<commit_before>Backbone::Chai
==============

- Adds Chai matchers for common backbone assertions
- Adds Chai matchers for common sinon assertions
- Adds support for Factories

Installation
------------

Add this line to your application's Gemfile:

    gem 'chai-backbone-rails'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install chai-backbone-rails

Using Backbone Chai Matchers
----------------------------

    #= require chai-backbone

### Triggers

    model.should.trigger("change", with: [model]).when -> model.set attribute: "value"

this can also be chained further:

    model.should.trigger("change").and.trigger("change:attribute").when -> model.set attribute: "value"
    model.should.trigger("change").and.not.trigger("reset").when -> model.set attribute: "value"

### Routing

    "page/3".should.route.to myRouter, "openPage", arguments: ["3"]
    "page/3".should.route.to myRouter, "openPage", considering: [conflictingRouter]

Using Sinon Chai Matchers
-------------------------

Matchers have also been added for sinonjs.

    #= require chai-sinon

These are not complete yet, see tests and code for details.

    spy.should.have.been.called.exactly(x).times
    spy.should.have.been.called.before otherSpy
    spy.should.have.been.called.after otherSpy
    spy.should.have.been.called.with "argument1", 2, "argument3"
    spy.should.not.have.been.called

Using Factories
--------------

Factory support is added to quickly be able to build backbone models or
other objects as you see fit:

    Factory.define 'user', (attributes = {}) ->
      new User attributes

    Factory.create 'user', name: 'Matthijs'

you can also use 'traits':

    Factory.define 'user', (attributes = {}, traits...) ->
      if traits.indexOf('male') isnt -1
        attributes.gender = 'male'

      returningClass = User
      if traits.indexOf('admin') isnt -1
        returningClass = AdminUser

      new returningClass attributes

    Factory.create 'user', name: 'Matthijs' # => new User name: 'Matthijs'
    Factory.create 'male-user', name: 'Matthijs' # => new User name: 'Matthijs', gender: 'male'
    Factory.create 'male-admin-user', name: 'Matthijs' # => new AdminUser name: 'Matthijs', gender: 'male'

Contributing<commit_msg>Add require statement for factories<commit_after>Backbone::Chai
==============

- Adds Chai matchers for common backbone assertions
- Adds Chai matchers for common sinon assertions
- Adds support for Factories

Installation
------------

Add this line to your application's Gemfile:

    gem 'chai-backbone-rails'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install chai-backbone-rails

Using Backbone Chai Matchers
----------------------------

    #= require chai-backbone

### Triggers

    model.should.trigger("change", with: [model]).when -> model.set attribute: "value"

this can also be chained further:

    model.should.trigger("change").and.trigger("change:attribute").when -> model.set attribute: "value"
    model.should.trigger("change").and.not.trigger("reset").when -> model.set attribute: "value"

### Routing

    "page/3".should.route.to myRouter, "openPage", arguments: ["3"]
    "page/3".should.route.to myRouter, "openPage", considering: [conflictingRouter]

Using Sinon Chai Matchers
-------------------------

Matchers have also been added for sinonjs.

    #= require chai-sinon

These are not complete yet, see tests and code for details.

    spy.should.have.been.called.exactly(x).times
    spy.should.have.been.called.before otherSpy
    spy.should.have.been.called.after otherSpy
    spy.should.have.been.called.with "argument1", 2, "argument3"
    spy.should.not.have.been.called

Using Factories
--------------

Factory support is added to quickly be able to build backbone models or
other objects as you see fit:

    #= require factories

    Factory.define 'user', (attributes = {}) ->
      new User attributes

    Factory.create 'user', name: 'Matthijs'

you can also use 'traits':

    Factory.define 'user', (attributes = {}, traits...) ->
      if traits.indexOf('male') isnt -1
        attributes.gender = 'male'

      returningClass = User
      if traits.indexOf('admin') isnt -1
        returningClass = AdminUser

      new returningClass attributes

    Factory.create 'user', name: 'Matthijs' # => new User name: 'Matthijs'
    Factory.create 'male-user', name: 'Matthijs' # => new User name: 'Matthijs', gender: 'male'
    Factory.create 'male-admin-user', name: 'Matthijs' # => new AdminUser name: 'Matthijs', gender: 'male'

Contributing
{'fraction_non_alphanumeric': 0.15438290449193195, 'fraction_numerical': 0.0034888791975577847, 'mean_word_length': 3.0918822479928636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4275048', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1358, 'n_words': 403}