chai-backbone-rails 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
- # Backbone::Chai
1
+ Backbone::Chai
2
+ ==============
2
3
 
3
- Some matchers to help testing backbone structures.
4
+ - Adds Chai matchers for common backbone assertions
5
+ - Adds Chai matchers for common sinon assertions
6
+ - Adds support for Factories
4
7
 
5
- ## Installation
8
+ Installation
9
+ ------------
6
10
 
7
11
  Add this line to your application's Gemfile:
8
12
 
@@ -16,7 +20,8 @@ Or install it yourself as:
16
20
 
17
21
  $ gem install chai-backbone-rails
18
22
 
19
- ## Usage
23
+ Using Backbone Chai Matchers
24
+ ----------------------------
20
25
 
21
26
  #= require chai-backbone
22
27
 
@@ -34,9 +39,10 @@ this can also be chained further:
34
39
  "page/3".should.route.to myRouter, "openPage", arguments: ["3"]
35
40
  "page/3".should.route.to myRouter, "openPage", considering: [conflictingRouter]
36
41
 
37
- ### Sinon
42
+ Using Sinon Chai Matchers
43
+ -------------------------
38
44
 
39
- Matchers have also been added for sinonjs.
45
+ Matchers have also been added for sinonjs.
40
46
 
41
47
  #= require chai-sinon
42
48
 
@@ -48,7 +54,35 @@ These are not complete yet, see tests and code for details.
48
54
  spy.should.have.been.called.with "argument1", 2, "argument3"
49
55
  spy.should.not.have.been.called
50
56
 
51
- ## Contributing
57
+ Using Factories
58
+ --------------
59
+
60
+ Factory support is added to quickly be able to build backbone models or
61
+ other objects as you see fit:
62
+
63
+ Factory.define 'user', (attributes = {}) ->
64
+ new User attributes
65
+
66
+ Factory.create 'user', name: 'Matthijs'
67
+
68
+ you can also use 'traits':
69
+
70
+ Factory.define 'user', (attributes = {}, traits...) ->
71
+ if traits.indexOf('male') isnt -1
72
+ attributes.gender = 'male'
73
+
74
+ returningClass = User
75
+ if traits.indexOf('admin') isnt -1
76
+ returningClass = AdminUser
77
+
78
+ new returningClass attributes
79
+
80
+ Factory.create 'user', name: 'Matthijs' # => new User name: 'Matthijs'
81
+ Factory.create 'male-user', name: 'Matthijs' # => new User name: 'Matthijs', gender: 'male'
82
+ Factory.create 'male-admin-user', name: 'Matthijs' # => new AdminUser name: 'Matthijs', gender: 'male'
83
+
84
+ Contributing
85
+ ------------
52
86
 
53
87
  1. Fork it
54
88
  2. Create your feature branch (`git checkout -b my-new-feature`)
@@ -1,7 +1,7 @@
1
1
  module Chai
2
2
  module Backbone
3
3
  module Rails
4
- VERSION = "0.0.3"
4
+ VERSION = "0.1.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: chai-backbone-rails
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthijs Groen