chai-backbone-rails 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +41 -7
- data/lib/chai-backbone-rails/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
|
1
|
+
Backbone::Chai
|
2
|
+
==============
|
2
3
|
|
3
|
-
|
4
|
+
- Adds Chai matchers for common backbone assertions
|
5
|
+
- Adds Chai matchers for common sinon assertions
|
6
|
+
- Adds support for Factories
|
4
7
|
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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`)
|