rspec-expectations 2.0.0.beta.19 → 2.0.0.beta.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,27 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "should match(expected)" do
4
- it "should pass when target (String) matches expected (Regexp)" do
4
+ it "passes when target (String) matches expected (Regexp)" do
5
5
  "string".should match(/tri/)
6
6
  end
7
7
 
8
- it "should pass when target (String) matches expected (String)" do
8
+ it "passes when target (String) matches expected (String)" do
9
9
  "string".should match("tri")
10
10
  end
11
11
 
12
- it "should fail when target (String) does not match expected (Regexp)" do
12
+ it "fails when target (String) does not match expected (Regexp)" do
13
13
  lambda {
14
14
  "string".should match(/rings/)
15
15
  }.should fail
16
16
  end
17
17
 
18
- it "should fail when target (String) does not match expected (String)" do
18
+ it "fails when target (String) does not match expected (String)" do
19
19
  lambda {
20
20
  "string".should match("rings")
21
21
  }.should fail
22
22
  end
23
23
 
24
- it "should provide message, expected and actual on failure" do
24
+ it "provides message, expected and actual on failure" do
25
25
  matcher = match(/rings/)
26
26
  matcher.matches?("string")
27
27
  matcher.failure_message_for_should.should == "expected \"string\" to match /rings/"
@@ -29,27 +29,27 @@ describe "should match(expected)" do
29
29
  end
30
30
 
31
31
  describe "should_not match(expected)" do
32
- it "should pass when target (String) matches does not match (Regexp)" do
32
+ it "passes when target (String) matches does not match (Regexp)" do
33
33
  "string".should_not match(/rings/)
34
34
  end
35
35
 
36
- it "should pass when target (String) matches does not match (String)" do
36
+ it "passes when target (String) matches does not match (String)" do
37
37
  "string".should_not match("rings")
38
38
  end
39
39
 
40
- it "should fail when target (String) matches expected (Regexp)" do
40
+ it "fails when target (String) matches expected (Regexp)" do
41
41
  lambda {
42
42
  "string".should_not match(/tri/)
43
43
  }.should fail
44
44
  end
45
45
 
46
- it "should fail when target (String) matches expected (String)" do
46
+ it "fails when target (String) matches expected (String)" do
47
47
  lambda {
48
48
  "string".should_not match("tri")
49
49
  }.should fail
50
50
  end
51
51
 
52
- it "should provide message, expected and actual on failure" do
52
+ it "provides message, expected and actual on failure" do
53
53
  matcher = match(/tri/)
54
54
  matcher.matches?("string")
55
55
  matcher.failure_message_for_should_not.should == "expected \"string\" not to match /tri/"
@@ -2,18 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  describe "should ==" do
4
4
 
5
- it "should delegate message to target" do
5
+ it "delegates message to target" do
6
6
  subject = "apple"
7
7
  subject.should_receive(:==).with("apple").and_return(true)
8
8
  subject.should == "apple"
9
9
  end
10
10
 
11
- it "should return true on success" do
11
+ it "returns true on success" do
12
12
  subject = "apple"
13
13
  (subject.should == "apple").should be_true
14
14
  end
15
15
 
16
- it "should fail when target.==(actual) returns false" do
16
+ it "fails when target.==(actual) returns false" do
17
17
  subject = "apple"
18
18
  RSpec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ==)], "orange", "apple")
19
19
  subject.should == "orange"
@@ -23,18 +23,18 @@ end
23
23
 
24
24
  describe "should_not ==" do
25
25
 
26
- it "should delegate message to target" do
26
+ it "delegates message to target" do
27
27
  subject = "orange"
28
28
  subject.should_receive(:==).with("apple").and_return(false)
29
29
  subject.should_not == "apple"
30
30
  end
31
31
 
32
- it "should return true on success" do
32
+ it "returns true on success" do
33
33
  subject = "apple"
34
34
  (subject.should_not == "orange").should be_false
35
35
  end
36
36
 
37
- it "should fail when target.==(actual) returns false" do
37
+ it "fails when target.==(actual) returns false" do
38
38
  subject = "apple"
39
39
  RSpec::Expectations.should_receive(:fail_with).with(%[expected not: == "apple",\n got: "apple"], "apple", "apple")
40
40
  subject.should_not == "apple"
@@ -44,13 +44,13 @@ end
44
44
 
45
45
  describe "should ===" do
46
46
 
47
- it "should delegate message to target" do
47
+ it "delegates message to target" do
48
48
  subject = "apple"
49
49
  subject.should_receive(:===).with("apple").and_return(true)
50
50
  subject.should === "apple"
51
51
  end
52
52
 
53
- it "should fail when target.===(actual) returns false" do
53
+ it "fails when target.===(actual) returns false" do
54
54
  subject = "apple"
55
55
  subject.should_receive(:===).with("orange").and_return(false)
56
56
  RSpec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ===)], "orange", "apple")
@@ -61,13 +61,13 @@ end
61
61
 
62
62
  describe "should_not ===" do
63
63
 
64
- it "should delegate message to target" do
64
+ it "delegates message to target" do
65
65
  subject = "orange"
66
66
  subject.should_receive(:===).with("apple").and_return(false)
67
67
  subject.should_not === "apple"
68
68
  end
69
69
 
70
- it "should fail when target.===(actual) returns false" do
70
+ it "fails when target.===(actual) returns false" do
71
71
  subject = "apple"
72
72
  subject.should_receive(:===).with("apple").and_return(true)
73
73
  RSpec::Expectations.should_receive(:fail_with).with(%[expected not: === "apple",\n got: "apple"], "apple", "apple")
@@ -78,13 +78,13 @@ end
78
78
 
79
79
  describe "should =~" do
80
80
 
81
- it "should delegate message to target" do
81
+ it "delegates message to target" do
82
82
  subject = "foo"
83
83
  subject.should_receive(:=~).with(/oo/).and_return(true)
84
84
  subject.should =~ /oo/
85
85
  end
86
86
 
87
- it "should fail when target.=~(actual) returns false" do
87
+ it "fails when target.=~(actual) returns false" do
88
88
  subject = "fu"
89
89
  subject.should_receive(:=~).with(/oo/).and_return(false)
90
90
  RSpec::Expectations.should_receive(:fail_with).with(%[expected: /oo/,\n got: "fu" (using =~)], /oo/, "fu")
@@ -95,13 +95,13 @@ end
95
95
 
96
96
  describe "should_not =~" do
97
97
 
98
- it "should delegate message to target" do
98
+ it "delegates message to target" do
99
99
  subject = "fu"
100
100
  subject.should_receive(:=~).with(/oo/).and_return(false)
101
101
  subject.should_not =~ /oo/
102
102
  end
103
103
 
104
- it "should fail when target.=~(actual) returns false" do
104
+ it "fails when target.=~(actual) returns false" do
105
105
  subject = "foo"
106
106
  subject.should_receive(:=~).with(/oo/).and_return(true)
107
107
  RSpec::Expectations.should_receive(:fail_with).with(%[expected not: =~ /oo/,\n got: "foo"], /oo/, "foo")
@@ -112,11 +112,11 @@ end
112
112
 
113
113
  describe "should >" do
114
114
 
115
- it "should pass if > passes" do
115
+ it "passes if > passes" do
116
116
  4.should > 3
117
117
  end
118
118
 
119
- it "should fail if > fails" do
119
+ it "fails if > fails" do
120
120
  RSpec::Expectations.should_receive(:fail_with).with(%[expected: > 5,\n got: 4], 5, 4)
121
121
  4.should > 5
122
122
  end
@@ -125,12 +125,12 @@ end
125
125
 
126
126
  describe "should >=" do
127
127
 
128
- it "should pass if >= passes" do
128
+ it "passes if >= passes" do
129
129
  4.should > 3
130
130
  4.should >= 4
131
131
  end
132
132
 
133
- it "should fail if > fails" do
133
+ it "fails if > fails" do
134
134
  RSpec::Expectations.should_receive(:fail_with).with(%[expected: >= 5,\n got: 4], 5, 4)
135
135
  4.should >= 5
136
136
  end
@@ -139,11 +139,11 @@ end
139
139
 
140
140
  describe "should <" do
141
141
 
142
- it "should pass if < passes" do
142
+ it "passes if < passes" do
143
143
  4.should < 5
144
144
  end
145
145
 
146
- it "should fail if > fails" do
146
+ it "fails if > fails" do
147
147
  RSpec::Expectations.should_receive(:fail_with).with(%[expected: < 3,\n got: 4], 3, 4)
148
148
  4.should < 3
149
149
  end
@@ -152,12 +152,12 @@ end
152
152
 
153
153
  describe "should <=" do
154
154
 
155
- it "should pass if <= passes" do
155
+ it "passes if <= passes" do
156
156
  4.should <= 5
157
157
  4.should <= 4
158
158
  end
159
159
 
160
- it "should fail if > fails" do
160
+ it "fails if > fails" do
161
161
  RSpec::Expectations.should_receive(:fail_with).with(%[expected: <= 3,\n got: 4], 3, 4)
162
162
  4.should <= 3
163
163
  end
@@ -166,7 +166,7 @@ end
166
166
 
167
167
  describe RSpec::Matchers::PositiveOperatorMatcher do
168
168
 
169
- it "should work when the target has implemented #send" do
169
+ it "works when the target has implemented #send" do
170
170
  o = Object.new
171
171
  def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end
172
172
  lambda {
@@ -178,7 +178,7 @@ end
178
178
 
179
179
  describe RSpec::Matchers::NegativeOperatorMatcher do
180
180
 
181
- it "should work when the target has implemented #send" do
181
+ it "works when the target has implemented #send" do
182
182
  o = Object.new
183
183
  def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end
184
184
  lambda {
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "should raise_error" do
4
- it "should pass if anything is raised" do
4
+ it "passes if anything is raised" do
5
5
  lambda {raise}.should raise_error
6
6
  end
7
7
 
8
- it "should fail if nothing is raised" do
8
+ it "fails if nothing is raised" do
9
9
  lambda {
10
10
  lambda {}.should raise_error
11
11
  }.should fail_with("expected Exception but nothing was raised")
@@ -13,7 +13,7 @@ describe "should raise_error" do
13
13
  end
14
14
 
15
15
  describe "raise_exception aliased to raise_error" do
16
- it "should pass if anything is raised" do
16
+ it "passes if anything is raised" do
17
17
  lambda {raise}.should raise_exception
18
18
  end
19
19
  end
@@ -37,11 +37,11 @@ describe "should raise_error {|err| ... }" do
37
37
  end
38
38
 
39
39
  describe "should_not raise_error" do
40
- it "should pass if nothing is raised" do
40
+ it "passes if nothing is raised" do
41
41
  lambda {}.should_not raise_error
42
42
  end
43
43
 
44
- it "should fail if anything is raised" do
44
+ it "fails if anything is raised" do
45
45
  lambda {
46
46
  lambda {raise}.should_not raise_error
47
47
  }.should fail_with("expected no Exception, got RuntimeError")
@@ -49,21 +49,21 @@ describe "should_not raise_error" do
49
49
  end
50
50
 
51
51
  describe "should raise_error(message)" do
52
- it "should pass if RuntimeError is raised with the right message" do
52
+ it "passes if RuntimeError is raised with the right message" do
53
53
  lambda {raise 'blah'}.should raise_error('blah')
54
54
  end
55
- it "should pass if RuntimeError is raised with a matching message" do
55
+ it "passes if RuntimeError is raised with a matching message" do
56
56
  lambda {raise 'blah'}.should raise_error(/blah/)
57
57
  end
58
- it "should pass if any other error is raised with the right message" do
58
+ it "passes if any other error is raised with the right message" do
59
59
  lambda {raise NameError.new('blah')}.should raise_error('blah')
60
60
  end
61
- it "should fail if RuntimeError error is raised with the wrong message" do
61
+ it "fails if RuntimeError error is raised with the wrong message" do
62
62
  lambda do
63
63
  lambda {raise 'blarg'}.should raise_error('blah')
64
64
  end.should fail_with("expected Exception with \"blah\", got #<RuntimeError: blarg>")
65
65
  end
66
- it "should fail if any other error is raised with the wrong message" do
66
+ it "fails if any other error is raised with the wrong message" do
67
67
  lambda do
68
68
  lambda {raise NameError.new('blarg')}.should raise_error('blah')
69
69
  end.should fail_with("expected Exception with \"blah\", got #<NameError: blarg>")
@@ -71,18 +71,18 @@ describe "should raise_error(message)" do
71
71
  end
72
72
 
73
73
  describe "should_not raise_error(message)" do
74
- it "should pass if RuntimeError error is raised with the different message" do
74
+ it "passes if RuntimeError error is raised with the different message" do
75
75
  lambda {raise 'blarg'}.should_not raise_error('blah')
76
76
  end
77
- it "should pass if any other error is raised with the wrong message" do
77
+ it "passes if any other error is raised with the wrong message" do
78
78
  lambda {raise NameError.new('blarg')}.should_not raise_error('blah')
79
79
  end
80
- it "should fail if RuntimeError is raised with message" do
80
+ it "fails if RuntimeError is raised with message" do
81
81
  lambda do
82
82
  lambda {raise 'blah'}.should_not raise_error('blah')
83
83
  end.should fail_with(%Q|expected no Exception with "blah", got #<RuntimeError: blah>|)
84
84
  end
85
- it "should fail if any other error is raised with message" do
85
+ it "fails if any other error is raised with message" do
86
86
  lambda do
87
87
  lambda {raise NameError.new('blah')}.should_not raise_error('blah')
88
88
  end.should fail_with(%Q|expected no Exception with "blah", got #<NameError: blah>|)
@@ -90,23 +90,23 @@ describe "should_not raise_error(message)" do
90
90
  end
91
91
 
92
92
  describe "should raise_error(NamedError)" do
93
- it "should pass if named error is raised" do
93
+ it "passes if named error is raised" do
94
94
  lambda { non_existent_method }.should raise_error(NameError)
95
95
  end
96
96
 
97
- it "should fail if nothing is raised" do
97
+ it "fails if nothing is raised" do
98
98
  lambda {
99
99
  lambda { }.should raise_error(NameError)
100
100
  }.should fail_with("expected NameError but nothing was raised")
101
101
  end
102
102
 
103
- it "should fail if another error is raised (NameError)" do
103
+ it "fails if another error is raised (NameError)" do
104
104
  lambda {
105
105
  lambda { raise }.should raise_error(NameError)
106
106
  }.should fail_with("expected NameError, got RuntimeError")
107
107
  end
108
108
 
109
- it "should fail if another error is raised (NameError)" do
109
+ it "fails if another error is raised (NameError)" do
110
110
  lambda {
111
111
  lambda { load "non/existent/file" }.should raise_error(NameError)
112
112
  }.should fail_with(/expected NameError, got #<LoadError/)
@@ -114,15 +114,15 @@ describe "should raise_error(NamedError)" do
114
114
  end
115
115
 
116
116
  describe "should_not raise_error(NamedError)" do
117
- it "should pass if nothing is raised" do
117
+ it "passes if nothing is raised" do
118
118
  lambda { }.should_not raise_error(NameError)
119
119
  end
120
120
 
121
- it "should pass if another error is raised" do
121
+ it "passes if another error is raised" do
122
122
  lambda { raise }.should_not raise_error(NameError)
123
123
  end
124
124
 
125
- it "should fail if named error is raised" do
125
+ it "fails if named error is raised" do
126
126
  lambda {
127
127
  lambda { 1 + 'b' }.should_not raise_error(TypeError)
128
128
  }.should fail_with(/expected no TypeError, got #<TypeError: String can't be/)
@@ -130,23 +130,23 @@ describe "should_not raise_error(NamedError)" do
130
130
  end
131
131
 
132
132
  describe "should raise_error(NamedError, error_message) with String" do
133
- it "should pass if named error is raised with same message" do
133
+ it "passes if named error is raised with same message" do
134
134
  lambda { raise "example message" }.should raise_error(RuntimeError, "example message")
135
135
  end
136
136
 
137
- it "should fail if nothing is raised" do
137
+ it "fails if nothing is raised" do
138
138
  lambda {
139
139
  lambda {}.should raise_error(RuntimeError, "example message")
140
140
  }.should fail_with("expected RuntimeError with \"example message\" but nothing was raised")
141
141
  end
142
142
 
143
- it "should fail if incorrect error is raised" do
143
+ it "fails if incorrect error is raised" do
144
144
  lambda {
145
145
  lambda { raise }.should raise_error(NameError, "example message")
146
146
  }.should fail_with("expected NameError with \"example message\", got RuntimeError")
147
147
  end
148
148
 
149
- it "should fail if correct error is raised with incorrect message" do
149
+ it "fails if correct error is raised with incorrect message" do
150
150
  lambda {
151
151
  lambda { raise RuntimeError.new("not the example message") }.should raise_error(RuntimeError, "example message")
152
152
  }.should fail_with(/expected RuntimeError with \"example message\", got #<RuntimeError: not the example message/)
@@ -154,7 +154,7 @@ describe "should raise_error(NamedError, error_message) with String" do
154
154
  end
155
155
 
156
156
  describe "should raise_error(NamedError, error_message) { |err| ... }" do
157
- it "should yield exception if named error is raised with same message" do
157
+ it "yields exception if named error is raised with same message" do
158
158
  ran = false
159
159
 
160
160
  lambda {
@@ -168,7 +168,7 @@ describe "should raise_error(NamedError, error_message) { |err| ... }" do
168
168
  ran.should == true
169
169
  end
170
170
 
171
- it "yielded block should be able to fail on it's own right" do
171
+ it "yielded block fails on it's own right" do
172
172
  ran, passed = false, false
173
173
 
174
174
  lambda {
@@ -185,7 +185,7 @@ describe "should raise_error(NamedError, error_message) { |err| ... }" do
185
185
  passed.should == false
186
186
  end
187
187
 
188
- it "should NOT yield exception if no error was thrown" do
188
+ it "does NOT yield exception if no error was thrown" do
189
189
  ran = false
190
190
 
191
191
  lambda {
@@ -197,7 +197,7 @@ describe "should raise_error(NamedError, error_message) { |err| ... }" do
197
197
  ran.should == false
198
198
  end
199
199
 
200
- it "should not yield exception if error class is not matched" do
200
+ it "does not yield exception if error class is not matched" do
201
201
  ran = false
202
202
 
203
203
  lambda {
@@ -211,7 +211,7 @@ describe "should raise_error(NamedError, error_message) { |err| ... }" do
211
211
  ran.should == false
212
212
  end
213
213
 
214
- it "should NOT yield exception if error message is not matched" do
214
+ it "does NOT yield exception if error message is not matched" do
215
215
  ran = false
216
216
 
217
217
  lambda {
@@ -227,7 +227,7 @@ describe "should raise_error(NamedError, error_message) { |err| ... }" do
227
227
  end
228
228
 
229
229
  describe "should_not raise_error(NamedError, error_message) { |err| ... }" do
230
- it "should pass if nothing is raised" do
230
+ it "passes if nothing is raised" do
231
231
  ran = false
232
232
 
233
233
  lambda {}.should_not raise_error(RuntimeError, "example message") { |err|
@@ -237,7 +237,7 @@ describe "should_not raise_error(NamedError, error_message) { |err| ... }" do
237
237
  ran.should == false
238
238
  end
239
239
 
240
- it "should pass if a different error is raised" do
240
+ it "passes if a different error is raised" do
241
241
  ran = false
242
242
 
243
243
  lambda { raise }.should_not raise_error(NameError, "example message") { |err|
@@ -247,7 +247,7 @@ describe "should_not raise_error(NamedError, error_message) { |err| ... }" do
247
247
  ran.should == false
248
248
  end
249
249
 
250
- it "should pass if same error is raised with different message" do
250
+ it "passes if same error is raised with different message" do
251
251
  ran = false
252
252
 
253
253
  lambda {
@@ -259,7 +259,7 @@ describe "should_not raise_error(NamedError, error_message) { |err| ... }" do
259
259
  ran.should == false
260
260
  end
261
261
 
262
- it "should fail if named error is raised with same message" do
262
+ it "fails if named error is raised with same message" do
263
263
  ran = false
264
264
 
265
265
  lambda {
@@ -275,19 +275,19 @@ describe "should_not raise_error(NamedError, error_message) { |err| ... }" do
275
275
  end
276
276
 
277
277
  describe "should_not raise_error(NamedError, error_message) with String" do
278
- it "should pass if nothing is raised" do
278
+ it "passes if nothing is raised" do
279
279
  lambda {}.should_not raise_error(RuntimeError, "example message")
280
280
  end
281
281
 
282
- it "should pass if a different error is raised" do
282
+ it "passes if a different error is raised" do
283
283
  lambda { raise }.should_not raise_error(NameError, "example message")
284
284
  end
285
285
 
286
- it "should pass if same error is raised with different message" do
286
+ it "passes if same error is raised with different message" do
287
287
  lambda { raise RuntimeError.new("not the example message") }.should_not raise_error(RuntimeError, "example message")
288
288
  end
289
289
 
290
- it "should fail if named error is raised with same message" do
290
+ it "fails if named error is raised with same message" do
291
291
  lambda {
292
292
  lambda { raise "example message" }.should_not raise_error(RuntimeError, "example message")
293
293
  }.should fail_with("expected no RuntimeError with \"example message\", got #<RuntimeError: example message>")
@@ -295,23 +295,23 @@ describe "should_not raise_error(NamedError, error_message) with String" do
295
295
  end
296
296
 
297
297
  describe "should raise_error(NamedError, error_message) with Regexp" do
298
- it "should pass if named error is raised with matching message" do
298
+ it "passes if named error is raised with matching message" do
299
299
  lambda { raise "example message" }.should raise_error(RuntimeError, /ample mess/)
300
300
  end
301
301
 
302
- it "should fail if nothing is raised" do
302
+ it "fails if nothing is raised" do
303
303
  lambda {
304
304
  lambda {}.should raise_error(RuntimeError, /ample mess/)
305
305
  }.should fail_with("expected RuntimeError with message matching /ample mess/ but nothing was raised")
306
306
  end
307
307
 
308
- it "should fail if incorrect error is raised" do
308
+ it "fails if incorrect error is raised" do
309
309
  lambda {
310
310
  lambda { raise }.should raise_error(NameError, /ample mess/)
311
311
  }.should fail_with("expected NameError with message matching /ample mess/, got RuntimeError")
312
312
  end
313
313
 
314
- it "should fail if correct error is raised with incorrect message" do
314
+ it "fails if correct error is raised with incorrect message" do
315
315
  lambda {
316
316
  lambda { raise RuntimeError.new("not the example message") }.should raise_error(RuntimeError, /less than ample mess/)
317
317
  }.should fail_with("expected RuntimeError with message matching /less than ample mess/, got #<RuntimeError: not the example message>")
@@ -319,19 +319,19 @@ describe "should raise_error(NamedError, error_message) with Regexp" do
319
319
  end
320
320
 
321
321
  describe "should_not raise_error(NamedError, error_message) with Regexp" do
322
- it "should pass if nothing is raised" do
322
+ it "passes if nothing is raised" do
323
323
  lambda {}.should_not raise_error(RuntimeError, /ample mess/)
324
324
  end
325
325
 
326
- it "should pass if a different error is raised" do
326
+ it "passes if a different error is raised" do
327
327
  lambda { raise }.should_not raise_error(NameError, /ample mess/)
328
328
  end
329
329
 
330
- it "should pass if same error is raised with non-matching message" do
330
+ it "passes if same error is raised with non-matching message" do
331
331
  lambda { raise RuntimeError.new("non matching message") }.should_not raise_error(RuntimeError, /ample mess/)
332
332
  end
333
333
 
334
- it "should fail if named error is raised with matching message" do
334
+ it "fails if named error is raised with matching message" do
335
335
  lambda {
336
336
  lambda { raise "example message" }.should_not raise_error(RuntimeError, /ample mess/)
337
337
  }.should fail_with("expected no RuntimeError with message matching /ample mess/, got #<RuntimeError: example message>")