rspec-expectations 2.14.5 → 2.99.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.
- checksums.yaml +15 -7
- data/Changelog.md +114 -31
- data/features/README.md +2 -1
- data/features/built_in_matchers/be.feature +40 -40
- data/features/step_definitions/additional_cli_steps.rb +10 -0
- data/features/test_frameworks/test_unit.feature +40 -0
- data/lib/rspec/expectations/caller_filter.rb +60 -0
- data/lib/rspec/{matchers → expectations}/configuration.rb +5 -3
- data/lib/rspec/expectations/deprecation.rb +11 -15
- data/lib/rspec/expectations/expectation_target.rb +75 -8
- data/lib/rspec/expectations/handler.rb +5 -1
- data/lib/rspec/expectations/syntax.rb +3 -5
- data/lib/rspec/expectations/version.rb +1 -2
- data/lib/rspec/expectations.rb +1 -1
- data/lib/rspec/matchers/be_close.rb +4 -1
- data/lib/rspec/matchers/built_in/base_matcher.rb +10 -5
- data/lib/rspec/matchers/built_in/be.rb +38 -9
- data/lib/rspec/matchers/built_in/be_within.rb +8 -2
- data/lib/rspec/matchers/built_in/change.rb +39 -1
- data/lib/rspec/matchers/built_in/has.rb +40 -7
- data/lib/rspec/matchers/built_in/have.rb +151 -2
- data/lib/rspec/matchers/built_in/include.rb +1 -1
- data/lib/rspec/matchers/built_in/match_array.rb +1 -1
- data/lib/rspec/matchers/built_in/raise_error.rb +7 -1
- data/lib/rspec/matchers/built_in/respond_to.rb +7 -1
- data/lib/rspec/matchers/built_in/satisfy.rb +7 -1
- data/lib/rspec/matchers/built_in/throw_symbol.rb +10 -2
- data/lib/rspec/matchers/built_in/yield.rb +25 -3
- data/lib/rspec/matchers/built_in.rb +2 -2
- data/lib/rspec/matchers/differentiate_block_method_types.rb +55 -0
- data/lib/rspec/matchers/dsl.rb +2 -1
- data/lib/rspec/matchers/match_aliases.rb +22 -0
- data/lib/rspec/matchers/matcher.rb +131 -10
- data/lib/rspec/matchers/operator_matcher.rb +70 -70
- data/lib/rspec/matchers/pretty.rb +4 -0
- data/lib/rspec/matchers/test_unit_integration.rb +22 -5
- data/lib/rspec/matchers.rb +41 -7
- data/lib/rspec-expectations.rb +5 -0
- data/spec/rspec/{matchers → expectations}/configuration_spec.rb +21 -2
- data/spec/rspec/expectations/expectation_target_spec.rb +62 -0
- data/spec/rspec/expectations/extensions/kernel_spec.rb +4 -0
- data/spec/rspec/expectations/handler_spec.rb +1 -1
- data/spec/rspec/expectations/syntax_spec.rb +6 -6
- data/spec/rspec/expectations_spec.rb +22 -1
- data/spec/rspec/matchers/base_matcher_spec.rb +15 -21
- data/spec/rspec/matchers/be_close_spec.rb +4 -1
- data/spec/rspec/matchers/be_spec.rb +105 -10
- data/spec/rspec/matchers/change_spec.rb +76 -1
- data/spec/rspec/matchers/description_generation_spec.rb +22 -18
- data/spec/rspec/matchers/differentiate_block_method_types_spec.rb +39 -0
- data/spec/rspec/matchers/eq_spec.rb +1 -1
- data/spec/rspec/matchers/has_spec.rb +24 -0
- data/spec/rspec/matchers/have_spec.rb +399 -1
- data/spec/rspec/matchers/matcher_spec.rb +213 -24
- data/spec/rspec/matchers/operator_matcher_spec.rb +28 -9
- data/spec/rspec/matchers/pretty_spec.rb +23 -0
- data/spec/rspec/matchers/raise_error_spec.rb +3 -3
- data/spec/rspec/matchers/throw_symbol_spec.rb +14 -14
- data/spec/spec_helper.rb +4 -2
- data/spec/support/helper_methods.rb +42 -0
- data/spec/support/shared_examples.rb +42 -0
- metadata +85 -64
- data/spec/rspec/matchers/matchers_spec.rb +0 -37
checksums.yaml
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
YjkxOGIyZDlkOGFkYmNlNTNiZTg1NzY3MmVmZDg4ZTE2YTg1NjNlZg==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
MDc2MmQyNGE4OWNlOTdhYTgyMDkyMDQ4MmI2NzQ1ZmRhYjhiYzE4Ng==
|
|
7
|
+
!binary "U0hBNTEy":
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
ODczNTI0ZjZjOWRhNzQ0Zjc5ZjVjODdjYTc1NzJjYzc1ZmM3NjQ5OGU0NDQ1
|
|
10
|
+
Y2MzODUzYzk5OTY1ZDI5MmY3OTlhZTRjNzJhZmQ4MzZmMzhkZWUwY2YxNTdl
|
|
11
|
+
ZmZiMmI1MWUzZThiOThlZWE3NDI3ZDFjMjhjZjBlM2E3OGRhYjM=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
ODJlOTYzOGFkMjRhZTQ1OWQ5YjZhNTk4NWY0ZjZhMzhhMzk2OGRiOGNiYThl
|
|
14
|
+
YWFiZWNmYWJhNWVhNGJkNWEwYmViYTQ0ZjUwMTU4NmViOGE2YTQwODY3NTkz
|
|
15
|
+
NDQ5ZTU4M2M0MTBlMzEwMjRiNzM0Nzg3NWQzZDE0NzM3ZmU2Yzc=
|
data/Changelog.md
CHANGED
|
@@ -1,12 +1,95 @@
|
|
|
1
|
+
### 2.99.0 / 2014-06-01
|
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.99.0.rc1...v2.99.0)
|
|
3
|
+
|
|
4
|
+
Enhancements:
|
|
5
|
+
|
|
6
|
+
* Special case deprecation message for `errors_on` with `rspec-rails` to be more useful.
|
|
7
|
+
(Aaron Kromer)
|
|
8
|
+
|
|
9
|
+
### 2.99.0.rc1 / 2014-05-18
|
|
10
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.99.0.beta2...2.99.0.rc1)
|
|
11
|
+
|
|
12
|
+
Deprecations:
|
|
13
|
+
|
|
14
|
+
* Deprecate `matcher_execution_context` attribute on DSL-defined
|
|
15
|
+
custom matchers. (Myron Marston)
|
|
16
|
+
* Deprecate `RSpec::Matchers::Pretty#_pretty_print`. (Myron Marston)
|
|
17
|
+
* Deprecate `RSpec::Matchers::Pretty#expected_to_sentence`. (Myron Marston)
|
|
18
|
+
* Deprecate `RSpec::Matchers::Configuration` in favor of
|
|
19
|
+
`RSpec::Expectations::Configuration`. (Myron Marston)
|
|
20
|
+
* Deprecate `be_xyz` predicate matcher on an object that doesn't respond to
|
|
21
|
+
`xyz?` or `xyzs?`. (Daniel Fone)
|
|
22
|
+
* Deprecate `have_xyz` matcher on an object that doesn't respond to `has_xyz?`.
|
|
23
|
+
(Daniel Fone)
|
|
24
|
+
* Deprecate `have_xyz` matcher on an object that has a private method `has_xyz?`.
|
|
25
|
+
(Jon Rowe)
|
|
26
|
+
* Issue a deprecation warning when a block expectation expression is
|
|
27
|
+
used with a matcher that doesn't explicitly support block expectations
|
|
28
|
+
via `supports_block_expectations?`. (Myron Marston)
|
|
29
|
+
* Deprecate `require 'rspec-expectations'`. Use
|
|
30
|
+
`require 'rspec/expectations'` instead. (Myron Marston)
|
|
31
|
+
|
|
32
|
+
### 2.99.0.beta2 / 2014-02-17
|
|
33
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.99.0.beta1...v2.99.0.beta2)
|
|
34
|
+
|
|
35
|
+
Deprecations:
|
|
36
|
+
|
|
37
|
+
* Deprecate chaining `by`, `by_at_least`, `by_at_most` or `to` off of
|
|
38
|
+
`expect { }.not_to change { }`. The docs have always said these are
|
|
39
|
+
not supported for the negative form but now they explicitly raise
|
|
40
|
+
errors in RSpec 3. (Myron Marston)
|
|
41
|
+
* Change the semantics of `expect { }.not_to change { x }.from(y)`.
|
|
42
|
+
In RSpec 2.x, this expectation would only fail if `x` started with
|
|
43
|
+
the value of `y` and changed. If it started with a different value
|
|
44
|
+
and changed, it would pass. In RSpec 3, it will pass only if the
|
|
45
|
+
value starts at `y` and it does not change. (Myron Marston)
|
|
46
|
+
* Deprecate `matcher == value` as an alias for `matcher.matches?(value)`,
|
|
47
|
+
in favor of `matcher === value`. (Myron Marston)
|
|
48
|
+
* Deprecate `RSpec::Matchers::OperatorMatcher` in favor of
|
|
49
|
+
`RSpec::Matchers::BuiltIn::OperatorMatcher`. (Myron Marston)
|
|
50
|
+
* Deprecate auto-integration with Test::Unit and minitest.
|
|
51
|
+
Instead, include `RSpec::Matchers` in the appropriate test case
|
|
52
|
+
base class yourself. (Myron Marston)
|
|
53
|
+
* Deprecate treating `#expected` on a DSL-generated custom matcher
|
|
54
|
+
as an array when only 1 argument is passed to the matcher method.
|
|
55
|
+
In RSpec 3 it will be the single value in order to make diffs
|
|
56
|
+
work properly. (Jon Rowe)
|
|
57
|
+
|
|
58
|
+
### 2.99.0.beta1 / 2013-11-07
|
|
59
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.4...v2.99.0.beta1)
|
|
60
|
+
|
|
61
|
+
Deprecations:
|
|
62
|
+
|
|
63
|
+
* Deprecate `have`, `have_at_least` and `have_at_most`. You can continue using those
|
|
64
|
+
matchers through https://github.com/rspec/rspec-collection_matchers, or
|
|
65
|
+
you can rewrite your expectations with something like
|
|
66
|
+
`expect(your_object.size).to eq(num)`. (Hugo Baraúna)
|
|
67
|
+
* Deprecate `be_xyz` predicate matcher when `xyz?` is a private method.
|
|
68
|
+
(Jon Rowe)
|
|
69
|
+
* Deprecate `be_true`/`be_false` in favour of `be_truthy`/`be_falsey`
|
|
70
|
+
(for Ruby's conditional semantics) or `be true`/`be false`
|
|
71
|
+
(for exact equality). (Sam Phippen)
|
|
72
|
+
* Deprecate calling helper methods from a custom matcher with the wrong
|
|
73
|
+
scope. (Myron Marston)
|
|
74
|
+
* `def self.foo` / `extend Helper` can be used to add macro methods
|
|
75
|
+
(e.g. methods that call the custom matcher DSL methods), but should
|
|
76
|
+
not be used to define helper methods called from within the DSL
|
|
77
|
+
blocks.
|
|
78
|
+
* `def foo` / `include Helper` is the opposite: it's for helper methods
|
|
79
|
+
callable from within a DSL block, but not for defining macros.
|
|
80
|
+
* RSpec 2.x allowed helper methods defined either way to be used for
|
|
81
|
+
either purpose, but RSpec 3.0 will not.
|
|
82
|
+
|
|
1
83
|
### 2.14.5 / 2014-02-01
|
|
2
|
-
[
|
|
84
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.4...v2.14.5)
|
|
3
85
|
|
|
4
86
|
Bug fixes
|
|
5
87
|
|
|
6
|
-
* Fix wrong matcher descriptions with falsey expected value
|
|
88
|
+
* Fix wrong matcher descriptions with falsey expected value
|
|
89
|
+
(yujinakayama)
|
|
7
90
|
|
|
8
91
|
### 2.14.4 / 2013-11-06
|
|
9
|
-
[
|
|
92
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.3...v2.14.4)
|
|
10
93
|
|
|
11
94
|
Bug fixes
|
|
12
95
|
|
|
@@ -15,7 +98,7 @@ Bug fixes
|
|
|
15
98
|
back to default internal encoding with replacing characters. (Jon Rowe)
|
|
16
99
|
|
|
17
100
|
### 2.14.3 / 2013-09-22
|
|
18
|
-
[
|
|
101
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.2...v2.14.3)
|
|
19
102
|
|
|
20
103
|
Bug fixes
|
|
21
104
|
|
|
@@ -26,7 +109,7 @@ Bug fixes
|
|
|
26
109
|
`method_missing` (Jon Rowe)
|
|
27
110
|
|
|
28
111
|
### 2.14.2 / 2013-08-14
|
|
29
|
-
[
|
|
112
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.1...v2.14.2)
|
|
30
113
|
|
|
31
114
|
Bug fixes
|
|
32
115
|
|
|
@@ -42,7 +125,7 @@ Bug fixes
|
|
|
42
125
|
`SomeClass === SomeClass` returns false. (Myron Marston)
|
|
43
126
|
|
|
44
127
|
### 2.14.1 / 2013-08-08
|
|
45
|
-
[
|
|
128
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.0...2.14.1)
|
|
46
129
|
|
|
47
130
|
Bug fixes
|
|
48
131
|
|
|
@@ -51,7 +134,7 @@ Bug fixes
|
|
|
51
134
|
errors (Jon Rowe).
|
|
52
135
|
|
|
53
136
|
### 2.14.0 / 2013-07-06
|
|
54
|
-
[
|
|
137
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.0.rc1...v2.14.0)
|
|
55
138
|
|
|
56
139
|
Bug fixes
|
|
57
140
|
|
|
@@ -63,7 +146,7 @@ Bug fixes
|
|
|
63
146
|
change...` (Sam Phippen).
|
|
64
147
|
|
|
65
148
|
### 2.14.0.rc1 / 2013-05-27
|
|
66
|
-
[
|
|
149
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.13.0...v2.14.0.rc1)
|
|
67
150
|
|
|
68
151
|
Enhancements
|
|
69
152
|
|
|
@@ -97,7 +180,7 @@ Deprecations
|
|
|
97
180
|
error_ to pass. (Sam Phippen and David Chelimsky)
|
|
98
181
|
|
|
99
182
|
### 2.13.0 / 2013-02-23
|
|
100
|
-
[
|
|
183
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.12.1...v2.13.0)
|
|
101
184
|
|
|
102
185
|
Enhancements
|
|
103
186
|
|
|
@@ -128,7 +211,7 @@ Bug fixes
|
|
|
128
211
|
printed for empty diffs (Myron Marston).
|
|
129
212
|
|
|
130
213
|
### 2.12.1 / 2012-12-15
|
|
131
|
-
[
|
|
214
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.12.0...v2.12.1)
|
|
132
215
|
|
|
133
216
|
Bug fixes
|
|
134
217
|
|
|
@@ -140,7 +223,7 @@ Bug fixes
|
|
|
140
223
|
(Steven Harman)
|
|
141
224
|
|
|
142
225
|
### 2.12.0 / 2012-11-12
|
|
143
|
-
[
|
|
226
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.3...v2.12.0)
|
|
144
227
|
|
|
145
228
|
Enhancements
|
|
146
229
|
|
|
@@ -163,7 +246,7 @@ Bug fixes
|
|
|
163
246
|
(Tom Stuart)
|
|
164
247
|
|
|
165
248
|
### 2.11.3 / 2012-09-04
|
|
166
|
-
[
|
|
249
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.2...v2.11.3)
|
|
167
250
|
|
|
168
251
|
Bug fixes
|
|
169
252
|
|
|
@@ -179,7 +262,7 @@ Bug fixes
|
|
|
179
262
|
}.to change { user.last_emailed_at }.to be_within(1.second).of(Time.zone.now)
|
|
180
263
|
|
|
181
264
|
### 2.11.2 / 2012-07-25
|
|
182
|
-
[
|
|
265
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.1...v2.11.2)
|
|
183
266
|
|
|
184
267
|
Bug fixes
|
|
185
268
|
|
|
@@ -188,7 +271,7 @@ Bug fixes
|
|
|
188
271
|
of the object hierarchy. (Gabriel Gilder)
|
|
189
272
|
|
|
190
273
|
### 2.11.1 / 2012-07-08
|
|
191
|
-
[
|
|
274
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.0...v2.11.1)
|
|
192
275
|
|
|
193
276
|
Bug fixes
|
|
194
277
|
|
|
@@ -197,7 +280,7 @@ Bug fixes
|
|
|
197
280
|
* `Time`, for example, is a legit alternative.
|
|
198
281
|
|
|
199
282
|
### 2.11.0 / 2012-07-07
|
|
200
|
-
[
|
|
283
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.10.0...v2.11.0)
|
|
201
284
|
|
|
202
285
|
Enhancements
|
|
203
286
|
|
|
@@ -220,7 +303,7 @@ Bug fixes
|
|
|
220
303
|
Marston)
|
|
221
304
|
|
|
222
305
|
### 2.10.0 / 2012-05-03
|
|
223
|
-
[
|
|
306
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.9.1...v2.10.0)
|
|
224
307
|
|
|
225
308
|
Enhancements
|
|
226
309
|
|
|
@@ -238,7 +321,7 @@ Bug fixes
|
|
|
238
321
|
* Fix message-specific specs to pass on Rubinius (John Firebaugh)
|
|
239
322
|
|
|
240
323
|
### 2.9.1 / 2012-04-03
|
|
241
|
-
[
|
|
324
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.9.0...v2.9.1)
|
|
242
325
|
|
|
243
326
|
Bug fixes
|
|
244
327
|
|
|
@@ -249,7 +332,7 @@ Bug fixes
|
|
|
249
332
|
* Fix using execution context methods in nested DSL matchers (mirasrael)
|
|
250
333
|
|
|
251
334
|
### 2.9.0 / 2012-03-17
|
|
252
|
-
[
|
|
335
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.8.0...v2.9.0)
|
|
253
336
|
|
|
254
337
|
Enhancements
|
|
255
338
|
|
|
@@ -269,7 +352,7 @@ Bug fixes
|
|
|
269
352
|
|
|
270
353
|
### 2.8.0 / 2012-01-04
|
|
271
354
|
|
|
272
|
-
[
|
|
355
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.8.0.rc2...v2.8.0)
|
|
273
356
|
|
|
274
357
|
Enhancements
|
|
275
358
|
|
|
@@ -278,13 +361,13 @@ Enhancements
|
|
|
278
361
|
|
|
279
362
|
### 2.8.0.rc2 / 2011-12-19
|
|
280
363
|
|
|
281
|
-
[
|
|
364
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.8.0.rc1...v2.8.0.rc2)
|
|
282
365
|
|
|
283
366
|
No changes for this release. Just releasing with the other rspec gems.
|
|
284
367
|
|
|
285
368
|
### 2.8.0.rc1 / 2011-11-06
|
|
286
369
|
|
|
287
|
-
[
|
|
370
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.7.0...v2.8.0.rc1)
|
|
288
371
|
|
|
289
372
|
Enhancements
|
|
290
373
|
|
|
@@ -293,7 +376,7 @@ Enhancements
|
|
|
293
376
|
|
|
294
377
|
### 2.7.0 / 2011-10-16
|
|
295
378
|
|
|
296
|
-
[
|
|
379
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.6.0...v2.7.0)
|
|
297
380
|
|
|
298
381
|
Enhancements
|
|
299
382
|
|
|
@@ -311,7 +394,7 @@ Bug fixes
|
|
|
311
394
|
|
|
312
395
|
### 2.6.0 / 2011-05-12
|
|
313
396
|
|
|
314
|
-
[
|
|
397
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.5.0...v2.6.0)
|
|
315
398
|
|
|
316
399
|
Enhancements
|
|
317
400
|
|
|
@@ -329,7 +412,7 @@ Bug fixes
|
|
|
329
412
|
|
|
330
413
|
### 2.5.0 / 2011-02-05
|
|
331
414
|
|
|
332
|
-
[
|
|
415
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.4.0...v2.5.0)
|
|
333
416
|
|
|
334
417
|
Enhancements
|
|
335
418
|
|
|
@@ -342,7 +425,7 @@ Documentation
|
|
|
342
425
|
|
|
343
426
|
### 2.4.0 / 2011-01-02
|
|
344
427
|
|
|
345
|
-
[
|
|
428
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.3.0...v2.4.0)
|
|
346
429
|
|
|
347
430
|
No functional changes in this release, which was made to align with the
|
|
348
431
|
rspec-core-2.4.0 release.
|
|
@@ -353,7 +436,7 @@ Enhancements
|
|
|
353
436
|
|
|
354
437
|
### 2.3.0 / 2010-12-12
|
|
355
438
|
|
|
356
|
-
[
|
|
439
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.2.1...v2.3.0)
|
|
357
440
|
|
|
358
441
|
Enhancements
|
|
359
442
|
|
|
@@ -361,11 +444,11 @@ Enhancements
|
|
|
361
444
|
|
|
362
445
|
### 2.2.0 / 2010-11-28
|
|
363
446
|
|
|
364
|
-
[
|
|
447
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.1.0...v2.2.0)
|
|
365
448
|
|
|
366
449
|
### 2.1.0 / 2010-11-07
|
|
367
450
|
|
|
368
|
-
[
|
|
451
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.1...v2.1.0)
|
|
369
452
|
|
|
370
453
|
Enhancements
|
|
371
454
|
|
|
@@ -384,7 +467,7 @@ Bug fixes
|
|
|
384
467
|
|
|
385
468
|
### 2.0.0 / 2010-10-10
|
|
386
469
|
|
|
387
|
-
[
|
|
470
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.rc...v2.0.0)
|
|
388
471
|
|
|
389
472
|
Enhancements
|
|
390
473
|
|
|
@@ -399,7 +482,7 @@ Bug fixes
|
|
|
399
482
|
|
|
400
483
|
### 2.0.0.rc / 2010-10-05
|
|
401
484
|
|
|
402
|
-
[
|
|
485
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.beta.22...v2.0.0.rc)
|
|
403
486
|
|
|
404
487
|
Enhancements
|
|
405
488
|
|
|
@@ -412,7 +495,7 @@ Bug fixes
|
|
|
412
495
|
|
|
413
496
|
### 2.0.0.beta.22 / 2010-09-12
|
|
414
497
|
|
|
415
|
-
[
|
|
498
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.beta.20...v2.0.0.beta.22)
|
|
416
499
|
|
|
417
500
|
Enhancements
|
|
418
501
|
|
data/features/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Note: You can also use `expect(..).to_not` instead of `expect(..).not_to`.
|
|
|
23
23
|
|
|
24
24
|
## What is a matcher?
|
|
25
25
|
|
|
26
|
-
A
|
|
26
|
+
A matcher is any object that responds to the following methods:
|
|
27
27
|
|
|
28
28
|
matches?(actual)
|
|
29
29
|
failure_message_for_should
|
|
@@ -33,6 +33,7 @@ These methods are also part of the matcher protocol, but are optional:
|
|
|
33
33
|
does_not_match?(actual)
|
|
34
34
|
failure_message_for_should_not
|
|
35
35
|
description
|
|
36
|
+
supports_block_expectations?
|
|
36
37
|
|
|
37
38
|
RSpec ships with a number of built-in matchers and a DSL for writing custom
|
|
38
39
|
matchers.
|
|
@@ -3,101 +3,101 @@ Feature: "be" matchers
|
|
|
3
3
|
There are several related "be" matchers:
|
|
4
4
|
|
|
5
5
|
```ruby
|
|
6
|
-
obj.should
|
|
7
|
-
obj.should
|
|
6
|
+
obj.should be_truthy # passes if obj is truthy (not nil or false)
|
|
7
|
+
obj.should be_falsey # passes if obj is falsy (nil or false)
|
|
8
8
|
obj.should be_nil # passes if obj is nil
|
|
9
9
|
obj.should be # passes if obj is truthy (not nil or false)
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Scenario:
|
|
13
|
-
Given a file named "
|
|
12
|
+
Scenario: be_truthy matcher
|
|
13
|
+
Given a file named "be_truthy_spec.rb" with:
|
|
14
14
|
"""ruby
|
|
15
|
-
describe "
|
|
16
|
-
specify { true.should
|
|
17
|
-
specify { 7.should
|
|
18
|
-
specify { "foo".should
|
|
19
|
-
specify { nil.should_not
|
|
20
|
-
specify { false.should_not
|
|
15
|
+
describe "be_truthy matcher" do
|
|
16
|
+
specify { true.should be_truthy }
|
|
17
|
+
specify { 7.should be_truthy }
|
|
18
|
+
specify { "foo".should be_truthy }
|
|
19
|
+
specify { nil.should_not be_truthy }
|
|
20
|
+
specify { false.should_not be_truthy }
|
|
21
21
|
|
|
22
22
|
# deliberate failures
|
|
23
|
-
specify { true.should_not
|
|
24
|
-
specify { 7.should_not
|
|
25
|
-
specify { "foo".should_not
|
|
26
|
-
specify { nil.should
|
|
27
|
-
specify { false.should
|
|
23
|
+
specify { true.should_not be_truthy }
|
|
24
|
+
specify { 7.should_not be_truthy }
|
|
25
|
+
specify { "foo".should_not be_truthy }
|
|
26
|
+
specify { nil.should be_truthy }
|
|
27
|
+
specify { false.should be_truthy }
|
|
28
28
|
end
|
|
29
29
|
"""
|
|
30
|
-
When I run `rspec
|
|
30
|
+
When I run `rspec be_truthy_spec.rb`
|
|
31
31
|
Then the output should contain "10 examples, 5 failures"
|
|
32
32
|
And the output should contain:
|
|
33
33
|
"""
|
|
34
|
-
expected:
|
|
34
|
+
expected: falsey value
|
|
35
35
|
got: true
|
|
36
36
|
"""
|
|
37
37
|
And the output should contain:
|
|
38
38
|
"""
|
|
39
|
-
expected:
|
|
39
|
+
expected: falsey value
|
|
40
40
|
got: 7
|
|
41
41
|
"""
|
|
42
42
|
And the output should contain:
|
|
43
43
|
"""
|
|
44
|
-
expected:
|
|
44
|
+
expected: falsey value
|
|
45
45
|
got: "foo"
|
|
46
46
|
"""
|
|
47
47
|
And the output should contain:
|
|
48
48
|
"""
|
|
49
|
-
expected:
|
|
49
|
+
expected: truthy value
|
|
50
50
|
got: nil
|
|
51
51
|
"""
|
|
52
52
|
And the output should contain:
|
|
53
53
|
"""
|
|
54
|
-
expected:
|
|
54
|
+
expected: truthy value
|
|
55
55
|
got: false
|
|
56
56
|
"""
|
|
57
57
|
|
|
58
|
-
Scenario:
|
|
59
|
-
Given a file named "
|
|
58
|
+
Scenario: be_falsey matcher
|
|
59
|
+
Given a file named "be_falsey_spec.rb" with:
|
|
60
60
|
"""ruby
|
|
61
|
-
describe "
|
|
62
|
-
specify { nil.should
|
|
63
|
-
specify { false.should
|
|
64
|
-
specify { true.should_not
|
|
65
|
-
specify { 7.should_not
|
|
66
|
-
specify { "foo".should_not
|
|
61
|
+
describe "be_falsey matcher" do
|
|
62
|
+
specify { nil.should be_falsey }
|
|
63
|
+
specify { false.should be_falsey }
|
|
64
|
+
specify { true.should_not be_falsey }
|
|
65
|
+
specify { 7.should_not be_falsey }
|
|
66
|
+
specify { "foo".should_not be_falsey }
|
|
67
67
|
|
|
68
68
|
# deliberate failures
|
|
69
|
-
specify { nil.should_not
|
|
70
|
-
specify { false.should_not
|
|
71
|
-
specify { true.should
|
|
72
|
-
specify { 7.should
|
|
73
|
-
specify { "foo".should
|
|
69
|
+
specify { nil.should_not be_falsey }
|
|
70
|
+
specify { false.should_not be_falsey }
|
|
71
|
+
specify { true.should be_falsey }
|
|
72
|
+
specify { 7.should be_falsey }
|
|
73
|
+
specify { "foo".should be_falsey }
|
|
74
74
|
end
|
|
75
75
|
"""
|
|
76
|
-
When I run `rspec
|
|
76
|
+
When I run `rspec be_falsey_spec.rb`
|
|
77
77
|
Then the output should contain "10 examples, 5 failures"
|
|
78
78
|
And the output should contain:
|
|
79
79
|
"""
|
|
80
|
-
expected:
|
|
80
|
+
expected: truthy value
|
|
81
81
|
got: nil
|
|
82
82
|
"""
|
|
83
83
|
And the output should contain:
|
|
84
84
|
"""
|
|
85
|
-
expected:
|
|
85
|
+
expected: truthy value
|
|
86
86
|
got: false
|
|
87
87
|
"""
|
|
88
88
|
And the output should contain:
|
|
89
89
|
"""
|
|
90
|
-
expected:
|
|
90
|
+
expected: falsey value
|
|
91
91
|
got: true
|
|
92
92
|
"""
|
|
93
93
|
And the output should contain:
|
|
94
94
|
"""
|
|
95
|
-
expected:
|
|
95
|
+
expected: falsey value
|
|
96
96
|
got: 7
|
|
97
97
|
"""
|
|
98
98
|
And the output should contain:
|
|
99
99
|
"""
|
|
100
|
-
expected:
|
|
100
|
+
expected: falsey value
|
|
101
101
|
got: "foo"
|
|
102
102
|
"""
|
|
103
103
|
|
|
@@ -20,3 +20,13 @@ Then /^the example should fail$/ do
|
|
|
20
20
|
step %q{the output should contain "1 failure"}
|
|
21
21
|
step %q{the exit status should not be 0}
|
|
22
22
|
end
|
|
23
|
+
|
|
24
|
+
deprecation_message = /rspec-expectations' built-in integration with (Test::Unit|minitest < 5.x) is deprecated/
|
|
25
|
+
|
|
26
|
+
Then /^the output should contain a deprecation warning about rspec\-expecations' built\-in integration$/ do
|
|
27
|
+
expect(all_output).to match(deprecation_message)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Then /^the output should not contain a deprecation warning about rspec\-expecations' built\-in integration$/ do
|
|
31
|
+
expect(all_output).not_to match(deprecation_message)
|
|
32
|
+
end
|
|
@@ -42,3 +42,43 @@ Feature: Test::Unit integration
|
|
|
42
42
|
Then the output should contain "3 tests, 0 assertions, 0 failures, 1 errors" or "3 tests, 0 assertions, 1 failures, 0 errors"
|
|
43
43
|
And the output should contain "expected empty? to return true, got false"
|
|
44
44
|
And the output should contain "be_an_int is deprecated"
|
|
45
|
+
And the output should contain a deprecation warning about rspec-expecations' built-in integration
|
|
46
|
+
|
|
47
|
+
Scenario: use rspec/expectations with Test::Unit
|
|
48
|
+
Given a file named "rspec_expectations_with_manual_integration_test.rb" with:
|
|
49
|
+
"""
|
|
50
|
+
require 'test/unit'
|
|
51
|
+
require "rspec/expectations"
|
|
52
|
+
|
|
53
|
+
class RSpecExpectationsTest < Test::Unit::TestCase
|
|
54
|
+
include ::RSpec::Matchers
|
|
55
|
+
|
|
56
|
+
RSpec::Matchers.define :be_an_integer do
|
|
57
|
+
match { |actual| Integer === actual }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def be_an_int
|
|
61
|
+
# This is actually an internal rspec-expectations API, but is used
|
|
62
|
+
# here to demonstrate that deprecation warnings from within
|
|
63
|
+
# rspec-expectations work correcty without depending on rspec-core
|
|
64
|
+
RSpec.deprecate(:be_an_int, :replacement => :be_an_integer)
|
|
65
|
+
be_an_integer
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_passing_expectation
|
|
69
|
+
expect(1 + 3).to eq 4
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def test_failing_expectation
|
|
73
|
+
expect([1,2]).to be_empty
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_custom_matcher_with_deprecation_warning
|
|
77
|
+
expect(1).to be_an_int
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
"""
|
|
81
|
+
When I run `ruby rspec_expectations_with_manual_integration_test.rb`
|
|
82
|
+
Then the output should contain "3 tests, 0 assertions, 0 failures, 1 errors" or "3 tests, 0 assertions, 1 failures, 0 errors"
|
|
83
|
+
And the output should not contain a deprecation warning about rspec-expecations' built-in integration
|
|
84
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module RSpec
|
|
2
|
+
# Consistent implementation for "cleaning" the caller method to strip out
|
|
3
|
+
# non-rspec lines. This enables errors to be reported at the call site in
|
|
4
|
+
# the code using the library, which is far more useful than the particular
|
|
5
|
+
# internal method that raised an error.
|
|
6
|
+
|
|
7
|
+
unless defined?(CallerFilter)
|
|
8
|
+
|
|
9
|
+
class CallerFilter
|
|
10
|
+
|
|
11
|
+
RSPEC_LIBS = %w[
|
|
12
|
+
core
|
|
13
|
+
mocks
|
|
14
|
+
expectations
|
|
15
|
+
matchers
|
|
16
|
+
rails
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
ADDITIONAL_TOP_LEVEL_FILES = %w[ autorun ]
|
|
20
|
+
|
|
21
|
+
LIB_REGEX = %r{/lib/rspec/(#{(RSPEC_LIBS + ADDITIONAL_TOP_LEVEL_FILES).join('|')})(\.rb|/)}
|
|
22
|
+
|
|
23
|
+
if RUBY_VERSION >= '2.0.0'
|
|
24
|
+
def self.first_non_rspec_line
|
|
25
|
+
# `caller` is an expensive method that scales linearly with the size of
|
|
26
|
+
# the stack. The performance hit for fetching it in chunks is small,
|
|
27
|
+
# and since the target line is probably near the top of the stack, the
|
|
28
|
+
# overall improvement of a chunked search like this is significant.
|
|
29
|
+
#
|
|
30
|
+
# See benchmarks/caller.rb for measurements.
|
|
31
|
+
|
|
32
|
+
# Initial value here is mostly arbitrary, but is chosen to give good
|
|
33
|
+
# performance on the common case of creating a double.
|
|
34
|
+
increment = 5
|
|
35
|
+
i = 1
|
|
36
|
+
line = nil
|
|
37
|
+
|
|
38
|
+
while !line
|
|
39
|
+
stack = caller(i, increment)
|
|
40
|
+
return nil unless stack
|
|
41
|
+
|
|
42
|
+
line = stack.find { |l| l !~ LIB_REGEX }
|
|
43
|
+
|
|
44
|
+
i += increment
|
|
45
|
+
increment *= 2 # The choice of two here is arbitrary.
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
line
|
|
49
|
+
end
|
|
50
|
+
else
|
|
51
|
+
# Earlier rubies do not support the two argument form of `caller`. This
|
|
52
|
+
# fallback is logically the same, but slower.
|
|
53
|
+
def self.first_non_rspec_line
|
|
54
|
+
caller.find { |line| line !~ LIB_REGEX }
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'rspec/expectations/syntax'
|
|
2
2
|
|
|
3
3
|
module RSpec
|
|
4
|
-
module
|
|
4
|
+
module Expectations
|
|
5
5
|
# Provides configuration options for rspec-expectations.
|
|
6
6
|
class Configuration
|
|
7
7
|
# Configures the supported syntax.
|
|
@@ -94,11 +94,13 @@ module RSpec
|
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
|
+
end
|
|
97
98
|
|
|
99
|
+
module Matchers
|
|
98
100
|
# The configuration object
|
|
99
|
-
# @return [RSpec::
|
|
101
|
+
# @return [RSpec::Expectations::Configuration] the configuration object
|
|
100
102
|
def self.configuration
|
|
101
|
-
@configuration ||= Configuration.new
|
|
103
|
+
@configuration ||= Expectations::Configuration.new
|
|
102
104
|
end
|
|
103
105
|
|
|
104
106
|
# set default syntax
|