rspec-expectations 2.13.0 → 2.14.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/Changelog.md +34 -0
  2. data/README.md +43 -87
  3. data/features/README.md +8 -9
  4. data/features/built_in_matchers/README.md +41 -41
  5. data/features/built_in_matchers/be_within.feature +3 -3
  6. data/features/built_in_matchers/expect_change.feature +6 -6
  7. data/features/built_in_matchers/expect_error.feature +2 -2
  8. data/features/built_in_matchers/start_with.feature +1 -1
  9. data/features/built_in_matchers/throw_symbol.feature +11 -11
  10. data/features/built_in_matchers/yield.feature +18 -3
  11. data/features/custom_matchers/define_diffable_matcher.feature +1 -1
  12. data/features/custom_matchers/define_matcher_outside_rspec.feature +6 -6
  13. data/features/custom_matchers/define_matcher_with_fluent_interface.feature +1 -1
  14. data/features/customized_message.feature +1 -1
  15. data/features/support/env.rb +10 -1
  16. data/features/syntax_configuration.feature +3 -0
  17. data/features/test_frameworks/test_unit.feature +15 -17
  18. data/lib/rspec/expectations.rb +1 -1
  19. data/lib/rspec/expectations/deprecation.rb +12 -33
  20. data/lib/rspec/expectations/differ.rb +25 -7
  21. data/lib/rspec/expectations/expectation_target.rb +7 -8
  22. data/lib/rspec/expectations/extensions/object.rb +2 -12
  23. data/lib/rspec/expectations/fail_with.rb +11 -1
  24. data/lib/rspec/expectations/handler.rb +11 -6
  25. data/lib/rspec/expectations/syntax.rb +2 -2
  26. data/lib/rspec/expectations/version.rb +1 -1
  27. data/lib/rspec/matchers.rb +134 -144
  28. data/lib/rspec/matchers/be_close.rb +1 -1
  29. data/lib/rspec/matchers/built_in/be_within.rb +1 -1
  30. data/lib/rspec/matchers/built_in/have.rb +20 -4
  31. data/lib/rspec/matchers/built_in/raise_error.rb +23 -7
  32. data/lib/rspec/matchers/built_in/yield.rb +78 -3
  33. data/lib/rspec/matchers/operator_matcher.rb +1 -1
  34. data/lib/rspec/matchers/test_unit_integration.rb +11 -0
  35. data/spec/rspec/expectations/differ_spec.rb +27 -5
  36. data/spec/rspec/expectations/expectation_target_spec.rb +10 -3
  37. data/spec/rspec/expectations/extensions/kernel_spec.rb +5 -5
  38. data/spec/rspec/expectations/fail_with_spec.rb +19 -0
  39. data/spec/rspec/expectations/handler_spec.rb +42 -21
  40. data/spec/rspec/expectations/syntax_spec.rb +45 -3
  41. data/spec/rspec/matchers/be_close_spec.rb +6 -6
  42. data/spec/rspec/matchers/be_spec.rb +36 -36
  43. data/spec/rspec/matchers/be_within_spec.rb +4 -0
  44. data/spec/rspec/matchers/change_spec.rb +6 -6
  45. data/spec/rspec/matchers/configuration_spec.rb +57 -89
  46. data/spec/rspec/matchers/description_generation_spec.rb +1 -1
  47. data/spec/rspec/matchers/exist_spec.rb +9 -9
  48. data/spec/rspec/matchers/has_spec.rb +1 -1
  49. data/spec/rspec/matchers/have_spec.rb +12 -2
  50. data/spec/rspec/matchers/include_matcher_integration_spec.rb +2 -2
  51. data/spec/rspec/matchers/include_spec.rb +4 -4
  52. data/spec/rspec/matchers/match_array_spec.rb +1 -1
  53. data/spec/rspec/matchers/match_spec.rb +1 -1
  54. data/spec/rspec/matchers/raise_error_spec.rb +189 -99
  55. data/spec/rspec/matchers/respond_to_spec.rb +4 -4
  56. data/spec/rspec/matchers/satisfy_spec.rb +1 -1
  57. data/spec/rspec/matchers/start_with_end_with_spec.rb +2 -2
  58. data/spec/rspec/matchers/yield_spec.rb +81 -4
  59. data/spec/spec_helper.rb +1 -1
  60. metadata +10 -12
@@ -148,7 +148,7 @@ describe "expect(...).to respond_to(:sym).with(2).arguments" do
148
148
  end
149
149
  end
150
150
 
151
- describe "expect(...).to_not respond_to(:sym)" do
151
+ describe "expect(...).not_to respond_to(:sym)" do
152
152
  it "passes if target does not respond to :sym" do
153
153
  expect(Object.new).not_to respond_to(:some_method)
154
154
  end
@@ -160,7 +160,7 @@ describe "expect(...).to_not respond_to(:sym)" do
160
160
  end
161
161
  end
162
162
 
163
- describe "expect(...).to_not respond_to(:sym).with(1).argument" do
163
+ describe "expect(...).not_to respond_to(:sym).with(1).argument" do
164
164
  it "fails if target responds to :sym with 1 arg" do
165
165
  obj = Object.new
166
166
  def obj.foo(arg); end
@@ -209,7 +209,7 @@ describe "expect(...).to_not respond_to(:sym).with(1).argument" do
209
209
  end
210
210
  end
211
211
 
212
- describe "expect(...).to_not respond_to(message1, message2)" do
212
+ describe "expect(...).not_to respond_to(message1, message2)" do
213
213
  it "passes if target does not respond to either message1 or message2" do
214
214
  expect(Object.new).not_to respond_to(:some_method, :some_other_method)
215
215
  end
@@ -233,7 +233,7 @@ describe "expect(...).to_not respond_to(message1, message2)" do
233
233
  end
234
234
  end
235
235
 
236
- describe "expect(...).to_not respond_to(:sym).with(2).arguments" do
236
+ describe "expect(...).not_to respond_to(:sym).with(2).arguments" do
237
237
  it "fails if target responds to :sym with 2 args" do
238
238
  obj = Object.new
239
239
  def obj.foo(a1, a2); end
@@ -28,7 +28,7 @@ describe "expect(...).to satisfy { block }" do
28
28
  end
29
29
  end
30
30
 
31
- describe "expect(...).to_not satisfy { block }" do
31
+ describe "expect(...).not_to satisfy { block }" do
32
32
  it "passes if block returns false" do
33
33
  expect(false).not_to satisfy { |val| val }
34
34
  expect(false).not_to satisfy do |val|
@@ -56,7 +56,7 @@ describe "expect(...).to start_with" do
56
56
  end
57
57
  end
58
58
 
59
- describe "expect(...).to_not start_with" do
59
+ describe "expect(...).not_to start_with" do
60
60
  context "with a string" do
61
61
  it "passes if it does not match the start of the actual string" do
62
62
  expect("this string").not_to start_with "that str"
@@ -149,7 +149,7 @@ describe "expect(...).to end_with" do
149
149
 
150
150
  end
151
151
 
152
- describe "expect(...).to_not end_with" do
152
+ describe "expect(...).not_to end_with" do
153
153
  context "with a sting" do
154
154
  it "passes if it does not match the end of the actual string" do
155
155
  expect("this string").not_to end_with "stringy"
@@ -63,10 +63,87 @@ describe "yield_control matcher" do
63
63
  }.to fail_with(/expected given block to yield control/)
64
64
  end
65
65
 
66
- it 'raises an error if it yields multiple times' do
67
- expect {
68
- expect { |b| [1, 2].each(&b) }.to yield_control
69
- }.to raise_error(/not designed.*yields multiple times/)
66
+ context "with exact count" do
67
+ it 'fails if the block yields wrong number of times' do
68
+ expect {
69
+ expect { |b| [1, 2, 3].each(&b) }.to yield_control.twice
70
+ }.to fail_with(/expected given block to yield control twice/)
71
+
72
+ expect {
73
+ expect { |b| [1, 2].each(&b) }.to yield_control.exactly(3).times
74
+ }.to fail_with(/expected given block to yield control 3 times/)
75
+ end
76
+
77
+ it 'passes if the block yields the specified number of times' do
78
+ expect { |b| [1].each(&b) }.to yield_control.once
79
+ expect { |b| [1, 2].each(&b) }.to yield_control.twice
80
+ expect { |b| [1, 2, 3].each(&b) }.to yield_control.exactly(3).times
81
+ end
82
+ end
83
+
84
+ context "with at_least count" do
85
+ it 'passes if the block yields the given number of times' do
86
+ expect { |b| [1, 2].each(&b) }.to yield_control.at_least(2).times
87
+ expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_least(3).times
88
+ end
89
+
90
+ it 'passes if the block yields more times' do
91
+ expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_least(2).times
92
+ expect { |b| [1, 2, 3, 4].each(&b) }.to yield_control.at_least(3).times
93
+ end
94
+
95
+ it 'allows :once and :twice to be passed as counts' do
96
+ expect { |b| [1].each(&b) }.to yield_control.at_least(:once)
97
+ expect { |b| [1, 2].each(&b) }.to yield_control.at_least(:once)
98
+
99
+ expect {
100
+ expect { |b| [].each(&b) }.to yield_control.at_least(:once)
101
+ }.to fail_with(/at least once/)
102
+
103
+ expect { |b| [1, 2].each(&b) }.to yield_control.at_least(:twice)
104
+ expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_least(:twice)
105
+
106
+ expect {
107
+ expect { |b| [1].each(&b) }.to yield_control.at_least(:twice)
108
+ }.to fail_with(/at least twice/)
109
+ end
110
+
111
+ it 'fails if the block yields too few times' do
112
+ expect {
113
+ expect { |b| _yield_with_no_args(&b) }.to yield_control.at_least(2).times
114
+ }.to fail_with(/expected given block to yield control at least twice/)
115
+ end
116
+ end
117
+
118
+ context "with at_most count" do
119
+ it 'passes if the block yields the given number of times' do
120
+ expect { |b| [1, 2].each(&b) }.to yield_control.at_most(2).times
121
+ expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_most(3).times
122
+ end
123
+
124
+ it 'passes if the block yields fewer times' do
125
+ expect { |b| [1, 2].each(&b) }.to yield_control.at_most(3).times
126
+ end
127
+
128
+ it 'allows :once and :twice to be passed as counts' do
129
+ expect { |b| [1].each(&b) }.to yield_control.at_most(:once)
130
+
131
+ expect {
132
+ expect { |b| [1, 2].each(&b) }.to yield_control.at_most(:once)
133
+ }.to fail_with(/expected given block to yield control at most once/)
134
+
135
+ expect { |b| [1, 2].each(&b) }.to yield_control.at_most(:twice)
136
+
137
+ expect {
138
+ expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_most(:twice)
139
+ }.to fail_with(/expected given block to yield control at most twice/)
140
+ end
141
+
142
+ it 'fails if the block yields too many times' do
143
+ expect {
144
+ expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_most(2).times
145
+ }.to fail_with(/expected given block to yield control at most twice/)
146
+ end
70
147
  end
71
148
  end
72
149
 
@@ -46,7 +46,7 @@ module TestUnitIntegrationSupport
46
46
  def with_test_unit_loaded
47
47
  in_sub_process do
48
48
  require 'test/unit'
49
- load 'rspec/matchers.rb'
49
+ load 'rspec/matchers/test_unit_integration.rb'
50
50
  yield
51
51
  end
52
52
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 2.13.0
4
+ prerelease: 7
5
+ version: 2.14.0.rc1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Steven Baker
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-23 00:00:00.000000000 Z
13
+ date: 2013-05-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  version_requirements: !ruby/object:Gem::Requirement
@@ -71,7 +71,7 @@ dependencies:
71
71
  requirements:
72
72
  - - ~>
73
73
  - !ruby/object:Gem::Version
74
- version: 0.4.11
74
+ version: '0.5'
75
75
  none: false
76
76
  prerelease: false
77
77
  name: aruba
@@ -79,7 +79,7 @@ dependencies:
79
79
  requirements:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: 0.4.11
82
+ version: '0.5'
83
83
  none: false
84
84
  type: :development
85
85
  description: rspec expectations (should[_not] and matchers)
@@ -135,6 +135,7 @@ files:
135
135
  - lib/rspec/matchers/method_missing.rb
136
136
  - lib/rspec/matchers/operator_matcher.rb
137
137
  - lib/rspec/matchers/pretty.rb
138
+ - lib/rspec/matchers/test_unit_integration.rb
138
139
  - README.md
139
140
  - License.txt
140
141
  - Changelog.md
@@ -232,23 +233,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
233
  version: '0'
233
234
  segments:
234
235
  - 0
235
- hash: 3249637945894736858
236
+ hash: -3852254251876092451
236
237
  none: false
237
238
  required_rubygems_version: !ruby/object:Gem::Requirement
238
239
  requirements:
239
- - - ! '>='
240
+ - - ! '>'
240
241
  - !ruby/object:Gem::Version
241
- version: '0'
242
- segments:
243
- - 0
244
- hash: 3249637945894736858
242
+ version: 1.3.1
245
243
  none: false
246
244
  requirements: []
247
245
  rubyforge_project: rspec
248
246
  rubygems_version: 1.8.24
249
247
  signing_key:
250
248
  specification_version: 3
251
- summary: rspec-expectations-2.13.0
249
+ summary: rspec-expectations-2.14.0.rc1
252
250
  test_files:
253
251
  - features/README.md
254
252
  - features/Upgrade.md