rspec-expectations 2.0.0.rc → 2.0.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.
@@ -29,6 +29,43 @@ module RSpec
29
29
  end
30
30
  end
31
31
 
32
+ context "with separate match logic for should and should not" do
33
+ let(:matcher) do
34
+ RSpec::Matchers::Matcher.new(:to_be_composed_of, 7, 11) do |a, b|
35
+ match_for_should do |actual|
36
+ actual == a * b
37
+ end
38
+
39
+ match_for_should_not do |actual|
40
+ actual == a + b
41
+ end
42
+ end
43
+ end
44
+
45
+ it "invokes the match_for_should block for #matches?" do
46
+ matcher.matches?(77).should be_true
47
+ matcher.matches?(18).should be_false
48
+ end
49
+
50
+ it "invokes the match_for_should_not block for #does_not_match?" do
51
+ matcher.does_not_match?(77).should be_false
52
+ matcher.does_not_match?(18).should be_true
53
+ end
54
+
55
+ it "provides a default failure message for #should_not" do
56
+ matcher.does_not_match?(77)
57
+ matcher.failure_message_for_should_not.should == "expected 77 not to to be composed of 7 and 11"
58
+ end
59
+ end
60
+
61
+ it "allows helper methods to be defined with #define_method to have access to matcher parameters" do
62
+ matcher = RSpec::Matchers::Matcher.new(:name, 3, 4) do |a, b|
63
+ define_method(:sum) { a + b }
64
+ end
65
+
66
+ matcher.sum.should == 7
67
+ end
68
+
32
69
  it "is not diffable by default" do
33
70
  matcher = RSpec::Matchers::Matcher.new(:name) {}
34
71
  matcher.should_not be_diffable
@@ -20,6 +20,18 @@ describe "should respond_to(:sym).with(1).argument" do
20
20
  def obj.foo(arg); end
21
21
  obj.should respond_to(:foo).with(1).argument
22
22
  end
23
+
24
+ it "passes if target responds to any number of arguments" do
25
+ obj = Object.new
26
+ def obj.foo(*args); end
27
+ obj.should respond_to(:foo).with(1).argument
28
+ end
29
+
30
+ it "passes if target responds to one or more arguments" do
31
+ obj = Object.new
32
+ def obj.foo(a, *args); end
33
+ obj.should respond_to(:foo).with(1).argument
34
+ end
23
35
 
24
36
  it "fails if target does not respond to :sym" do
25
37
  obj = Object.new
@@ -43,6 +55,14 @@ describe "should respond_to(:sym).with(1).argument" do
43
55
  obj.should respond_to(:foo).with(1).argument
44
56
  }.should fail_with(/expected #<Object.*> to respond to :foo with 1 argument/)
45
57
  end
58
+
59
+ it "fails if :sym expects 2 or more args" do
60
+ obj = Object.new
61
+ def obj.foo(arg, arg2, *args); end
62
+ lambda {
63
+ obj.should respond_to(:foo).with(1).argument
64
+ }.should fail_with(/expected #<Object.*> to respond to :foo with 1 argument/)
65
+ end
46
66
  end
47
67
 
48
68
  describe "should respond_to(message1, message2)" do
@@ -76,6 +96,24 @@ describe "should respond_to(:sym).with(2).arguments" do
76
96
  def obj.foo(a1, a2); end
77
97
  obj.should respond_to(:foo).with(2).arguments
78
98
  end
99
+
100
+ it "passes if target responds to any number of arguments" do
101
+ obj = Object.new
102
+ def obj.foo(*args); end
103
+ obj.should respond_to(:foo).with(2).arguments
104
+ end
105
+
106
+ it "passes if target responds to one or more arguments" do
107
+ obj = Object.new
108
+ def obj.foo(a, *args); end
109
+ obj.should respond_to(:foo).with(2).arguments
110
+ end
111
+
112
+ it "passes if target responds to two or more arguments" do
113
+ obj = Object.new
114
+ def obj.foo(a, b, *args); end
115
+ obj.should respond_to(:foo).with(2).arguments
116
+ end
79
117
 
80
118
  it "fails if target does not respond to :sym" do
81
119
  obj = Object.new
@@ -92,13 +130,21 @@ describe "should respond_to(:sym).with(2).arguments" do
92
130
  }.should fail_with(/expected #<Object.*> to respond to :foo with 2 arguments/)
93
131
  end
94
132
 
95
- it "fails if :sym expects 2 args" do
133
+ it "fails if :sym expects 1 args" do
96
134
  obj = Object.new
97
135
  def obj.foo(arg); end
98
136
  lambda {
99
137
  obj.should respond_to(:foo).with(2).arguments
100
138
  }.should fail_with(/expected #<Object.*> to respond to :foo with 2 arguments/)
101
139
  end
140
+
141
+ it "fails if :sym expects 3 or more args" do
142
+ obj = Object.new
143
+ def obj.foo(arg, arg2, arg3, *args); end
144
+ lambda {
145
+ obj.should respond_to(:foo).with(2).arguments
146
+ }.should fail_with(/expected #<Object.*> to respond to :foo with 2 arguments/)
147
+ end
102
148
  end
103
149
 
104
150
  describe "should_not respond_to(:sym)" do
@@ -114,3 +160,133 @@ describe "should_not respond_to(:sym)" do
114
160
  end
115
161
 
116
162
  end
163
+
164
+ describe "should_not respond_to(:sym).with(1).argument" do
165
+ it "fails if target responds to :sym with 1 arg" do
166
+ obj = Object.new
167
+ def obj.foo(arg); end
168
+ lambda {
169
+ obj.should_not respond_to(:foo).with(1).argument
170
+ }.should fail_with(/expected #<Object:.*> not to respond to :foo with 1 argument/)
171
+ end
172
+
173
+ it "fails if target responds to :sym with any number of args" do
174
+ obj = Object.new
175
+ def obj.foo(*args); end
176
+ lambda {
177
+ obj.should_not respond_to(:foo).with(1).argument
178
+ }.should fail_with(/expected #<Object:.*> not to respond to :foo with 1 argument/)
179
+ end
180
+
181
+ it "fails if target responds to :sym with one or more args" do
182
+ obj = Object.new
183
+ def obj.foo(a, *args); end
184
+ lambda {
185
+ obj.should_not respond_to(:foo).with(1).argument
186
+ }.should fail_with(/expected #<Object:.*> not to respond to :foo with 1 argument/)
187
+ end
188
+
189
+ it "passes if target does not respond to :sym" do
190
+ obj = Object.new
191
+ obj.should_not respond_to(:some_method).with(1).argument
192
+ end
193
+
194
+ it "passes if :sym expects 0 args" do
195
+ obj = Object.new
196
+ def obj.foo; end
197
+ obj.should_not respond_to(:foo).with(1).argument
198
+ end
199
+
200
+ it "passes if :sym expects 2 args" do
201
+ obj = Object.new
202
+ def obj.foo(arg, arg2); end
203
+ obj.should_not respond_to(:foo).with(1).argument
204
+ end
205
+
206
+ it "passes if :sym expects 2 or more args" do
207
+ obj = Object.new
208
+ def obj.foo(arg, arg2, *args); end
209
+ obj.should_not respond_to(:foo).with(1).argument
210
+ end
211
+ end
212
+
213
+ describe "should_not respond_to(message1, message2)" do
214
+ it "passes if target does not respond to either message1 or message2" do
215
+ Object.new.should_not respond_to(:some_method, :some_other_method)
216
+ end
217
+
218
+ it "fails if target responds to message1 but not message2" do
219
+ lambda {
220
+ Object.new.should_not respond_to(:object_id, :some_method)
221
+ }.should fail_with(/expected #<Object:.*> not to respond to :object_id/)
222
+ end
223
+
224
+ it "fails if target responds to message2 but not message1" do
225
+ lambda {
226
+ Object.new.should_not respond_to(:some_method, :object_id)
227
+ }.should fail_with(/expected #<Object:.*> not to respond to :object_id/)
228
+ end
229
+
230
+ it "fails if target responds to both message1 and message2" do
231
+ lambda {
232
+ Object.new.should_not respond_to(:class, :object_id)
233
+ }.should fail_with(/expected #<Object:.*> not to respond to :class, :object_id/)
234
+ end
235
+ end
236
+
237
+ describe "should_not respond_to(:sym).with(2).arguments" do
238
+ it "fails if target responds to :sym with 2 args" do
239
+ obj = Object.new
240
+ def obj.foo(a1, a2); end
241
+ lambda {
242
+ obj.should_not respond_to(:foo).with(2).arguments
243
+ }.should fail_with(/expected .* not to respond to :foo with 2 arguments/)
244
+ end
245
+
246
+ it "fails if target responds to :sym with any number args" do
247
+ obj = Object.new
248
+ def obj.foo(*args); end
249
+ lambda {
250
+ obj.should_not respond_to(:foo).with(2).arguments
251
+ }.should fail_with(/expected .* not to respond to :foo with 2 arguments/)
252
+ end
253
+
254
+ it "fails if target responds to :sym with one or more args" do
255
+ obj = Object.new
256
+ def obj.foo(a, *args); end
257
+ lambda {
258
+ obj.should_not respond_to(:foo).with(2).arguments
259
+ }.should fail_with(/expected .* not to respond to :foo with 2 arguments/)
260
+ end
261
+
262
+ it "fails if target responds to :sym with two or more args" do
263
+ obj = Object.new
264
+ def obj.foo(a, b, *args); end
265
+ lambda {
266
+ obj.should_not respond_to(:foo).with(2).arguments
267
+ }.should fail_with(/expected .* not to respond to :foo with 2 arguments/)
268
+ end
269
+
270
+ it "passes if target does not respond to :sym" do
271
+ obj = Object.new
272
+ obj.should_not respond_to(:some_method).with(2).arguments
273
+ end
274
+
275
+ it "passes if :sym expects 0 args" do
276
+ obj = Object.new
277
+ def obj.foo; end
278
+ obj.should_not respond_to(:foo).with(2).arguments
279
+ end
280
+
281
+ it "passes if :sym expects 2 args" do
282
+ obj = Object.new
283
+ def obj.foo(arg); end
284
+ obj.should_not respond_to(:foo).with(2).arguments
285
+ end
286
+
287
+ it "passes if :sym expects 3 or more args" do
288
+ obj = Object.new
289
+ def obj.foo(a, b, c, *arg); end
290
+ obj.should_not respond_to(:foo).with(2).arguments
291
+ end
292
+ end
@@ -48,4 +48,6 @@ RSpec::configure do |config|
48
48
  config.mock_with(:rspec)
49
49
  config.include RSpec::Mocks::Methods
50
50
  config.color_enabled = true
51
+ config.filter_run :focused => true
52
+ config.run_all_when_everything_filtered = true
51
53
  end
metadata CHANGED
@@ -1,14 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7712058
5
- prerelease: true
4
+ prerelease: false
6
5
  segments:
7
6
  - 2
8
7
  - 0
9
8
  - 0
10
- - rc
11
- version: 2.0.0.rc
9
+ version: 2.0.0
12
10
  platform: ruby
13
11
  authors:
14
12
  - David Chelimsky
@@ -17,91 +15,84 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2010-10-04 00:00:00 -05:00
18
+ date: 2010-10-10 00:00:00 -05:00
21
19
  default_executable:
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ name: diff-lcs
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 23
30
28
  segments:
31
29
  - 1
32
30
  - 1
33
31
  - 2
34
32
  version: 1.1.2
35
- requirement: *id001
36
33
  type: :runtime
37
- name: diff-lcs
38
34
  prerelease: false
35
+ version_requirements: *id001
39
36
  - !ruby/object:Gem::Dependency
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ name: cucumber
38
+ requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
43
41
  - - ">="
44
42
  - !ruby/object:Gem::Version
45
- hash: 3
46
43
  segments:
47
44
  - 0
48
45
  - 6
49
46
  - 2
50
47
  version: 0.6.2
51
- requirement: *id002
52
48
  type: :development
53
- name: cucumber
54
49
  prerelease: false
50
+ version_requirements: *id002
55
51
  - !ruby/object:Gem::Dependency
56
- version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ name: aruba
53
+ requirement: &id003 !ruby/object:Gem::Requirement
57
54
  none: false
58
55
  requirements:
59
56
  - - ">="
60
57
  - !ruby/object:Gem::Version
61
- hash: 25
62
58
  segments:
63
59
  - 0
64
60
  - 1
65
61
  - 1
66
62
  version: 0.1.1
67
- requirement: *id003
68
63
  type: :development
69
- name: aruba
70
64
  prerelease: false
65
+ version_requirements: *id003
71
66
  - !ruby/object:Gem::Dependency
72
- version_requirements: &id004 !ruby/object:Gem::Requirement
67
+ name: rspec-core
68
+ requirement: &id004 !ruby/object:Gem::Requirement
73
69
  none: false
74
70
  requirements:
75
71
  - - ">="
76
72
  - !ruby/object:Gem::Version
77
- hash: 7712058
78
73
  segments:
79
74
  - 2
80
75
  - 0
81
76
  - 0
82
- - rc
83
- version: 2.0.0.rc
84
- requirement: *id004
77
+ version: 2.0.0
85
78
  type: :development
86
- name: rspec-core
87
79
  prerelease: false
80
+ version_requirements: *id004
88
81
  - !ruby/object:Gem::Dependency
89
- version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ name: rspec-mocks
83
+ requirement: &id005 !ruby/object:Gem::Requirement
90
84
  none: false
91
85
  requirements:
92
86
  - - ">="
93
87
  - !ruby/object:Gem::Version
94
- hash: 7712058
95
88
  segments:
96
89
  - 2
97
90
  - 0
98
91
  - 0
99
- - rc
100
- version: 2.0.0.rc
101
- requirement: *id005
92
+ version: 2.0.0
102
93
  type: :development
103
- name: rspec-mocks
104
94
  prerelease: false
95
+ version_requirements: *id005
105
96
  description: rspec expectations (should[_not] and matchers)
106
97
  email: dchelimsky@gmail.com;chad.humphries@gmail.com
107
98
  executables: []
@@ -134,8 +125,10 @@ files:
134
125
  - features/matchers/expect_change.feature
135
126
  - features/matchers/expect_error.feature
136
127
  - features/matchers/have.feature
128
+ - features/matchers/include.feature
137
129
  - features/matchers/operators.feature
138
130
  - features/matchers/predicates.feature
131
+ - features/matchers/respond_to.feature
139
132
  - features/step_definitions/additional_cli_steps.rb
140
133
  - features/support/env.rb
141
134
  - features/test_frameworks/test_unit.feature
@@ -226,28 +219,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
226
219
  requirements:
227
220
  - - ">="
228
221
  - !ruby/object:Gem::Version
229
- hash: 3
222
+ hash: -4161069882601304184
230
223
  segments:
231
224
  - 0
232
225
  version: "0"
233
226
  required_rubygems_version: !ruby/object:Gem::Requirement
234
227
  none: false
235
228
  requirements:
236
- - - ">"
229
+ - - ">="
237
230
  - !ruby/object:Gem::Version
238
- hash: 25
231
+ hash: -4161069882601304184
239
232
  segments:
240
- - 1
241
- - 3
242
- - 1
243
- version: 1.3.1
233
+ - 0
234
+ version: "0"
244
235
  requirements: []
245
236
 
246
237
  rubyforge_project: rspec
247
238
  rubygems_version: 1.3.7
248
239
  signing_key:
249
240
  specification_version: 3
250
- summary: rspec-expectations-2.0.0.rc
241
+ summary: rspec-expectations-2.0.0
251
242
  test_files:
252
243
  - features/README.markdown
253
244
  - features/expectations/attribute_of_subject.feature
@@ -263,8 +254,10 @@ test_files:
263
254
  - features/matchers/expect_change.feature
264
255
  - features/matchers/expect_error.feature
265
256
  - features/matchers/have.feature
257
+ - features/matchers/include.feature
266
258
  - features/matchers/operators.feature
267
259
  - features/matchers/predicates.feature
260
+ - features/matchers/respond_to.feature
268
261
  - features/step_definitions/additional_cli_steps.rb
269
262
  - features/support/env.rb
270
263
  - features/test_frameworks/test_unit.feature