rspec-expectations 2.0.0.beta.22 → 2.6.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.
Files changed (93) hide show
  1. data/.gitignore +1 -1
  2. data/.travis.yml +7 -0
  3. data/Gemfile +35 -13
  4. data/Guardfile +5 -0
  5. data/License.txt +1 -1
  6. data/README.md +43 -0
  7. data/Rakefile +51 -9
  8. data/cucumber.yml +9 -2
  9. data/features/.nav +29 -0
  10. data/features/Changelog.md +101 -0
  11. data/features/README.markdown +45 -8
  12. data/features/built_in_matchers/README.md +71 -0
  13. data/features/built_in_matchers/be.feature +135 -0
  14. data/features/built_in_matchers/be_within.feature +43 -0
  15. data/features/built_in_matchers/cover.feature +45 -0
  16. data/features/{matchers → built_in_matchers}/equality.feature +16 -13
  17. data/features/built_in_matchers/exist.feature +43 -0
  18. data/features/built_in_matchers/expect_change.feature +59 -0
  19. data/features/built_in_matchers/expect_error.feature +105 -0
  20. data/features/built_in_matchers/have.feature +103 -0
  21. data/features/built_in_matchers/include.feature +121 -0
  22. data/features/built_in_matchers/match.feature +50 -0
  23. data/features/built_in_matchers/operators.feature +221 -0
  24. data/features/built_in_matchers/predicates.feature +128 -0
  25. data/features/built_in_matchers/respond_to.feature +78 -0
  26. data/features/built_in_matchers/satisfy.feature +31 -0
  27. data/features/built_in_matchers/throw_symbol.feature +85 -0
  28. data/features/built_in_matchers/types.feature +114 -0
  29. data/features/{matchers → custom_matchers}/access_running_example.feature +2 -2
  30. data/features/{matchers → custom_matchers}/define_diffable_matcher.feature +1 -1
  31. data/features/{matchers → custom_matchers}/define_matcher.feature +91 -9
  32. data/features/{matchers → custom_matchers}/define_matcher_outside_rspec.feature +1 -1
  33. data/features/{matchers → custom_matchers}/define_matcher_with_fluent_interface.feature +8 -11
  34. data/features/customized_message.feature +22 -0
  35. data/features/{expectations/diffing.feature → diffing.feature} +16 -16
  36. data/features/{expectations/implicit_docstrings.feature → implicit_docstrings.feature} +4 -4
  37. data/features/step_definitions/additional_cli_steps.rb +22 -0
  38. data/features/support/env.rb +5 -1
  39. data/features/test_frameworks/test_unit.feature +46 -0
  40. data/lib/rspec/expectations/backward_compatibility.rb +22 -1
  41. data/lib/rspec/expectations/deprecation.rb +36 -0
  42. data/lib/rspec/expectations/extensions.rb +0 -1
  43. data/lib/rspec/expectations/version.rb +1 -1
  44. data/lib/rspec/expectations.rb +2 -1
  45. data/lib/rspec/matchers/be.rb +4 -4
  46. data/lib/rspec/matchers/be_close.rb +2 -17
  47. data/lib/rspec/matchers/be_within.rb +40 -0
  48. data/lib/rspec/matchers/block_aliases.rb +19 -0
  49. data/lib/rspec/matchers/change.rb +74 -49
  50. data/lib/rspec/matchers/cover.rb +35 -0
  51. data/lib/rspec/matchers/exist.rb +13 -3
  52. data/lib/rspec/matchers/has.rb +15 -11
  53. data/lib/rspec/matchers/have.rb +5 -5
  54. data/lib/rspec/matchers/include.rb +14 -5
  55. data/lib/rspec/matchers/matcher.rb +39 -13
  56. data/lib/rspec/matchers/method_missing.rb +6 -3
  57. data/lib/rspec/matchers/operator_matcher.rb +12 -3
  58. data/lib/rspec/matchers/respond_to.rb +23 -9
  59. data/lib/rspec/matchers/satisfy.rb +4 -0
  60. data/lib/rspec/matchers/throw_symbol.rb +43 -26
  61. data/lib/rspec/matchers.rb +15 -3
  62. data/rspec-expectations.gemspec +2 -6
  63. data/spec/rspec/matchers/be_close_spec.rb +11 -39
  64. data/spec/rspec/matchers/be_spec.rb +8 -8
  65. data/spec/rspec/matchers/be_within_spec.rb +64 -0
  66. data/spec/rspec/matchers/change_spec.rb +88 -9
  67. data/spec/rspec/matchers/cover_spec.rb +65 -0
  68. data/spec/rspec/matchers/description_generation_spec.rb +41 -25
  69. data/spec/rspec/matchers/exist_spec.rb +90 -51
  70. data/spec/rspec/matchers/has_spec.rb +2 -2
  71. data/spec/rspec/matchers/have_spec.rb +291 -291
  72. data/spec/rspec/matchers/include_spec.rb +318 -65
  73. data/spec/rspec/matchers/matcher_spec.rb +91 -0
  74. data/spec/rspec/matchers/matchers_spec.rb +29 -0
  75. data/spec/rspec/matchers/method_missing_spec.rb +23 -0
  76. data/spec/rspec/matchers/operator_matcher_spec.rb +36 -10
  77. data/spec/rspec/matchers/respond_to_spec.rb +177 -1
  78. data/spec/rspec/matchers/satisfy_spec.rb +4 -0
  79. data/spec/rspec/matchers/throw_symbol_spec.rb +27 -10
  80. data/spec/spec_helper.rb +10 -35
  81. data/spec/support/classes.rb +1 -1
  82. data/spec/support/matchers.rb +22 -0
  83. data/spec/support/ruby_version.rb +10 -0
  84. metadata +95 -114
  85. data/History.md +0 -16
  86. data/README.markdown +0 -23
  87. data/features/expectations/attribute_of_subject.feature +0 -19
  88. data/features/expectations/customized_message.feature +0 -54
  89. data/features/matchers/expect_change.feature +0 -65
  90. data/features/matchers/expect_error.feature +0 -44
  91. data/lib/rspec/expectations/extensions/rspec/core/example_group.rb +0 -19
  92. data/spec/suite.rb +0 -1
  93. /data/{Upgrade.markdown → features/Upgrade.md} +0 -0
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
4
+ hash: 23
5
+ prerelease:
5
6
  segments:
6
7
  - 2
8
+ - 6
7
9
  - 0
8
- - 0
9
- - beta
10
- - 22
11
- version: 2.0.0.beta.22
10
+ version: 2.6.0
12
11
  platform: ruby
13
12
  authors:
14
13
  - David Chelimsky
@@ -17,88 +16,25 @@ autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
18
 
20
- date: 2010-09-12 00:00:00 -05:00
19
+ date: 2011-05-12 00:00:00 -05:00
21
20
  default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
24
- name: diff-lcs
25
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
24
  none: false
27
25
  requirements:
28
- - - ">="
26
+ - - ~>
29
27
  - !ruby/object:Gem::Version
28
+ hash: 23
30
29
  segments:
31
30
  - 1
32
31
  - 1
33
32
  - 2
34
33
  version: 1.1.2
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: cucumber
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- segments:
46
- - 0
47
- - 6
48
- - 2
49
- version: 0.6.2
50
- type: :development
51
34
  prerelease: false
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: aruba
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- segments:
61
- - 0
62
- - 1
63
- - 1
64
- version: 0.1.1
65
- type: :development
66
- prerelease: false
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: rspec-core
70
- requirement: &id004 !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- segments:
76
- - 2
77
- - 0
78
- - 0
79
- - beta
80
- - 22
81
- version: 2.0.0.beta.22
82
- type: :development
83
- prerelease: false
84
- version_requirements: *id004
85
- - !ruby/object:Gem::Dependency
86
- name: rspec-mocks
87
- requirement: &id005 !ruby/object:Gem::Requirement
88
- none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- segments:
93
- - 2
94
- - 0
95
- - 0
96
- - beta
97
- - 22
98
- version: 2.0.0.beta.22
99
- type: :development
100
- prerelease: false
101
- version_requirements: *id005
35
+ type: :runtime
36
+ requirement: *id001
37
+ name: diff-lcs
102
38
  description: rspec expectations (should[_not] and matchers)
103
39
  email: dchelimsky@gmail.com;chad.humphries@gmail.com
104
40
  executables: []
@@ -106,40 +42,58 @@ executables: []
106
42
  extensions: []
107
43
 
108
44
  extra_rdoc_files:
109
- - README.markdown
45
+ - README.md
110
46
  files:
111
47
  - .document
112
48
  - .gitignore
49
+ - .travis.yml
113
50
  - Gemfile
114
- - History.md
51
+ - Guardfile
115
52
  - License.txt
116
- - README.markdown
53
+ - README.md
117
54
  - Rakefile
118
- - Upgrade.markdown
119
55
  - cucumber.yml
56
+ - features/.nav
57
+ - features/Changelog.md
120
58
  - features/README.markdown
121
- - features/expectations/attribute_of_subject.feature
122
- - features/expectations/customized_message.feature
123
- - features/expectations/diffing.feature
124
- - features/expectations/implicit_docstrings.feature
125
- - features/matchers/access_running_example.feature
126
- - features/matchers/define_diffable_matcher.feature
127
- - features/matchers/define_matcher.feature
128
- - features/matchers/define_matcher_outside_rspec.feature
129
- - features/matchers/define_matcher_with_fluent_interface.feature
130
- - features/matchers/equality.feature
131
- - features/matchers/expect_change.feature
132
- - features/matchers/expect_error.feature
59
+ - features/Upgrade.md
60
+ - features/built_in_matchers/README.md
61
+ - features/built_in_matchers/be.feature
62
+ - features/built_in_matchers/be_within.feature
63
+ - features/built_in_matchers/cover.feature
64
+ - features/built_in_matchers/equality.feature
65
+ - features/built_in_matchers/exist.feature
66
+ - features/built_in_matchers/expect_change.feature
67
+ - features/built_in_matchers/expect_error.feature
68
+ - features/built_in_matchers/have.feature
69
+ - features/built_in_matchers/include.feature
70
+ - features/built_in_matchers/match.feature
71
+ - features/built_in_matchers/operators.feature
72
+ - features/built_in_matchers/predicates.feature
73
+ - features/built_in_matchers/respond_to.feature
74
+ - features/built_in_matchers/satisfy.feature
75
+ - features/built_in_matchers/throw_symbol.feature
76
+ - features/built_in_matchers/types.feature
77
+ - features/custom_matchers/access_running_example.feature
78
+ - features/custom_matchers/define_diffable_matcher.feature
79
+ - features/custom_matchers/define_matcher.feature
80
+ - features/custom_matchers/define_matcher_outside_rspec.feature
81
+ - features/custom_matchers/define_matcher_with_fluent_interface.feature
82
+ - features/customized_message.feature
83
+ - features/diffing.feature
84
+ - features/implicit_docstrings.feature
85
+ - features/step_definitions/additional_cli_steps.rb
133
86
  - features/support/env.rb
87
+ - features/test_frameworks/test_unit.feature
134
88
  - lib/rspec-expectations.rb
135
89
  - lib/rspec/expectations.rb
136
90
  - lib/rspec/expectations/backward_compatibility.rb
91
+ - lib/rspec/expectations/deprecation.rb
137
92
  - lib/rspec/expectations/differ.rb
138
93
  - lib/rspec/expectations/errors.rb
139
94
  - lib/rspec/expectations/extensions.rb
140
95
  - lib/rspec/expectations/extensions/array.rb
141
96
  - lib/rspec/expectations/extensions/kernel.rb
142
- - lib/rspec/expectations/extensions/rspec/core/example_group.rb
143
97
  - lib/rspec/expectations/fail_with.rb
144
98
  - lib/rspec/expectations/handler.rb
145
99
  - lib/rspec/expectations/version.rb
@@ -148,8 +102,11 @@ files:
148
102
  - lib/rspec/matchers/be_close.rb
149
103
  - lib/rspec/matchers/be_instance_of.rb
150
104
  - lib/rspec/matchers/be_kind_of.rb
105
+ - lib/rspec/matchers/be_within.rb
106
+ - lib/rspec/matchers/block_aliases.rb
151
107
  - lib/rspec/matchers/change.rb
152
108
  - lib/rspec/matchers/compatibility.rb
109
+ - lib/rspec/matchers/cover.rb
153
110
  - lib/rspec/matchers/dsl.rb
154
111
  - lib/rspec/matchers/eq.rb
155
112
  - lib/rspec/matchers/eql.rb
@@ -180,8 +137,10 @@ files:
180
137
  - spec/rspec/matchers/be_instance_of_spec.rb
181
138
  - spec/rspec/matchers/be_kind_of_spec.rb
182
139
  - spec/rspec/matchers/be_spec.rb
140
+ - spec/rspec/matchers/be_within_spec.rb
183
141
  - spec/rspec/matchers/change_spec.rb
184
142
  - spec/rspec/matchers/compatibility_spec.rb
143
+ - spec/rspec/matchers/cover_spec.rb
185
144
  - spec/rspec/matchers/description_generation_spec.rb
186
145
  - spec/rspec/matchers/dsl_spec.rb
187
146
  - spec/rspec/matchers/eq_spec.rb
@@ -195,14 +154,16 @@ files:
195
154
  - spec/rspec/matchers/match_spec.rb
196
155
  - spec/rspec/matchers/matcher_spec.rb
197
156
  - spec/rspec/matchers/matchers_spec.rb
157
+ - spec/rspec/matchers/method_missing_spec.rb
198
158
  - spec/rspec/matchers/operator_matcher_spec.rb
199
159
  - spec/rspec/matchers/raise_error_spec.rb
200
160
  - spec/rspec/matchers/respond_to_spec.rb
201
161
  - spec/rspec/matchers/satisfy_spec.rb
202
162
  - spec/rspec/matchers/throw_symbol_spec.rb
203
163
  - spec/spec_helper.rb
204
- - spec/suite.rb
205
164
  - spec/support/classes.rb
165
+ - spec/support/matchers.rb
166
+ - spec/support/ruby_version.rb
206
167
  - specs.watchr
207
168
  has_rdoc: true
208
169
  homepage: http://github.com/rspec/rspec-expectations
@@ -218,42 +179,58 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
179
  requirements:
219
180
  - - ">="
220
181
  - !ruby/object:Gem::Version
221
- hash: -37858944882232104
182
+ hash: 3
222
183
  segments:
223
184
  - 0
224
185
  version: "0"
225
186
  required_rubygems_version: !ruby/object:Gem::Requirement
226
187
  none: false
227
188
  requirements:
228
- - - ">"
189
+ - - ">="
229
190
  - !ruby/object:Gem::Version
191
+ hash: 3
230
192
  segments:
231
- - 1
232
- - 3
233
- - 1
234
- version: 1.3.1
193
+ - 0
194
+ version: "0"
235
195
  requirements: []
236
196
 
237
197
  rubyforge_project: rspec
238
- rubygems_version: 1.3.7
198
+ rubygems_version: 1.6.2
239
199
  signing_key:
240
200
  specification_version: 3
241
- summary: rspec-expectations-2.0.0.beta.22
201
+ summary: rspec-expectations-2.6.0
242
202
  test_files:
203
+ - features/Changelog.md
243
204
  - features/README.markdown
244
- - features/expectations/attribute_of_subject.feature
245
- - features/expectations/customized_message.feature
246
- - features/expectations/diffing.feature
247
- - features/expectations/implicit_docstrings.feature
248
- - features/matchers/access_running_example.feature
249
- - features/matchers/define_diffable_matcher.feature
250
- - features/matchers/define_matcher.feature
251
- - features/matchers/define_matcher_outside_rspec.feature
252
- - features/matchers/define_matcher_with_fluent_interface.feature
253
- - features/matchers/equality.feature
254
- - features/matchers/expect_change.feature
255
- - features/matchers/expect_error.feature
205
+ - features/Upgrade.md
206
+ - features/built_in_matchers/README.md
207
+ - features/built_in_matchers/be.feature
208
+ - features/built_in_matchers/be_within.feature
209
+ - features/built_in_matchers/cover.feature
210
+ - features/built_in_matchers/equality.feature
211
+ - features/built_in_matchers/exist.feature
212
+ - features/built_in_matchers/expect_change.feature
213
+ - features/built_in_matchers/expect_error.feature
214
+ - features/built_in_matchers/have.feature
215
+ - features/built_in_matchers/include.feature
216
+ - features/built_in_matchers/match.feature
217
+ - features/built_in_matchers/operators.feature
218
+ - features/built_in_matchers/predicates.feature
219
+ - features/built_in_matchers/respond_to.feature
220
+ - features/built_in_matchers/satisfy.feature
221
+ - features/built_in_matchers/throw_symbol.feature
222
+ - features/built_in_matchers/types.feature
223
+ - features/custom_matchers/access_running_example.feature
224
+ - features/custom_matchers/define_diffable_matcher.feature
225
+ - features/custom_matchers/define_matcher.feature
226
+ - features/custom_matchers/define_matcher_outside_rspec.feature
227
+ - features/custom_matchers/define_matcher_with_fluent_interface.feature
228
+ - features/customized_message.feature
229
+ - features/diffing.feature
230
+ - features/implicit_docstrings.feature
231
+ - features/step_definitions/additional_cli_steps.rb
256
232
  - features/support/env.rb
233
+ - features/test_frameworks/test_unit.feature
257
234
  - spec/rspec/expectations/differ_spec.rb
258
235
  - spec/rspec/expectations/extensions/kernel_spec.rb
259
236
  - spec/rspec/expectations/fail_with_spec.rb
@@ -262,8 +239,10 @@ test_files:
262
239
  - spec/rspec/matchers/be_instance_of_spec.rb
263
240
  - spec/rspec/matchers/be_kind_of_spec.rb
264
241
  - spec/rspec/matchers/be_spec.rb
242
+ - spec/rspec/matchers/be_within_spec.rb
265
243
  - spec/rspec/matchers/change_spec.rb
266
244
  - spec/rspec/matchers/compatibility_spec.rb
245
+ - spec/rspec/matchers/cover_spec.rb
267
246
  - spec/rspec/matchers/description_generation_spec.rb
268
247
  - spec/rspec/matchers/dsl_spec.rb
269
248
  - spec/rspec/matchers/eq_spec.rb
@@ -277,11 +256,13 @@ test_files:
277
256
  - spec/rspec/matchers/match_spec.rb
278
257
  - spec/rspec/matchers/matcher_spec.rb
279
258
  - spec/rspec/matchers/matchers_spec.rb
259
+ - spec/rspec/matchers/method_missing_spec.rb
280
260
  - spec/rspec/matchers/operator_matcher_spec.rb
281
261
  - spec/rspec/matchers/raise_error_spec.rb
282
262
  - spec/rspec/matchers/respond_to_spec.rb
283
263
  - spec/rspec/matchers/satisfy_spec.rb
284
264
  - spec/rspec/matchers/throw_symbol_spec.rb
285
265
  - spec/spec_helper.rb
286
- - spec/suite.rb
287
266
  - spec/support/classes.rb
267
+ - spec/support/matchers.rb
268
+ - spec/support/ruby_version.rb
data/History.md DELETED
@@ -1,16 +0,0 @@
1
- ## rspec-expectations release history (incomplete)
2
-
3
- ### 2.0.0.beta.22 / 2010-09-12
4
-
5
- [full changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.beta.20...v2.0.0.beta.22)
6
-
7
- * Enhancements
8
- * diffing improvements
9
- * diff multiline strings
10
- * don't diff single line strings
11
- * don't diff numbers (silly)
12
- * diff regexp + multiline string
13
-
14
- * Bug fixes
15
- * should[_not] change now handles boolean values correctly
16
-
data/README.markdown DELETED
@@ -1,23 +0,0 @@
1
- # RSpec Expectations
2
-
3
- rspec-expectations adds `should` and `should_not` to every object and includes
4
- RSpec::Matchers, a library of standard matchers.
5
-
6
- ## Matchers
7
-
8
- Matchers are objects used to compose expectations:
9
-
10
- result.should eq("this value")
11
-
12
- In that example, `eq("this value")` returns a `Matcher` object that
13
- compares the actual `result` to the expected `"this value"`.
14
-
15
- ## Contribute
16
-
17
- See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev)
18
-
19
- ## Also see
20
-
21
- * [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
22
- * [http://github.com/rspec/rspec-core](http://github.com/rspec/rspec-core)
23
- * [http://github.com/rspec/rspec-mocks](http://github.com/rspec/rspec-mocks)
@@ -1,19 +0,0 @@
1
- Feature: attribute of subject
2
-
3
- In order to get more meaningful failure messages
4
- As a spec author
5
- I want RSpec to tell me what attribute a matcher applies
6
- to when using the its(:attribute) technique
7
-
8
- Scenario: eq matcher fails
9
- Given a file named "example_spec.rb" with:
10
- """
11
- describe "an array" do
12
- subject { [] }
13
- its(:size) { should eq(1) } # intentionally fail
14
- end
15
- """
16
-
17
- When I run "rspec example_spec.rb -fdoc"
18
- Then the output should contain "Failure/Error: its(:size) { should eq(1) }"
19
- And the output should contain "expected 1"
@@ -1,54 +0,0 @@
1
- Feature: customized message
2
-
3
- In order to get the feedback I want
4
- As an RSpec user
5
- I want to customize the failure message per example
6
-
7
- Scenario: one additional method
8
- Given a file named "node_spec.rb" with:
9
- """
10
- class Node
11
- def initialize(state=:waiting)
12
- @state = state
13
- end
14
- def state
15
- @state
16
- end
17
- def waiting?
18
- @state == :waiting
19
- end
20
- def started?
21
- @state == :started
22
- end
23
- def start
24
- @state = :started
25
- end
26
- end
27
-
28
- describe "a new Node" do
29
- it "should be waiting" do
30
- node = Node.new(:started) #start w/ started to trigger failure
31
- node.should be_waiting, "node.state: #{node.state} (first example)"
32
- end
33
-
34
- it "should not be started" do
35
- node = Node.new(:started) #start w/ started to trigger failure
36
- node.should_not be_started, "node.state: #{node.state} (second example)"
37
- end
38
- end
39
-
40
- describe "node.start" do
41
- it "should change the state" do
42
- node = Node.new(:started) #start w/ started to trigger failure
43
- lambda {node.start}.should change{node.state}, "expected a change"
44
- end
45
- end
46
-
47
- """
48
- When I run "rspec ./node_spec.rb --format documentation"
49
- Then the output should contain "3 examples, 3 failures"
50
- And the output should not contain "to return true, got false"
51
- And the output should not contain "to return false, got true"
52
- And the output should contain "node.state: started (first example)"
53
- And the output should contain "node.state: started (second example)"
54
- And the output should contain "expected a change"
@@ -1,65 +0,0 @@
1
- Feature: expect change
2
-
3
- Expect some code (wrapped in a proc) to change the state of some object.
4
-
5
- Scenario: expecting change
6
- Given a file named "expect_change_spec.rb" with:
7
- """
8
- class Counter
9
- class << self
10
- def increment
11
- @count ||= 0
12
- @count += 1
13
- end
14
-
15
- def count
16
- @count ||= 0
17
- end
18
- end
19
- end
20
-
21
- describe Counter, "#increment" do
22
- it "should increment the count" do
23
- expect{Counter.increment}.to change{Counter.count}.from(0).to(1)
24
- end
25
-
26
- # deliberate failure
27
- it "should increment the count by 2" do
28
- expect{Counter.increment}.to change{Counter.count}.by(2)
29
- end
30
- end
31
- """
32
- When I run "rspec ./expect_change_spec.rb"
33
- Then the output should contain "2 examples, 1 failure"
34
- Then the output should contain "should have been changed by 2, but was changed by 1"
35
-
36
- Scenario: expecting no change
37
- Given a file named "expect_no_change_spec.rb" with:
38
- """
39
- class Counter
40
- class << self
41
- def increment
42
- @count ||= 0
43
- @count += 1
44
- end
45
-
46
- def count
47
- @count ||= 0
48
- end
49
- end
50
- end
51
-
52
- describe Counter, "#increment" do
53
- it "should not increment the count by 2" do
54
- expect{Counter.increment}.to_not change{Counter.count}.from(0).to(2)
55
- end
56
-
57
- # deliberate failure
58
- it "should not increment the count by 1" do
59
- expect{Counter.increment}.to_not change{Counter.count}.by(1)
60
- end
61
- end
62
- """
63
- When I run "rspec ./expect_no_change_spec.rb"
64
- Then the output should contain "2 examples, 1 failure"
65
- Then the output should contain "should not have changed, but did change from 1 to 2"
@@ -1,44 +0,0 @@
1
- Feature: expect error
2
-
3
- Expect a proc to change the state of some object.
4
-
5
- Scenario: expect error
6
- Given a file named "expect_error_spec.rb" with:
7
- """
8
- describe Object, "#non_existent_message" do
9
- it "should raise" do
10
- expect{Object.non_existent_message}.to raise_error(NameError)
11
- end
12
- end
13
-
14
- #deliberate failure
15
- describe Object, "#public_instance_methods" do
16
- it "should raise" do
17
- expect{Object.public_instance_methods}.to raise_error(NameError)
18
- end
19
- end
20
- """
21
- When I run "rspec ./expect_error_spec.rb"
22
- Then the output should contain "2 examples, 1 failure"
23
- Then the output should contain "expected NameError but nothing was raised"
24
-
25
- Scenario: expect no error
26
- Given a file named "expect_no_error_spec.rb" with:
27
- """
28
- describe Object, "#public_instance_methods" do
29
- it "should not raise" do
30
- expect{Object.public_instance_methods}.to_not raise_error(NameError)
31
- end
32
- end
33
-
34
- #deliberate failure
35
- describe Object, "#non_existent_message" do
36
- it "should not raise" do
37
- expect{Object.non_existent_message}.to_not raise_error(NameError)
38
- end
39
- end
40
- """
41
- When I run "rspec ./expect_no_error_spec.rb"
42
- Then the output should contain "2 examples, 1 failure"
43
- Then the output should contain "undefined method `non_existent_message'"
44
-
@@ -1,19 +0,0 @@
1
- module RSpec
2
- module Core
3
- class ExampleGroup
4
- module BlockAliases
5
- alias_method :to, :should
6
- alias_method :to_not, :should_not
7
- end
8
-
9
- # Extends the submitted block with aliases to and to_not
10
- # for should and should_not. Allows expectations like this:
11
- #
12
- # expect { this_block }.to change{this.expression}.from(old_value).to(new_value)
13
- # expect { this_block }.to raise_error
14
- def expect(&block)
15
- block.extend BlockAliases
16
- end
17
- end
18
- end
19
- end
data/spec/suite.rb DELETED
@@ -1 +0,0 @@
1
- Dir["spec/**/*_spec.rb"].each {|f| require f}
File without changes