chai-backbone-rails 0.1.0 → 0.1.1

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 CHANGED
@@ -39,6 +39,10 @@ this can also be chained further:
39
39
  "page/3".should.route.to myRouter, "openPage", arguments: ["3"]
40
40
  "page/3".should.route.to myRouter, "openPage", considering: [conflictingRouter]
41
41
 
42
+ ### Changes
43
+
44
+ (-> view.$('p').length).should.change.by(4).when -> collection.add 1, 2, 3, 4
45
+
42
46
  Using Sinon Chai Matchers
43
47
  -------------------------
44
48
 
@@ -55,11 +59,13 @@ These are not complete yet, see tests and code for details.
55
59
  spy.should.not.have.been.called
56
60
 
57
61
  Using Factories
58
- --------------
62
+ ---------------
59
63
 
60
64
  Factory support is added to quickly be able to build backbone models or
61
65
  other objects as you see fit:
62
66
 
67
+ #= require factories
68
+
63
69
  Factory.define 'user', (attributes = {}) ->
64
70
  new User attributes
65
71
 
@@ -1,7 +1,7 @@
1
1
  module Chai
2
2
  module Backbone
3
3
  module Rails
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
@@ -115,6 +115,43 @@
115
115
 
116
116
  chai.Assertion.addChainableMethod 'to', routeTo, -> this
117
117
 
118
+ # Verifies if the subject return value changes by given delta 'when' events happen
119
+ #
120
+ # Examples:
121
+ # (-> resultValue).should.change.by(1).when -> resultValue += 1
122
+ #
123
+ chai.Assertion.addProperty 'change', ->
124
+ flag(this, 'change', true)
125
+
126
+ formatFunction = (func) ->
127
+ func.toString().replace(/^\s*function \(\) {\s*/, '').replace(/\s+}$/, '').replace(/\s*return\s*/, '')
128
+
129
+ changeBy = (delta) ->
130
+ definedActions = flag(this, 'whenActions') || []
131
+
132
+ # Add a around filter to the when actions
133
+ definedActions.push
134
+ negate: flag(this, 'negate')
135
+
136
+ # set up the callback to trigger
137
+ before: (context) ->
138
+ @startValue = flag(context, 'object')()
139
+
140
+ # verify if our callback is triggered
141
+ after: (context) ->
142
+ negate = flag(context, 'negate')
143
+ flag(context, 'negate', @negate)
144
+ object = flag(context, 'object')
145
+ @endValue = object()
146
+ context.assert (@startValue + delta is @endValue),
147
+ "expected \"#{formatFunction object}\" to change by #{delta} but it was changed by #{@endValue - @startValue}",
148
+ "expected \"#{formatFunction object}\" not change"
149
+
150
+ flag(context, 'negate', negate)
151
+ flag(this, 'whenActions', definedActions)
152
+
153
+ chai.Assertion.addChainableMethod 'by', changeBy, -> this
154
+
118
155
  )
119
156
 
120
157
 
metadata CHANGED
@@ -1,28 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: chai-backbone-rails
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
4
5
  prerelease:
5
- version: 0.1.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Matthijs Groen
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-09-26 00:00:00 Z
12
+ date: 2012-09-26 00:00:00.000000000 Z
14
13
  dependencies: []
15
-
16
14
  description: Chai.js matchers for Backbone.js framework
17
- email:
15
+ email:
18
16
  - matthijs.groen@gmail.com
19
17
  executables: []
20
-
21
18
  extensions: []
22
-
23
19
  extra_rdoc_files: []
24
-
25
- files:
20
+ files:
26
21
  - .gitignore
27
22
  - Gemfile
28
23
  - LICENSE
@@ -39,32 +34,28 @@ files:
39
34
  - vendor/assets/javascripts/spec/chai-backbone_spec.js.coffee
40
35
  - vendor/assets/javascripts/spec/chai-sinon_spec.js.coffee
41
36
  - vendor/assets/javascripts/spec/factory_spec.js.coffee
42
- homepage: ""
37
+ homepage: ''
43
38
  licenses: []
44
-
45
39
  post_install_message:
46
40
  rdoc_options: []
47
-
48
- require_paths:
41
+ require_paths:
49
42
  - lib
50
- required_ruby_version: !ruby/object:Gem::Requirement
43
+ required_ruby_version: !ruby/object:Gem::Requirement
51
44
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
56
- required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
50
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
62
55
  requirements: []
63
-
64
56
  rubyforge_project:
65
- rubygems_version: 1.8.5
57
+ rubygems_version: 1.8.24
66
58
  signing_key:
67
59
  specification_version: 3
68
60
  summary: A set of assertion matchers to test Backbone code using Konacha in Rails
69
61
  test_files: []
70
-