rspec-expectations 2.13.0 → 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 -0
- data/Changelog.md +204 -23
- data/README.md +43 -87
- data/features/README.md +10 -10
- data/features/built_in_matchers/README.md +41 -41
- data/features/built_in_matchers/be.feature +40 -40
- data/features/built_in_matchers/be_within.feature +3 -3
- data/features/built_in_matchers/expect_change.feature +6 -6
- data/features/built_in_matchers/expect_error.feature +2 -2
- data/features/built_in_matchers/start_with.feature +1 -1
- data/features/built_in_matchers/throw_symbol.feature +11 -11
- data/features/built_in_matchers/yield.feature +18 -3
- data/features/custom_matchers/define_diffable_matcher.feature +1 -1
- data/features/custom_matchers/define_matcher_outside_rspec.feature +6 -6
- data/features/custom_matchers/define_matcher_with_fluent_interface.feature +1 -1
- data/features/customized_message.feature +1 -1
- data/features/diffing.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +10 -0
- data/features/support/env.rb +10 -1
- data/features/support/rubinius.rb +6 -0
- data/features/syntax_configuration.feature +3 -0
- data/features/test_frameworks/test_unit.feature +55 -17
- data/lib/rspec/expectations/caller_filter.rb +60 -0
- data/lib/rspec/{matchers → expectations}/configuration.rb +5 -3
- data/lib/rspec/expectations/deprecation.rb +20 -31
- data/lib/rspec/expectations/differ.rb +48 -9
- data/lib/rspec/expectations/expectation_target.rb +81 -15
- data/lib/rspec/expectations/extensions/object.rb +2 -12
- data/lib/rspec/expectations/fail_with.rb +11 -1
- data/lib/rspec/expectations/handler.rb +16 -7
- data/lib/rspec/expectations/syntax.rb +5 -7
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/expectations.rb +28 -2
- data/lib/rspec/matchers/be_close.rb +4 -1
- data/lib/rspec/matchers/built_in/base_matcher.rb +17 -10
- data/lib/rspec/matchers/built_in/be.rb +69 -32
- data/lib/rspec/matchers/built_in/be_within.rb +9 -3
- data/lib/rspec/matchers/built_in/change.rb +49 -3
- data/lib/rspec/matchers/built_in/has.rb +40 -7
- data/lib/rspec/matchers/built_in/have.rb +170 -5
- data/lib/rspec/matchers/built_in/include.rb +3 -11
- data/lib/rspec/matchers/built_in/match.rb +5 -0
- data/lib/rspec/matchers/built_in/match_array.rb +1 -1
- data/lib/rspec/matchers/built_in/raise_error.rb +34 -8
- 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 +102 -5
- 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 -66
- data/lib/rspec/matchers/pretty.rb +11 -1
- data/lib/rspec/matchers/test_unit_integration.rb +28 -0
- data/lib/rspec/matchers.rb +175 -146
- data/lib/rspec-expectations.rb +5 -0
- data/spec/rspec/{matchers → expectations}/configuration_spec.rb +78 -91
- data/spec/rspec/expectations/differ_spec.rb +65 -6
- data/spec/rspec/expectations/expectation_target_spec.rb +72 -3
- data/spec/rspec/expectations/extensions/kernel_spec.rb +9 -5
- data/spec/rspec/expectations/fail_with_spec.rb +19 -0
- data/spec/rspec/expectations/handler_spec.rb +43 -22
- data/spec/rspec/expectations/syntax_spec.rb +51 -9
- data/spec/rspec/expectations_spec.rb +71 -0
- data/spec/rspec/matchers/base_matcher_spec.rb +33 -18
- data/spec/rspec/matchers/be_close_spec.rb +9 -6
- data/spec/rspec/matchers/be_spec.rb +146 -45
- data/spec/rspec/matchers/be_within_spec.rb +8 -0
- data/spec/rspec/matchers/change_spec.rb +107 -7
- data/spec/rspec/matchers/description_generation_spec.rb +38 -20
- 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/equal_spec.rb +26 -0
- data/spec/rspec/matchers/exist_spec.rb +9 -9
- data/spec/rspec/matchers/has_spec.rb +25 -1
- data/spec/rspec/matchers/have_spec.rb +411 -3
- data/spec/rspec/matchers/include_matcher_integration_spec.rb +2 -2
- data/spec/rspec/matchers/include_spec.rb +4 -4
- data/spec/rspec/matchers/match_array_spec.rb +1 -1
- data/spec/rspec/matchers/match_spec.rb +14 -1
- data/spec/rspec/matchers/matcher_spec.rb +213 -24
- data/spec/rspec/matchers/operator_matcher_spec.rb +56 -8
- data/spec/rspec/matchers/pretty_spec.rb +23 -0
- data/spec/rspec/matchers/raise_error_spec.rb +242 -102
- data/spec/rspec/matchers/respond_to_spec.rb +4 -4
- data/spec/rspec/matchers/satisfy_spec.rb +1 -1
- data/spec/rspec/matchers/start_with_end_with_spec.rb +2 -2
- data/spec/rspec/matchers/throw_symbol_spec.rb +14 -14
- data/spec/rspec/matchers/yield_spec.rb +81 -4
- data/spec/spec_helper.rb +5 -3
- data/spec/support/helper_methods.rb +42 -0
- data/spec/support/shared_examples.rb +42 -0
- metadata +40 -44
- data/spec/rspec/matchers/matchers_spec.rb +0 -37
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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,5 +1,186 @@
|
|
|
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
|
+
|
|
83
|
+
### 2.14.5 / 2014-02-01
|
|
84
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.4...v2.14.5)
|
|
85
|
+
|
|
86
|
+
Bug fixes
|
|
87
|
+
|
|
88
|
+
* Fix wrong matcher descriptions with falsey expected value
|
|
89
|
+
(yujinakayama)
|
|
90
|
+
|
|
91
|
+
### 2.14.4 / 2013-11-06
|
|
92
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.3...v2.14.4)
|
|
93
|
+
|
|
94
|
+
Bug fixes
|
|
95
|
+
|
|
96
|
+
* Make the `match` matcher produce a diff output. (Jon Rowe, Ben Moss)
|
|
97
|
+
* Choose encoding for diff's more intelligently, and when all else fails fall
|
|
98
|
+
back to default internal encoding with replacing characters. (Jon Rowe)
|
|
99
|
+
|
|
100
|
+
### 2.14.3 / 2013-09-22
|
|
101
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.2...v2.14.3)
|
|
102
|
+
|
|
103
|
+
Bug fixes
|
|
104
|
+
|
|
105
|
+
* Fix operator matchers (`should` syntax) when `method` is redefined on target.
|
|
106
|
+
(Brandon Turner)
|
|
107
|
+
* Fix diffing of hashes with object based keys. (Jon Rowe)
|
|
108
|
+
* Fix operator matchers (`should` syntax) when operator is defined via
|
|
109
|
+
`method_missing` (Jon Rowe)
|
|
110
|
+
|
|
111
|
+
### 2.14.2 / 2013-08-14
|
|
112
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.1...v2.14.2)
|
|
113
|
+
|
|
114
|
+
Bug fixes
|
|
115
|
+
|
|
116
|
+
* Fix `be_<predicate>` matcher to not support operator chaining like the
|
|
117
|
+
`be` matcher does (e.g. `be == 5`). This led to some odd behaviors
|
|
118
|
+
since `be_<predicate> == anything` returned a `BeComparedTo` matcher
|
|
119
|
+
and was thus always truthy. This was a consequence of the implementation
|
|
120
|
+
(e.g. subclassing the basic `Be` matcher) and was not intended behavior.
|
|
121
|
+
(Myron Marston).
|
|
122
|
+
* Fix `change` matcher to compare using `==` in addition to `===`. This
|
|
123
|
+
is important for an expression like:
|
|
124
|
+
`expect {}.to change { a.class }.from(ClassA).to(ClassB)` because
|
|
125
|
+
`SomeClass === SomeClass` returns false. (Myron Marston)
|
|
126
|
+
|
|
127
|
+
### 2.14.1 / 2013-08-08
|
|
128
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.0...2.14.1)
|
|
129
|
+
|
|
130
|
+
Bug fixes
|
|
131
|
+
|
|
132
|
+
* Ensure diff output uses the same encoding as the encoding of
|
|
133
|
+
the string being diff'd to prevent `Encoding::UndefinedConversionError`
|
|
134
|
+
errors (Jon Rowe).
|
|
135
|
+
|
|
136
|
+
### 2.14.0 / 2013-07-06
|
|
137
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.0.rc1...v2.14.0)
|
|
138
|
+
|
|
139
|
+
Bug fixes
|
|
140
|
+
|
|
141
|
+
* Values that are not matchers use `#inspect`, rather than `#description` for
|
|
142
|
+
documentation output (Andy Lindeman, Sam Phippen).
|
|
143
|
+
* Make `expect(a).to be_within(x).percent_of(y)` work with negative y
|
|
144
|
+
(Katsuhiko Nishimra).
|
|
145
|
+
* Make the `be_predicate` matcher work as expected used with `expect{...}.to
|
|
146
|
+
change...` (Sam Phippen).
|
|
147
|
+
|
|
148
|
+
### 2.14.0.rc1 / 2013-05-27
|
|
149
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.13.0...v2.14.0.rc1)
|
|
150
|
+
|
|
151
|
+
Enhancements
|
|
152
|
+
|
|
153
|
+
* Enhance `yield_control` so that you can specify an exact or relative
|
|
154
|
+
number of times: `expect { }.to yield_control.exactly(3).times`,
|
|
155
|
+
`expect { }.to yield_control.at_least(2).times`, etc (Bartek
|
|
156
|
+
Borkowski).
|
|
157
|
+
* Make the differ that is used when an expectation fails better handle arrays
|
|
158
|
+
by splitting each element of the array onto its own line. (Sam Phippen)
|
|
159
|
+
* Accept duck-typed strings that respond to `:to_str` as expectation messages.
|
|
160
|
+
(Toby Ovod-Everett)
|
|
161
|
+
|
|
162
|
+
Bug fixes
|
|
163
|
+
|
|
164
|
+
* Fix differ to not raise errors when dealing with differently-encoded
|
|
165
|
+
strings (Jon Rowe).
|
|
166
|
+
* Fix `expect(something).to be_within(x).percent_of(y)` where x and y are both
|
|
167
|
+
integers (Sam Phippen).
|
|
168
|
+
* Fix `have` matcher to handle the fact that on ruby 2.0,
|
|
169
|
+
`Enumerator#size` may return nil (Kenta Murata).
|
|
170
|
+
* Fix `expect { raise s }.to raise_error(s)` where s is an error instance
|
|
171
|
+
on ruby 2.0 (Sam Phippen).
|
|
172
|
+
* Fix `expect(object).to raise_error` passing. This now warns the user and
|
|
173
|
+
fails the spec (tomykaira).
|
|
174
|
+
|
|
175
|
+
Deprecations
|
|
176
|
+
|
|
177
|
+
* Deprecate `expect { }.not_to raise_error(SpecificErrorClass)` or
|
|
178
|
+
`expect { }.not_to raise_error("some specific message")`. Using
|
|
179
|
+
these was prone to hiding failures as they would allow _any other
|
|
180
|
+
error_ to pass. (Sam Phippen and David Chelimsky)
|
|
181
|
+
|
|
1
182
|
### 2.13.0 / 2013-02-23
|
|
2
|
-
[
|
|
183
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.12.1...v2.13.0)
|
|
3
184
|
|
|
4
185
|
Enhancements
|
|
5
186
|
|
|
@@ -30,7 +211,7 @@ Bug fixes
|
|
|
30
211
|
printed for empty diffs (Myron Marston).
|
|
31
212
|
|
|
32
213
|
### 2.12.1 / 2012-12-15
|
|
33
|
-
[
|
|
214
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.12.0...v2.12.1)
|
|
34
215
|
|
|
35
216
|
Bug fixes
|
|
36
217
|
|
|
@@ -42,7 +223,7 @@ Bug fixes
|
|
|
42
223
|
(Steven Harman)
|
|
43
224
|
|
|
44
225
|
### 2.12.0 / 2012-11-12
|
|
45
|
-
[
|
|
226
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.3...v2.12.0)
|
|
46
227
|
|
|
47
228
|
Enhancements
|
|
48
229
|
|
|
@@ -65,7 +246,7 @@ Bug fixes
|
|
|
65
246
|
(Tom Stuart)
|
|
66
247
|
|
|
67
248
|
### 2.11.3 / 2012-09-04
|
|
68
|
-
[
|
|
249
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.2...v2.11.3)
|
|
69
250
|
|
|
70
251
|
Bug fixes
|
|
71
252
|
|
|
@@ -81,7 +262,7 @@ Bug fixes
|
|
|
81
262
|
}.to change { user.last_emailed_at }.to be_within(1.second).of(Time.zone.now)
|
|
82
263
|
|
|
83
264
|
### 2.11.2 / 2012-07-25
|
|
84
|
-
[
|
|
265
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.1...v2.11.2)
|
|
85
266
|
|
|
86
267
|
Bug fixes
|
|
87
268
|
|
|
@@ -90,7 +271,7 @@ Bug fixes
|
|
|
90
271
|
of the object hierarchy. (Gabriel Gilder)
|
|
91
272
|
|
|
92
273
|
### 2.11.1 / 2012-07-08
|
|
93
|
-
[
|
|
274
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.0...v2.11.1)
|
|
94
275
|
|
|
95
276
|
Bug fixes
|
|
96
277
|
|
|
@@ -99,7 +280,7 @@ Bug fixes
|
|
|
99
280
|
* `Time`, for example, is a legit alternative.
|
|
100
281
|
|
|
101
282
|
### 2.11.0 / 2012-07-07
|
|
102
|
-
[
|
|
283
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.10.0...v2.11.0)
|
|
103
284
|
|
|
104
285
|
Enhancements
|
|
105
286
|
|
|
@@ -122,7 +303,7 @@ Bug fixes
|
|
|
122
303
|
Marston)
|
|
123
304
|
|
|
124
305
|
### 2.10.0 / 2012-05-03
|
|
125
|
-
[
|
|
306
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.9.1...v2.10.0)
|
|
126
307
|
|
|
127
308
|
Enhancements
|
|
128
309
|
|
|
@@ -140,7 +321,7 @@ Bug fixes
|
|
|
140
321
|
* Fix message-specific specs to pass on Rubinius (John Firebaugh)
|
|
141
322
|
|
|
142
323
|
### 2.9.1 / 2012-04-03
|
|
143
|
-
[
|
|
324
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.9.0...v2.9.1)
|
|
144
325
|
|
|
145
326
|
Bug fixes
|
|
146
327
|
|
|
@@ -151,7 +332,7 @@ Bug fixes
|
|
|
151
332
|
* Fix using execution context methods in nested DSL matchers (mirasrael)
|
|
152
333
|
|
|
153
334
|
### 2.9.0 / 2012-03-17
|
|
154
|
-
[
|
|
335
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.8.0...v2.9.0)
|
|
155
336
|
|
|
156
337
|
Enhancements
|
|
157
338
|
|
|
@@ -171,7 +352,7 @@ Bug fixes
|
|
|
171
352
|
|
|
172
353
|
### 2.8.0 / 2012-01-04
|
|
173
354
|
|
|
174
|
-
[
|
|
355
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.8.0.rc2...v2.8.0)
|
|
175
356
|
|
|
176
357
|
Enhancements
|
|
177
358
|
|
|
@@ -180,13 +361,13 @@ Enhancements
|
|
|
180
361
|
|
|
181
362
|
### 2.8.0.rc2 / 2011-12-19
|
|
182
363
|
|
|
183
|
-
[
|
|
364
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.8.0.rc1...v2.8.0.rc2)
|
|
184
365
|
|
|
185
366
|
No changes for this release. Just releasing with the other rspec gems.
|
|
186
367
|
|
|
187
368
|
### 2.8.0.rc1 / 2011-11-06
|
|
188
369
|
|
|
189
|
-
[
|
|
370
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.7.0...v2.8.0.rc1)
|
|
190
371
|
|
|
191
372
|
Enhancements
|
|
192
373
|
|
|
@@ -195,7 +376,7 @@ Enhancements
|
|
|
195
376
|
|
|
196
377
|
### 2.7.0 / 2011-10-16
|
|
197
378
|
|
|
198
|
-
[
|
|
379
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.6.0...v2.7.0)
|
|
199
380
|
|
|
200
381
|
Enhancements
|
|
201
382
|
|
|
@@ -213,7 +394,7 @@ Bug fixes
|
|
|
213
394
|
|
|
214
395
|
### 2.6.0 / 2011-05-12
|
|
215
396
|
|
|
216
|
-
[
|
|
397
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.5.0...v2.6.0)
|
|
217
398
|
|
|
218
399
|
Enhancements
|
|
219
400
|
|
|
@@ -231,7 +412,7 @@ Bug fixes
|
|
|
231
412
|
|
|
232
413
|
### 2.5.0 / 2011-02-05
|
|
233
414
|
|
|
234
|
-
[
|
|
415
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.4.0...v2.5.0)
|
|
235
416
|
|
|
236
417
|
Enhancements
|
|
237
418
|
|
|
@@ -244,7 +425,7 @@ Documentation
|
|
|
244
425
|
|
|
245
426
|
### 2.4.0 / 2011-01-02
|
|
246
427
|
|
|
247
|
-
[
|
|
428
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.3.0...v2.4.0)
|
|
248
429
|
|
|
249
430
|
No functional changes in this release, which was made to align with the
|
|
250
431
|
rspec-core-2.4.0 release.
|
|
@@ -255,7 +436,7 @@ Enhancements
|
|
|
255
436
|
|
|
256
437
|
### 2.3.0 / 2010-12-12
|
|
257
438
|
|
|
258
|
-
[
|
|
439
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.2.1...v2.3.0)
|
|
259
440
|
|
|
260
441
|
Enhancements
|
|
261
442
|
|
|
@@ -263,11 +444,11 @@ Enhancements
|
|
|
263
444
|
|
|
264
445
|
### 2.2.0 / 2010-11-28
|
|
265
446
|
|
|
266
|
-
[
|
|
447
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.1.0...v2.2.0)
|
|
267
448
|
|
|
268
449
|
### 2.1.0 / 2010-11-07
|
|
269
450
|
|
|
270
|
-
[
|
|
451
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.1...v2.1.0)
|
|
271
452
|
|
|
272
453
|
Enhancements
|
|
273
454
|
|
|
@@ -286,7 +467,7 @@ Bug fixes
|
|
|
286
467
|
|
|
287
468
|
### 2.0.0 / 2010-10-10
|
|
288
469
|
|
|
289
|
-
[
|
|
470
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.rc...v2.0.0)
|
|
290
471
|
|
|
291
472
|
Enhancements
|
|
292
473
|
|
|
@@ -301,7 +482,7 @@ Bug fixes
|
|
|
301
482
|
|
|
302
483
|
### 2.0.0.rc / 2010-10-05
|
|
303
484
|
|
|
304
|
-
[
|
|
485
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.beta.22...v2.0.0.rc)
|
|
305
486
|
|
|
306
487
|
Enhancements
|
|
307
488
|
|
|
@@ -314,7 +495,7 @@ Bug fixes
|
|
|
314
495
|
|
|
315
496
|
### 2.0.0.beta.22 / 2010-09-12
|
|
316
497
|
|
|
317
|
-
[
|
|
498
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.beta.20...v2.0.0.beta.22)
|
|
318
499
|
|
|
319
500
|
Enhancements
|
|
320
501
|
|
data/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
RSpec::Expectations lets you express expected outcomes on an object in an
|
|
4
4
|
example.
|
|
5
5
|
|
|
6
|
-
account.balance.
|
|
6
|
+
expect(account.balance).to eq(Money.new(37.42, :USD))
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -38,8 +38,7 @@ describe Order do
|
|
|
38
38
|
end
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
The `describe` and `it` methods come from rspec-core. The `Order`, `LineItem`,
|
|
42
|
-
and `Item` classes would be from _your_ code. The last line of the example
|
|
41
|
+
The `describe` and `it` methods come from rspec-core. The `Order`, `LineItem`, `Item` and `Money` classes would be from _your_ code. The last line of the example
|
|
43
42
|
expresses an expected outcome. If `order.total == Money.new(5.55, :USD)`, then
|
|
44
43
|
the example passes. If not, it fails with a message like:
|
|
45
44
|
|
|
@@ -51,52 +50,50 @@ the example passes. If not, it fails with a message like:
|
|
|
51
50
|
### Equivalence
|
|
52
51
|
|
|
53
52
|
```ruby
|
|
54
|
-
actual.
|
|
55
|
-
actual.
|
|
56
|
-
actual.should eql(expected) # passes if actual.eql?(expected)
|
|
53
|
+
expect(actual).to eq(expected) # passes if actual == expected
|
|
54
|
+
expect(actual).to eql(expected) # passes if actual.eql?(expected)
|
|
57
55
|
```
|
|
58
56
|
|
|
59
|
-
Note:
|
|
60
|
-
useless context" warning when the `==` matcher is used anywhere but the
|
|
61
|
-
last statement of an example.
|
|
57
|
+
Note: The new `expect` syntax no longer supports `==` matcher.
|
|
62
58
|
|
|
63
59
|
### Identity
|
|
64
60
|
|
|
65
61
|
```ruby
|
|
66
|
-
actual.
|
|
67
|
-
actual.
|
|
62
|
+
expect(actual).to be(expected) # passes if actual.equal?(expected)
|
|
63
|
+
expect(actual).to equal(expected) # passes if actual.equal?(expected)
|
|
68
64
|
```
|
|
69
65
|
|
|
70
66
|
### Comparisons
|
|
71
67
|
|
|
72
68
|
```ruby
|
|
73
|
-
actual.
|
|
74
|
-
actual.
|
|
75
|
-
actual.
|
|
76
|
-
actual.
|
|
77
|
-
actual.
|
|
69
|
+
expect(actual).to be > expected
|
|
70
|
+
expect(actual).to be >= expected
|
|
71
|
+
expect(actual).to be <= expected
|
|
72
|
+
expect(actual).to be < expected
|
|
73
|
+
expect(actual).to be_within(delta).of(expected)
|
|
78
74
|
```
|
|
79
75
|
|
|
80
76
|
### Regular expressions
|
|
81
77
|
|
|
82
78
|
```ruby
|
|
83
|
-
actual.
|
|
84
|
-
actual.should =~ /expression/
|
|
79
|
+
expect(actual).to match(/expression/)
|
|
85
80
|
```
|
|
86
81
|
|
|
82
|
+
Note: The new `expect` syntax no longer supports `=~` matcher.
|
|
83
|
+
|
|
87
84
|
### Types/classes
|
|
88
85
|
|
|
89
86
|
```ruby
|
|
90
|
-
actual.
|
|
91
|
-
actual.
|
|
87
|
+
expect(actual).to be_an_instance_of(expected)
|
|
88
|
+
expect(actual).to be_a_kind_of(expected)
|
|
92
89
|
```
|
|
93
90
|
|
|
94
91
|
### Truthiness
|
|
95
92
|
|
|
96
93
|
```ruby
|
|
97
|
-
actual.
|
|
98
|
-
actual.
|
|
99
|
-
actual.
|
|
94
|
+
expect(actual).to be_true # passes if actual is truthy (not nil or false)
|
|
95
|
+
expect(actual).to be_false # passes if actual is falsy (nil or false)
|
|
96
|
+
expect(actual).to be_nil # passes if actual is nil
|
|
100
97
|
```
|
|
101
98
|
|
|
102
99
|
### Expecting errors
|
|
@@ -134,92 +131,51 @@ expect { |b| { :a => 1, :b => 2 }.each(&b) }.to yield_successive_args([:a, 1], [
|
|
|
134
131
|
### Predicate matchers
|
|
135
132
|
|
|
136
133
|
```ruby
|
|
137
|
-
actual.
|
|
138
|
-
actual.
|
|
134
|
+
expect(actual).to be_xxx # passes if actual.xxx?
|
|
135
|
+
expect(actual).to have_xxx(:arg) # passes if actual.has_xxx?(:arg)
|
|
139
136
|
```
|
|
140
137
|
|
|
141
138
|
### Ranges (Ruby >= 1.9 only)
|
|
142
139
|
|
|
143
140
|
```ruby
|
|
144
|
-
(1..10).
|
|
141
|
+
expect(1..10).to cover(3)
|
|
145
142
|
```
|
|
146
143
|
|
|
147
144
|
### Collection membership
|
|
148
145
|
|
|
149
146
|
```ruby
|
|
150
|
-
actual.
|
|
151
|
-
actual.
|
|
152
|
-
actual.
|
|
147
|
+
expect(actual).to include(expected)
|
|
148
|
+
expect(actual).to start_with(expected)
|
|
149
|
+
expect(actual).to end_with(expected)
|
|
153
150
|
```
|
|
154
151
|
|
|
155
152
|
#### Examples
|
|
156
153
|
|
|
157
154
|
```ruby
|
|
158
|
-
[1,2,3].
|
|
159
|
-
[1,2,3].
|
|
160
|
-
[1,2,3].
|
|
161
|
-
[1,2,3].
|
|
162
|
-
[1,2,3].
|
|
163
|
-
[1,2,3].
|
|
164
|
-
{:a => 'b'}.
|
|
165
|
-
"this string".
|
|
166
|
-
"this string".
|
|
167
|
-
"this string".
|
|
155
|
+
expect([1,2,3]).to include(1)
|
|
156
|
+
expect([1,2,3]).to include(1, 2)
|
|
157
|
+
expect([1,2,3]).to start_with(1)
|
|
158
|
+
expect([1,2,3]).to start_with(1,2)
|
|
159
|
+
expect([1,2,3]).to end_with(3)
|
|
160
|
+
expect([1,2,3]).to end_with(2,3)
|
|
161
|
+
expect({:a => 'b'}).to include(:a => 'b')
|
|
162
|
+
expect("this string").to include("is str")
|
|
163
|
+
expect("this string").to start_with("this")
|
|
164
|
+
expect("this string").to end_with("ring")
|
|
168
165
|
```
|
|
169
166
|
|
|
170
|
-
## `
|
|
171
|
-
|
|
172
|
-
In addition to the `should` syntax, rspec-expectations supports
|
|
173
|
-
a new `expect` syntax as of version 2.11.0:
|
|
174
|
-
|
|
175
|
-
```ruby
|
|
176
|
-
expect(actual).to eq expected
|
|
177
|
-
expect(actual).to be > 3
|
|
178
|
-
expect([1, 2, 3]).to_not include 4
|
|
179
|
-
```
|
|
167
|
+
## `should` syntax
|
|
180
168
|
|
|
181
|
-
|
|
182
|
-
|
|
169
|
+
In addition to the `expect` syntax, rspec-expectations continues to support the
|
|
170
|
+
`should` syntax:
|
|
183
171
|
|
|
184
172
|
```ruby
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
# or
|
|
189
|
-
c.syntax = :should
|
|
190
|
-
# or
|
|
191
|
-
c.syntax = [:should, :expect]
|
|
192
|
-
end
|
|
193
|
-
end
|
|
173
|
+
actual.should eq expected
|
|
174
|
+
actual.should be > 3
|
|
175
|
+
[1, 2, 3].should_not include 4
|
|
194
176
|
```
|
|
195
177
|
|
|
196
|
-
See
|
|
197
|
-
[RSpec::Expectations::Syntax#expect](http://rubydoc.info/gems/rspec-expectations/RSpec/Expectations/Syntax:expect)
|
|
198
|
-
for more information.
|
|
199
|
-
|
|
200
|
-
### Motivation for `expect`
|
|
201
|
-
|
|
202
|
-
We added the `expect` syntax to resolve some edge case issues, most notably
|
|
203
|
-
that objects whose definitions wipe out all but a few methods were throwing
|
|
204
|
-
`should` and `should_not` away. `expect` solves that by not monkey patching
|
|
205
|
-
those methods onto `Kernel` (or any global object).
|
|
206
|
-
|
|
207
|
-
See
|
|
208
|
-
[http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax](http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax)
|
|
209
|
-
for a detailed explanation.
|
|
210
|
-
|
|
211
|
-
### One-liners
|
|
212
|
-
|
|
213
|
-
The one-liner syntax supported by
|
|
214
|
-
[rspec-core](http://rubydoc.info/gems/rspec-core) uses `should` even when
|
|
215
|
-
`config.syntax = :expect`. It reads better than the alternative, and does not
|
|
216
|
-
require a global monkey patch:
|
|
217
|
-
|
|
218
|
-
```ruby
|
|
219
|
-
describe User do
|
|
220
|
-
it { should validate_presence_of :email }
|
|
221
|
-
end
|
|
222
|
-
```
|
|
178
|
+
See [detailed information on the `should` syntax and its usage.](https://github.com/rspec/rspec-expectations/blob/master/Should.md)
|
|
223
179
|
|
|
224
180
|
## Also see
|
|
225
181
|
|
data/features/README.md
CHANGED
|
@@ -2,7 +2,7 @@ rspec-expectations is used to define expected outcomes.
|
|
|
2
2
|
|
|
3
3
|
describe Account do
|
|
4
4
|
it "has a balance of zero when first created" do
|
|
5
|
-
Account.new.balance.
|
|
5
|
+
expect(Account.new.balance).to eq(Money.new(0))
|
|
6
6
|
end
|
|
7
7
|
end
|
|
8
8
|
|
|
@@ -10,21 +10,20 @@ rspec-expectations is used to define expected outcomes.
|
|
|
10
10
|
|
|
11
11
|
The basic structure of an rspec expectation is:
|
|
12
12
|
|
|
13
|
-
actual.
|
|
14
|
-
actual.
|
|
13
|
+
expect(actual).to matcher(expected)
|
|
14
|
+
expect(actual).not_to matcher(expected)
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Note: You can also use `expect(..).to_not` instead of `expect(..).not_to`.
|
|
17
|
+
One is an alias to the other, so you can use whichever reads better to you.
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
the system. These methods each accept a matcher as an argument. This allows
|
|
20
|
-
each matcher to work in a positive or negative mode:
|
|
19
|
+
#### Examples
|
|
21
20
|
|
|
22
|
-
5.
|
|
23
|
-
5.
|
|
21
|
+
expect(5).to eq(5)
|
|
22
|
+
expect(5).not_to eq(4)
|
|
24
23
|
|
|
25
24
|
## What is a matcher?
|
|
26
25
|
|
|
27
|
-
A
|
|
26
|
+
A matcher is any object that responds to the following methods:
|
|
28
27
|
|
|
29
28
|
matches?(actual)
|
|
30
29
|
failure_message_for_should
|
|
@@ -34,6 +33,7 @@ These methods are also part of the matcher protocol, but are optional:
|
|
|
34
33
|
does_not_match?(actual)
|
|
35
34
|
failure_message_for_should_not
|
|
36
35
|
description
|
|
36
|
+
supports_block_expectations?
|
|
37
37
|
|
|
38
38
|
RSpec ships with a number of built-in matchers and a DSL for writing custom
|
|
39
39
|
matchers.
|