rspec-expectations 2.11.1 → 2.11.2

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.
@@ -1,7 +1,16 @@
1
+ ### 2.11.2 / 2012-07-25
2
+ [full changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.1...v2.11.2)
3
+
4
+ Bug fixes
5
+
6
+ * Define `should` and `should_not` on `Object` rather than `BasicObject`
7
+ on MacRuby. On MacRuby, `BasicObject` is defined but is not the root
8
+ of the object hierarchy. (Gabriel Gilder)
9
+
1
10
  ### 2.11.1 / 2012-07-08
2
11
  [full changelog](http://github.com/rspec/rspec-expectations/compare/v2.11.0...v2.11.1)
3
12
 
4
- Bug fix
13
+ Bug fixes
5
14
 
6
15
  * Constrain `actual` in `be_within` matcher to values that respond to `-` instead
7
16
  of requiring a specific type.
data/README.md CHANGED
@@ -33,7 +33,7 @@ describe Order do
33
33
  :price => Money.new(2.22, :USD),
34
34
  :quantity => 2
35
35
  )))
36
- order.total.should eq(Money.new(5.55, :USD))
36
+ expect(order.total).to eq(Money.new(5.55, :USD))
37
37
  end
38
38
  end
39
39
  ```
@@ -163,23 +163,15 @@ actual.should end_with(expected)
163
163
  "this string".should end_with("ring")
164
164
  ```
165
165
 
166
- ## Syntax Options
166
+ ## `expect` syntax
167
167
 
168
168
  In addition to the `should` syntax, rspec-expectations supports
169
- an additional `expect` syntax:
169
+ a new `expect` syntax as of version 2.11.0:
170
170
 
171
171
  ```ruby
172
- # rather than:
173
- [1, 2, 3].should include(1)
174
-
175
- #...you can use:
176
- expect([1, 2, 3]).to include(1)
177
-
178
- # rather than:
179
- foo.should_not eq(bar)
180
-
181
- #...you can use:
182
- expect(foo).not_to eq(bar)
172
+ expect(actual).to eq expected
173
+ expect(actual).to be > 3
174
+ expect([1, 2, 3]).to_not include 4
183
175
  ```
184
176
 
185
177
  If you want your project to only use one of these syntaxes, you can
@@ -197,6 +189,34 @@ RSpec.configure do |config|
197
189
  end
198
190
  ```
199
191
 
192
+ See
193
+ [RSpec::Expectations::Syntax#expect](http://rubydoc.info/gems/rspec-expectations/RSpec/Expectations/Syntax:expect)
194
+ for more information.
195
+
196
+ ### Motivation for `expect`
197
+
198
+ We added the `expect` syntax to resolve some edge case issues, most notably
199
+ that objects whose definitions wipe out all but a few methods were throwing
200
+ `should` and `should_not` away. `expect` solves that by not monkey patching
201
+ those methods onto `Kernel` (or any global object).
202
+
203
+ See
204
+ [http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax](http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax)
205
+ for a detailed explanation.
206
+
207
+ ### One-liners
208
+
209
+ The one-liner syntax supported by
210
+ [rspec-core](http://rubydoc.info/gems/rspec-core) uses `should` even when
211
+ `config.syntax = :expect`. It reads better than the alternative, and does not
212
+ require a global monkey patch:
213
+
214
+ ```ruby
215
+ describe User do
216
+ it { should validate_presence_of :email }
217
+ end
218
+ ```
219
+
200
220
  ## Also see
201
221
 
202
222
  * [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
@@ -3,6 +3,12 @@ module RSpec
3
3
  # Wraps the target of an expectation.
4
4
  # @example
5
5
  # expect(something) # => ExpectationTarget wrapping something
6
+ #
7
+ # # used with `to`
8
+ # expect(actual).to eq(3)
9
+ #
10
+ # # with `to_not`
11
+ # expect(actual).to_not eq(3)
6
12
  class ExpectationTarget
7
13
  # @api private
8
14
  def initialize(target)
@@ -28,14 +28,19 @@ module RSpec
28
28
  # @see RSpec::Matchers
29
29
 
30
30
  # @method expect
31
- # Wraps `target` in an `ExpectationTarget`
31
+ # Supports `expect(actual).to matcher` syntax by wrapping `actual` in an
32
+ # `ExpectationTarget`.
33
+ # @example
34
+ # expect(actual).to eq(expected)
35
+ # expect(actual).to_not eq(expected)
32
36
  # @return [ExpectationTarget]
37
+ # @see ExpectationTarget#to
38
+ # @see ExpectationTarget#to_not
33
39
 
34
40
  # @api private
35
41
  # Determines where we add `should` and `should_not`.
36
42
  def default_should_host
37
- @default_should_host ||= defined?(::BasicObject) ?
38
- ::BasicObject : ::Kernel
43
+ @default_should_host ||= ::Object.ancestors.last
39
44
  end
40
45
 
41
46
  # @api private
@@ -2,7 +2,7 @@ module RSpec
2
2
  module Expectations
3
3
  # @private
4
4
  module Version
5
- STRING = '2.11.1'
5
+ STRING = '2.11.2'
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,87 +1,96 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
- version: !ruby/object:Gem::Version
4
- version: 2.11.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 39
5
5
  prerelease:
6
+ segments:
7
+ - 2
8
+ - 11
9
+ - 2
10
+ version: 2.11.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Steven Baker
9
14
  - David Chelimsky
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2012-07-08 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2012-07-26 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
16
22
  name: diff-lcs
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 1.1.3
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
- requirements:
27
+ requirements:
28
28
  - - ~>
29
- - !ruby/object:Gem::Version
29
+ - !ruby/object:Gem::Version
30
+ hash: 21
31
+ segments:
32
+ - 1
33
+ - 1
34
+ - 3
30
35
  version: 1.1.3
31
- - !ruby/object:Gem::Dependency
36
+ requirement: *id001
37
+ - !ruby/object:Gem::Dependency
32
38
  name: rake
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ~>
37
- - !ruby/object:Gem::Version
38
- version: 0.9.2
39
39
  type: :development
40
40
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
42
42
  none: false
43
- requirements:
43
+ requirements:
44
44
  - - ~>
45
- - !ruby/object:Gem::Version
45
+ - !ruby/object:Gem::Version
46
+ hash: 63
47
+ segments:
48
+ - 0
49
+ - 9
50
+ - 2
46
51
  version: 0.9.2
47
- - !ruby/object:Gem::Dependency
52
+ requirement: *id002
53
+ - !ruby/object:Gem::Dependency
48
54
  name: cucumber
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 1.1.9
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
57
+ version_requirements: &id003 !ruby/object:Gem::Requirement
58
58
  none: false
59
- requirements:
59
+ requirements:
60
60
  - - ~>
61
- - !ruby/object:Gem::Version
61
+ - !ruby/object:Gem::Version
62
+ hash: 1
63
+ segments:
64
+ - 1
65
+ - 1
66
+ - 9
62
67
  version: 1.1.9
63
- - !ruby/object:Gem::Dependency
68
+ requirement: *id003
69
+ - !ruby/object:Gem::Dependency
64
70
  name: aruba
65
- requirement: !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ~>
69
- - !ruby/object:Gem::Version
70
- version: 0.4.11
71
71
  type: :development
72
72
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
73
+ version_requirements: &id004 !ruby/object:Gem::Requirement
74
74
  none: false
75
- requirements:
75
+ requirements:
76
76
  - - ~>
77
- - !ruby/object:Gem::Version
77
+ - !ruby/object:Gem::Version
78
+ hash: 25
79
+ segments:
80
+ - 0
81
+ - 4
82
+ - 11
78
83
  version: 0.4.11
84
+ requirement: *id004
79
85
  description: rspec expectations (should[_not] and matchers)
80
86
  email: rspec-users@rubyforge.org
81
87
  executables: []
88
+
82
89
  extensions: []
90
+
83
91
  extra_rdoc_files: []
84
- files:
92
+
93
+ files:
85
94
  - lib/rspec-expectations.rb
86
95
  - lib/rspec/expectations.rb
87
96
  - lib/rspec/expectations/deprecation.rb
@@ -209,38 +218,39 @@ files:
209
218
  - spec/support/matchers.rb
210
219
  - spec/support/ruby_version.rb
211
220
  homepage: http://github.com/rspec/rspec-expectations
212
- licenses:
221
+ licenses:
213
222
  - MIT
214
223
  post_install_message:
215
- rdoc_options:
224
+ rdoc_options:
216
225
  - --charset=UTF-8
217
- require_paths:
226
+ require_paths:
218
227
  - lib
219
- required_ruby_version: !ruby/object:Gem::Requirement
228
+ required_ruby_version: !ruby/object:Gem::Requirement
220
229
  none: false
221
- requirements:
222
- - - ! '>='
223
- - !ruby/object:Gem::Version
224
- version: '0'
225
- segments:
230
+ requirements:
231
+ - - ">="
232
+ - !ruby/object:Gem::Version
233
+ hash: 3
234
+ segments:
226
235
  - 0
227
- hash: 4256634287402574449
228
- required_rubygems_version: !ruby/object:Gem::Requirement
236
+ version: "0"
237
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
238
  none: false
230
- requirements:
231
- - - ! '>='
232
- - !ruby/object:Gem::Version
233
- version: '0'
234
- segments:
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ hash: 3
243
+ segments:
235
244
  - 0
236
- hash: 4256634287402574449
245
+ version: "0"
237
246
  requirements: []
247
+
238
248
  rubyforge_project: rspec
239
- rubygems_version: 1.8.24
249
+ rubygems_version: 1.8.6
240
250
  signing_key:
241
251
  specification_version: 3
242
- summary: rspec-expectations-2.11.1
243
- test_files:
252
+ summary: rspec-expectations-2.11.2
253
+ test_files:
244
254
  - features/README.md
245
255
  - features/Upgrade.md
246
256
  - features/built_in_matchers/README.md