rspec-mocks 2.10.0 → 2.10.1
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.
- data/Changelog.md +10 -0
- data/lib/rspec/mocks/message_expectation.rb +6 -2
- data/lib/rspec/mocks/version.rb +1 -1
- data/spec/rspec/mocks/at_least_spec.rb +75 -50
- data/spec/rspec/mocks/mock_spec.rb +240 -238
- data/spec/rspec/mocks/stub_chain_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -1
- metadata +5 -5
data/Changelog.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
### 2.10.1 / 2012-05-05
|
2
|
+
[full changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.0...v2.10.1)
|
3
|
+
|
4
|
+
Bug fixes
|
5
|
+
|
6
|
+
* fix regression of edge case behavior
|
7
|
+
(https://github.com/rspec/rspec-mocks/issues/132)
|
8
|
+
* fixed failure of `object.should_receive(:message).at_least(0).times.and_return value`
|
9
|
+
* fixed failure of `object.should_not_receive(:message).and_return value`
|
10
|
+
|
1
11
|
### 2.10.0 / 2012-05-03
|
2
12
|
[full changelog](http://github.com/rspec/rspec-mocks/compare/v2.9.0...v2.10.0)
|
3
13
|
|
@@ -87,7 +87,7 @@ module RSpec
|
|
87
87
|
# counter.stub(:count) { 1 }
|
88
88
|
# counter.count # => 1
|
89
89
|
def and_return(*values, &implementation)
|
90
|
-
@expected_received_count = [@expected_received_count, values.size].max unless ignoring_args?
|
90
|
+
@expected_received_count = [@expected_received_count, values.size].max unless ignoring_args? || (@expected_received_count == 0 and @at_least)
|
91
91
|
@consecutive = true if values.size > 1
|
92
92
|
@implementation = implementation || build_implementation(values)
|
93
93
|
end
|
@@ -153,7 +153,7 @@ module RSpec
|
|
153
153
|
|
154
154
|
# @private
|
155
155
|
def invoke(*args, &block)
|
156
|
-
if @expected_received_count == 0 || ((@exactly || @at_most) && (@actual_received_count == @expected_received_count))
|
156
|
+
if (@expected_received_count == 0 && !@at_least) || ((@exactly || @at_most) && (@actual_received_count == @expected_received_count))
|
157
157
|
@actual_received_count += 1
|
158
158
|
@failed_fast = true
|
159
159
|
@error_generator.raise_expectation_error(@message, @expected_received_count, @actual_received_count, *args)
|
@@ -467,6 +467,10 @@ MESSAGE
|
|
467
467
|
super(error_generator, expectation_ordering, expected_from, message, 0, {}, &implementation)
|
468
468
|
end
|
469
469
|
|
470
|
+
def and_return(*)
|
471
|
+
# no-op
|
472
|
+
end
|
473
|
+
|
470
474
|
# @private
|
471
475
|
def negative_expectation_for?(message)
|
472
476
|
return @message == message
|
data/lib/rspec/mocks/version.rb
CHANGED
@@ -3,100 +3,125 @@ require 'spec_helper'
|
|
3
3
|
module RSpec
|
4
4
|
module Mocks
|
5
5
|
describe "at_least" do
|
6
|
-
before(:each)
|
7
|
-
@mock = RSpec::Mocks::Mock.new("test mock")
|
8
|
-
end
|
6
|
+
before(:each) { @double = double }
|
9
7
|
|
10
8
|
it "fails if method is never called" do
|
11
|
-
@
|
12
|
-
|
13
|
-
|
9
|
+
@double.should_receive(:do_something).at_least(4).times
|
10
|
+
lambda do
|
11
|
+
@double.rspec_verify
|
14
12
|
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
15
13
|
end
|
16
14
|
|
17
15
|
it "fails when called less than n times" do
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
16
|
+
@double.should_receive(:do_something).at_least(4).times
|
17
|
+
@double.do_something
|
18
|
+
@double.do_something
|
19
|
+
@double.do_something
|
22
20
|
lambda do
|
23
|
-
@
|
21
|
+
@double.rspec_verify
|
24
22
|
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
25
23
|
end
|
26
24
|
|
27
25
|
it "fails when at least once method is never called" do
|
28
|
-
@
|
26
|
+
@double.should_receive(:do_something).at_least(:once)
|
29
27
|
lambda do
|
30
|
-
@
|
28
|
+
@double.rspec_verify
|
31
29
|
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
32
30
|
end
|
33
31
|
|
34
32
|
it "fails when at least twice method is called once" do
|
35
|
-
@
|
36
|
-
@
|
33
|
+
@double.should_receive(:do_something).at_least(:twice)
|
34
|
+
@double.do_something
|
37
35
|
lambda do
|
38
|
-
@
|
36
|
+
@double.rspec_verify
|
39
37
|
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
40
38
|
end
|
41
39
|
|
42
40
|
it "fails when at least twice method is never called" do
|
43
|
-
@
|
41
|
+
@double.should_receive(:do_something).at_least(:twice)
|
44
42
|
lambda do
|
45
|
-
@
|
43
|
+
@double.rspec_verify
|
46
44
|
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
47
45
|
end
|
48
46
|
|
49
47
|
it "passes when at least n times method is called exactly n times" do
|
50
|
-
@
|
51
|
-
@
|
52
|
-
@
|
53
|
-
@
|
54
|
-
@
|
55
|
-
@
|
48
|
+
@double.should_receive(:do_something).at_least(4).times
|
49
|
+
@double.do_something
|
50
|
+
@double.do_something
|
51
|
+
@double.do_something
|
52
|
+
@double.do_something
|
53
|
+
@double.rspec_verify
|
56
54
|
end
|
57
55
|
|
58
56
|
it "passes when at least n times method is called n plus 1 times" do
|
59
|
-
@
|
60
|
-
@
|
61
|
-
@
|
62
|
-
@
|
63
|
-
@
|
64
|
-
@
|
65
|
-
@
|
57
|
+
@double.should_receive(:do_something).at_least(4).times
|
58
|
+
@double.do_something
|
59
|
+
@double.do_something
|
60
|
+
@double.do_something
|
61
|
+
@double.do_something
|
62
|
+
@double.do_something
|
63
|
+
@double.rspec_verify
|
66
64
|
end
|
67
65
|
|
68
66
|
it "passes when at least once method is called once" do
|
69
|
-
@
|
70
|
-
@
|
71
|
-
@
|
67
|
+
@double.should_receive(:do_something).at_least(:once)
|
68
|
+
@double.do_something
|
69
|
+
@double.rspec_verify
|
72
70
|
end
|
73
71
|
|
74
72
|
it "passes when at least once method is called twice" do
|
75
|
-
@
|
76
|
-
@
|
77
|
-
@
|
78
|
-
@
|
73
|
+
@double.should_receive(:do_something).at_least(:once)
|
74
|
+
@double.do_something
|
75
|
+
@double.do_something
|
76
|
+
@double.rspec_verify
|
79
77
|
end
|
80
78
|
|
81
79
|
it "passes when at least twice method is called three times" do
|
82
|
-
@
|
83
|
-
@
|
84
|
-
@
|
85
|
-
@
|
86
|
-
@
|
80
|
+
@double.should_receive(:do_something).at_least(:twice)
|
81
|
+
@double.do_something
|
82
|
+
@double.do_something
|
83
|
+
@double.do_something
|
84
|
+
@double.rspec_verify
|
87
85
|
end
|
88
86
|
|
89
87
|
it "passes when at least twice method is called twice" do
|
90
|
-
@
|
91
|
-
@
|
92
|
-
@
|
93
|
-
@
|
88
|
+
@double.should_receive(:do_something).at_least(:twice)
|
89
|
+
@double.do_something
|
90
|
+
@double.do_something
|
91
|
+
@double.rspec_verify
|
94
92
|
end
|
95
93
|
|
96
94
|
it "returns the value given by a block when the at least once method is called" do
|
97
|
-
@
|
98
|
-
@
|
99
|
-
@
|
95
|
+
@double.should_receive(:to_s).at_least(:once) { "testing" }
|
96
|
+
@double.to_s.should eq "testing"
|
97
|
+
@double.rspec_verify
|
98
|
+
end
|
99
|
+
|
100
|
+
it "passes with at_least(0) with no return if called once" do
|
101
|
+
@double.should_receive(:do_something).at_least(0).times
|
102
|
+
@double.do_something
|
103
|
+
end
|
104
|
+
|
105
|
+
it "passes with at_least(0) with return block if called once" do
|
106
|
+
@double.should_receive(:do_something).at_least(0).times { true }
|
107
|
+
@double.do_something
|
108
|
+
end
|
109
|
+
|
110
|
+
it "passes with at_least(0) with and_return if called once" do
|
111
|
+
@double.should_receive(:do_something).at_least(0).times.and_return true
|
112
|
+
@double.do_something
|
113
|
+
end
|
114
|
+
|
115
|
+
it "passes with at_least(0) with no return if never called" do
|
116
|
+
@double.should_receive(:do_something).at_least(0).times
|
117
|
+
end
|
118
|
+
|
119
|
+
it "passes with at_least(0) with return block if never called" do
|
120
|
+
@double.should_receive(:do_something).at_least(0).times { true }
|
121
|
+
end
|
122
|
+
|
123
|
+
it "passes with at_least(0) with and_return if never called" do
|
124
|
+
@double.should_receive(:do_something).at_least(0).times.and_return true
|
100
125
|
end
|
101
126
|
end
|
102
127
|
end
|
@@ -3,20 +3,15 @@ require 'spec_helper'
|
|
3
3
|
module RSpec
|
4
4
|
module Mocks
|
5
5
|
describe Mock do
|
6
|
-
before(:each) do
|
7
|
-
@mock = double("test double")
|
8
|
-
end
|
9
|
-
|
10
6
|
treats_method_missing_as_private :subject => RSpec::Mocks::Mock.new, :noop => false
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
8
|
+
before(:each) { @double = double("test double") }
|
9
|
+
after(:each) { @double.rspec_reset }
|
15
10
|
|
16
11
|
it "reports line number of expectation of unreceived message" do
|
17
|
-
expected_error_line = __LINE__; @
|
12
|
+
expected_error_line = __LINE__; @double.should_receive(:wont_happen).with("x", 3)
|
18
13
|
begin
|
19
|
-
@
|
14
|
+
@double.rspec_verify
|
20
15
|
violated
|
21
16
|
rescue RSpec::Mocks::MockExpectationError => e
|
22
17
|
# NOTE - this regexp ended w/ $, but jruby adds extra info at the end of the line
|
@@ -25,10 +20,10 @@ module RSpec
|
|
25
20
|
end
|
26
21
|
|
27
22
|
it "reports line number of expectation of unreceived message after #should_receive after similar stub" do
|
28
|
-
@
|
29
|
-
expected_error_line = __LINE__; @
|
23
|
+
@double.stub(:wont_happen)
|
24
|
+
expected_error_line = __LINE__; @double.should_receive(:wont_happen).with("x", 3)
|
30
25
|
begin
|
31
|
-
@
|
26
|
+
@double.rspec_verify
|
32
27
|
violated
|
33
28
|
rescue RSpec::Mocks::MockExpectationError => e
|
34
29
|
# NOTE - this regexp ended w/ $, but jruby adds extra info at the end of the line
|
@@ -37,21 +32,28 @@ module RSpec
|
|
37
32
|
end
|
38
33
|
|
39
34
|
it "passes when not receiving message specified as not to be received" do
|
40
|
-
@
|
41
|
-
@
|
35
|
+
@double.should_not_receive(:not_expected)
|
36
|
+
@double.rspec_verify
|
37
|
+
end
|
38
|
+
|
39
|
+
it "passes when not receiving message specified as not to be received with and_return" do
|
40
|
+
# NOTE (DC 2012-05-05) calling `and_return` after `should_not_receive` makes no sense
|
41
|
+
# and should probably be disallowed.
|
42
|
+
@double.should_not_receive(:not_expected).and_return nil
|
43
|
+
@double.rspec_verify
|
42
44
|
end
|
43
45
|
|
44
46
|
it "passes when receiving message specified as not to be received with different args" do
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
47
|
+
@double.should_not_receive(:message).with("unwanted text")
|
48
|
+
@double.should_receive(:message).with("other text")
|
49
|
+
@double.message "other text"
|
50
|
+
@double.rspec_verify
|
49
51
|
end
|
50
52
|
|
51
53
|
it "fails when receiving message specified as not to be received" do
|
52
|
-
@
|
54
|
+
@double.should_not_receive(:not_expected)
|
53
55
|
expect {
|
54
|
-
@
|
56
|
+
@double.not_expected
|
55
57
|
violated
|
56
58
|
}.to raise_error(
|
57
59
|
RSpec::Mocks::MockExpectationError,
|
@@ -60,9 +62,9 @@ module RSpec
|
|
60
62
|
end
|
61
63
|
|
62
64
|
it "fails when receiving message specified as not to be received with args" do
|
63
|
-
@
|
65
|
+
@double.should_not_receive(:not_expected).with("unexpected text")
|
64
66
|
expect {
|
65
|
-
@
|
67
|
+
@double.not_expected("unexpected text")
|
66
68
|
violated
|
67
69
|
}.to raise_error(
|
68
70
|
RSpec::Mocks::MockExpectationError,
|
@@ -71,157 +73,157 @@ module RSpec
|
|
71
73
|
end
|
72
74
|
|
73
75
|
it "passes when receiving message specified as not to be received with wrong args" do
|
74
|
-
@
|
75
|
-
@
|
76
|
-
@
|
76
|
+
@double.should_not_receive(:not_expected).with("unexpected text")
|
77
|
+
@double.not_expected "really unexpected text"
|
78
|
+
@double.rspec_verify
|
77
79
|
end
|
78
80
|
|
79
81
|
it "allows block to calculate return values" do
|
80
|
-
@
|
81
|
-
@
|
82
|
-
@
|
82
|
+
@double.should_receive(:something).with("a","b","c").and_return { |a,b,c| c+b+a }
|
83
|
+
@double.something("a","b","c").should eq "cba"
|
84
|
+
@double.rspec_verify
|
83
85
|
end
|
84
86
|
|
85
87
|
it "allows parameter as return value" do
|
86
|
-
@
|
87
|
-
@
|
88
|
-
@
|
88
|
+
@double.should_receive(:something).with("a","b","c").and_return("booh")
|
89
|
+
@double.something("a","b","c").should eq "booh"
|
90
|
+
@double.rspec_verify
|
89
91
|
end
|
90
92
|
|
91
93
|
it "returns the previously stubbed value if no return value is set" do
|
92
|
-
@
|
93
|
-
@
|
94
|
-
@
|
95
|
-
@
|
94
|
+
@double.stub(:something).with("a","b","c").and_return(:stubbed_value)
|
95
|
+
@double.should_receive(:something).with("a","b","c")
|
96
|
+
@double.something("a","b","c").should eq :stubbed_value
|
97
|
+
@double.rspec_verify
|
96
98
|
end
|
97
99
|
|
98
100
|
it "returns nil if no return value is set and there is no previously stubbed value" do
|
99
|
-
@
|
100
|
-
@
|
101
|
-
@
|
101
|
+
@double.should_receive(:something).with("a","b","c")
|
102
|
+
@double.something("a","b","c").should be_nil
|
103
|
+
@double.rspec_verify
|
102
104
|
end
|
103
105
|
|
104
106
|
it "raises exception if args don't match when method called" do
|
105
|
-
@
|
107
|
+
@double.should_receive(:something).with("a","b","c").and_return("booh")
|
106
108
|
lambda {
|
107
|
-
@
|
109
|
+
@double.something("a","d","c")
|
108
110
|
violated
|
109
111
|
}.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: (\"a\", \"d\", \"c\")")
|
110
112
|
end
|
111
113
|
|
112
114
|
describe "even when a similar expectation with different arguments exist" do
|
113
115
|
it "raises exception if args don't match when method called, correctly reporting the offending arguments" do
|
114
|
-
@
|
115
|
-
@
|
116
|
+
@double.should_receive(:something).with("a","b","c").once
|
117
|
+
@double.should_receive(:something).with("z","x","c").once
|
116
118
|
lambda {
|
117
|
-
@
|
118
|
-
@
|
119
|
+
@double.something("a","b","c")
|
120
|
+
@double.something("z","x","g")
|
119
121
|
}.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received :something with unexpected arguments\n expected: (\"z\", \"x\", \"c\")\n got: (\"z\", \"x\", \"g\")")
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
123
125
|
it "raises exception if args don't match when method called even when the method is stubbed" do
|
124
|
-
@
|
125
|
-
@
|
126
|
+
@double.stub(:something)
|
127
|
+
@double.should_receive(:something).with("a","b","c")
|
126
128
|
lambda {
|
127
|
-
@
|
128
|
-
@
|
129
|
+
@double.something("a","d","c")
|
130
|
+
@double.rspec_verify
|
129
131
|
}.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: (\"a\", \"d\", \"c\")")
|
130
132
|
end
|
131
133
|
|
132
134
|
it "raises exception if args don't match when method called even when using null_object" do
|
133
|
-
@
|
134
|
-
@
|
135
|
+
@double = double("test double").as_null_object
|
136
|
+
@double.should_receive(:something).with("a","b","c")
|
135
137
|
lambda {
|
136
|
-
@
|
137
|
-
@
|
138
|
+
@double.something("a","d","c")
|
139
|
+
@double.rspec_verify
|
138
140
|
}.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: (\"a\", \"d\", \"c\")")
|
139
141
|
end
|
140
142
|
|
141
143
|
describe 'with a method that has a default argument' do
|
142
144
|
it "raises an exception if the arguments don't match when the method is called, correctly reporting the offending arguments" do
|
143
|
-
def @
|
144
|
-
@
|
145
|
+
def @double.method_with_default_argument(arg={}); end
|
146
|
+
@double.should_receive(:method_with_default_argument).with({})
|
145
147
|
|
146
148
|
expect {
|
147
|
-
@
|
148
|
-
@
|
149
|
+
@double.method_with_default_argument(nil)
|
150
|
+
@double.rspec_verify
|
149
151
|
}.to raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received :method_with_default_argument with unexpected arguments\n expected: ({})\n got: (nil)")
|
150
152
|
end
|
151
153
|
end
|
152
154
|
|
153
155
|
it "fails if unexpected method called" do
|
154
156
|
lambda {
|
155
|
-
@
|
157
|
+
@double.something("a","b","c")
|
156
158
|
violated
|
157
159
|
}.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received unexpected message :something with (\"a\", \"b\", \"c\")")
|
158
160
|
end
|
159
161
|
|
160
162
|
it "uses block for expectation if provided" do
|
161
|
-
@
|
163
|
+
@double.should_receive(:something) do | a, b |
|
162
164
|
a.should eq "a"
|
163
165
|
b.should eq "b"
|
164
166
|
"booh"
|
165
167
|
end
|
166
|
-
@
|
167
|
-
@
|
168
|
+
@double.something("a", "b").should eq "booh"
|
169
|
+
@double.rspec_verify
|
168
170
|
end
|
169
171
|
|
170
172
|
it "fails if expectation block fails" do
|
171
|
-
@
|
173
|
+
@double.should_receive(:something) {| bool | bool.should be_true}
|
172
174
|
expect {
|
173
|
-
@
|
175
|
+
@double.something false
|
174
176
|
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
175
177
|
end
|
176
178
|
|
177
179
|
it "passes proc to expectation block without an argument", :ruby => '> 1.8.6' do
|
178
180
|
# We eval this because Ruby 1.8.6's syntax parser barfs on { |&block| ... }
|
179
181
|
# and prevents the entire spec suite from running.
|
180
|
-
eval("@
|
181
|
-
@
|
182
|
+
eval("@double.should_receive(:foo) {|&block| block.call.should eq(:bar)}")
|
183
|
+
@double.foo { :bar }
|
182
184
|
end
|
183
185
|
|
184
186
|
it "passes proc to expectation block with an argument", :ruby => '> 1.8.6' do
|
185
|
-
eval("@
|
186
|
-
@
|
187
|
+
eval("@double.should_receive(:foo) {|arg, &block| block.call.should eq(:bar)}")
|
188
|
+
@double.foo(:arg) { :bar }
|
187
189
|
end
|
188
190
|
|
189
191
|
it "passes proc to stub block without an argurment", :ruby => '>1.8.6' do
|
190
|
-
eval("@
|
191
|
-
@
|
192
|
+
eval("@double.stub(:foo) {|&block| block.call.should eq(:bar)}")
|
193
|
+
@double.foo { :bar }
|
192
194
|
end
|
193
195
|
|
194
196
|
it "passes proc to stub block with an argument", :ruby => '> 1.8.6' do
|
195
|
-
eval("@
|
196
|
-
@
|
197
|
+
eval("@double.stub(:foo) {|arg, &block| block.call.should eq(:bar)}")
|
198
|
+
@double.foo(:arg) { :bar }
|
197
199
|
end
|
198
200
|
|
199
201
|
it "fails right away when method defined as never is received" do
|
200
|
-
@
|
201
|
-
expect { @
|
202
|
+
@double.should_receive(:not_expected).never
|
203
|
+
expect { @double.not_expected }.
|
202
204
|
to raise_error(RSpec::Mocks::MockExpectationError,
|
203
205
|
%Q|(Double "test double").not_expected(no args)\n expected: 0 times\n received: 1 time|
|
204
206
|
)
|
205
207
|
end
|
206
208
|
|
207
209
|
it "raises when told to" do
|
208
|
-
@
|
209
|
-
expect { @
|
210
|
+
@double.should_receive(:something).and_raise(RuntimeError)
|
211
|
+
expect { @double.something }.to raise_error(RuntimeError)
|
210
212
|
end
|
211
213
|
|
212
214
|
it "raises instance of submitted Exception" do
|
213
215
|
error = RuntimeError.new("error message")
|
214
|
-
@
|
216
|
+
@double.should_receive(:something).and_raise(error)
|
215
217
|
lambda {
|
216
|
-
@
|
218
|
+
@double.something
|
217
219
|
}.should raise_error(RuntimeError, "error message")
|
218
220
|
end
|
219
221
|
|
220
222
|
it "raises instance of submitted ArgumentError" do
|
221
223
|
error = ArgumentError.new("error message")
|
222
|
-
@
|
224
|
+
@double.should_receive(:something).and_raise(error)
|
223
225
|
lambda {
|
224
|
-
@
|
226
|
+
@double.something
|
225
227
|
}.should raise_error(ArgumentError, "error message")
|
226
228
|
end
|
227
229
|
|
@@ -231,208 +233,208 @@ module RSpec
|
|
231
233
|
end
|
232
234
|
end
|
233
235
|
|
234
|
-
@
|
236
|
+
@double.stub(:something).and_raise(ErrorWithNonZeroArgConstructor)
|
235
237
|
lambda {
|
236
|
-
@
|
238
|
+
@double.something
|
237
239
|
}.should raise_error(ArgumentError, /^'and_raise' can only accept an Exception class if an instance/)
|
238
240
|
end
|
239
241
|
|
240
242
|
it "raises RuntimeError with submitted message" do
|
241
|
-
@
|
243
|
+
@double.should_receive(:something).and_raise("error message")
|
242
244
|
lambda {
|
243
|
-
@
|
245
|
+
@double.something
|
244
246
|
}.should raise_error(RuntimeError, "error message")
|
245
247
|
end
|
246
248
|
|
247
249
|
it "does not raise when told to if args dont match" do
|
248
|
-
@
|
250
|
+
@double.should_receive(:something).with(2).and_raise(RuntimeError)
|
249
251
|
lambda {
|
250
|
-
@
|
252
|
+
@double.something 1
|
251
253
|
}.should raise_error(RSpec::Mocks::MockExpectationError)
|
252
254
|
end
|
253
255
|
|
254
256
|
it "throws when told to" do
|
255
|
-
@
|
257
|
+
@double.should_receive(:something).and_throw(:blech)
|
256
258
|
lambda {
|
257
|
-
@
|
259
|
+
@double.something
|
258
260
|
}.should throw_symbol(:blech)
|
259
261
|
end
|
260
262
|
|
261
263
|
it "ignores args on any args" do
|
262
|
-
@
|
263
|
-
@
|
264
|
-
@
|
265
|
-
@
|
266
|
-
@
|
267
|
-
@
|
264
|
+
@double.should_receive(:something).at_least(:once).with(any_args)
|
265
|
+
@double.something
|
266
|
+
@double.something 1
|
267
|
+
@double.something "a", 2
|
268
|
+
@double.something [], {}, "joe", 7
|
269
|
+
@double.rspec_verify
|
268
270
|
end
|
269
271
|
|
270
272
|
it "fails on no args if any args received" do
|
271
|
-
@
|
273
|
+
@double.should_receive(:something).with(no_args())
|
272
274
|
lambda {
|
273
|
-
@
|
275
|
+
@double.something 1
|
274
276
|
}.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received :something with unexpected arguments\n expected: (no args)\n got: (1)")
|
275
277
|
end
|
276
278
|
|
277
279
|
it "fails when args are expected but none are received" do
|
278
|
-
@
|
280
|
+
@double.should_receive(:something).with(1)
|
279
281
|
lambda {
|
280
|
-
@
|
282
|
+
@double.something
|
281
283
|
}.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received :something with unexpected arguments\n expected: (1)\n got: (no args)")
|
282
284
|
end
|
283
285
|
|
284
286
|
it "returns value from block by default" do
|
285
|
-
@
|
286
|
-
@
|
287
|
-
@
|
287
|
+
@double.stub(:method_that_yields).and_yield
|
288
|
+
@double.method_that_yields { :returned_obj }.should eq :returned_obj
|
289
|
+
@double.rspec_verify
|
288
290
|
end
|
289
291
|
|
290
292
|
it "yields 0 args to blocks that take a variable number of arguments" do
|
291
|
-
@
|
293
|
+
@double.should_receive(:yield_back).with(no_args()).once.and_yield
|
292
294
|
a = nil
|
293
|
-
@
|
295
|
+
@double.yield_back {|*x| a = x}
|
294
296
|
a.should eq []
|
295
|
-
@
|
297
|
+
@double.rspec_verify
|
296
298
|
end
|
297
299
|
|
298
300
|
it "yields 0 args multiple times to blocks that take a variable number of arguments" do
|
299
|
-
@
|
301
|
+
@double.should_receive(:yield_back).once.with(no_args()).once.and_yield.
|
300
302
|
and_yield
|
301
303
|
b = []
|
302
|
-
@
|
304
|
+
@double.yield_back {|*a| b << a}
|
303
305
|
b.should eq [ [], [] ]
|
304
|
-
@
|
306
|
+
@double.rspec_verify
|
305
307
|
end
|
306
308
|
|
307
309
|
it "yields one arg to blocks that take a variable number of arguments" do
|
308
|
-
@
|
310
|
+
@double.should_receive(:yield_back).with(no_args()).once.and_yield(99)
|
309
311
|
a = nil
|
310
|
-
@
|
312
|
+
@double.yield_back {|*x| a = x}
|
311
313
|
a.should eq [99]
|
312
|
-
@
|
314
|
+
@double.rspec_verify
|
313
315
|
end
|
314
316
|
|
315
317
|
it "yields one arg 3 times consecutively to blocks that take a variable number of arguments" do
|
316
|
-
@
|
318
|
+
@double.should_receive(:yield_back).once.with(no_args()).once.and_yield(99).
|
317
319
|
and_yield(43).
|
318
320
|
and_yield("something fruity")
|
319
321
|
b = []
|
320
|
-
@
|
322
|
+
@double.yield_back {|*a| b << a}
|
321
323
|
b.should eq [[99], [43], ["something fruity"]]
|
322
|
-
@
|
324
|
+
@double.rspec_verify
|
323
325
|
end
|
324
326
|
|
325
327
|
it "yields many args to blocks that take a variable number of arguments" do
|
326
|
-
@
|
328
|
+
@double.should_receive(:yield_back).with(no_args()).once.and_yield(99, 27, "go")
|
327
329
|
a = nil
|
328
|
-
@
|
330
|
+
@double.yield_back {|*x| a = x}
|
329
331
|
a.should eq [99, 27, "go"]
|
330
|
-
@
|
332
|
+
@double.rspec_verify
|
331
333
|
end
|
332
334
|
|
333
335
|
it "yields many args 3 times consecutively to blocks that take a variable number of arguments" do
|
334
|
-
@
|
336
|
+
@double.should_receive(:yield_back).once.with(no_args()).once.and_yield(99, :green, "go").
|
335
337
|
and_yield("wait", :amber).
|
336
338
|
and_yield("stop", 12, :red)
|
337
339
|
b = []
|
338
|
-
@
|
340
|
+
@double.yield_back {|*a| b << a}
|
339
341
|
b.should eq [[99, :green, "go"], ["wait", :amber], ["stop", 12, :red]]
|
340
|
-
@
|
342
|
+
@double.rspec_verify
|
341
343
|
end
|
342
344
|
|
343
345
|
it "yields single value" do
|
344
|
-
@
|
346
|
+
@double.should_receive(:yield_back).with(no_args()).once.and_yield(99)
|
345
347
|
a = nil
|
346
|
-
@
|
348
|
+
@double.yield_back {|x| a = x}
|
347
349
|
a.should eq 99
|
348
|
-
@
|
350
|
+
@double.rspec_verify
|
349
351
|
end
|
350
352
|
|
351
353
|
it "yields single value 3 times consecutively" do
|
352
|
-
@
|
354
|
+
@double.should_receive(:yield_back).once.with(no_args()).once.and_yield(99).
|
353
355
|
and_yield(43).
|
354
356
|
and_yield("something fruity")
|
355
357
|
b = []
|
356
|
-
@
|
358
|
+
@double.yield_back {|a| b << a}
|
357
359
|
b.should eq [99, 43, "something fruity"]
|
358
|
-
@
|
360
|
+
@double.rspec_verify
|
359
361
|
end
|
360
362
|
|
361
363
|
it "yields two values" do
|
362
|
-
@
|
364
|
+
@double.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
|
363
365
|
a, b = nil
|
364
|
-
@
|
366
|
+
@double.yield_back {|x,y| a=x; b=y}
|
365
367
|
a.should eq 'wha'
|
366
368
|
b.should eq 'zup'
|
367
|
-
@
|
369
|
+
@double.rspec_verify
|
368
370
|
end
|
369
371
|
|
370
372
|
it "yields two values 3 times consecutively" do
|
371
|
-
@
|
373
|
+
@double.should_receive(:yield_back).once.with(no_args()).once.and_yield('wha', 'zup').
|
372
374
|
and_yield('not', 'down').
|
373
375
|
and_yield(14, 65)
|
374
376
|
c = []
|
375
|
-
@
|
377
|
+
@double.yield_back {|a,b| c << [a, b]}
|
376
378
|
c.should eq [['wha', 'zup'], ['not', 'down'], [14, 65]]
|
377
|
-
@
|
379
|
+
@double.rspec_verify
|
378
380
|
end
|
379
381
|
|
380
382
|
it "fails when calling yielding method with wrong arity" do
|
381
|
-
@
|
383
|
+
@double.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
|
382
384
|
lambda {
|
383
|
-
@
|
385
|
+
@double.yield_back {|a|}
|
384
386
|
}.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" yielded |\"wha\", \"zup\"| to block with arity of 1")
|
385
387
|
end
|
386
388
|
|
387
389
|
it "fails when calling yielding method consecutively with wrong arity" do
|
388
|
-
@
|
390
|
+
@double.should_receive(:yield_back).once.with(no_args()).once.and_yield('wha', 'zup').
|
389
391
|
and_yield('down').
|
390
392
|
and_yield(14, 65)
|
391
393
|
lambda {
|
392
394
|
c = []
|
393
|
-
@
|
395
|
+
@double.yield_back {|a,b| c << [a, b]}
|
394
396
|
}.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" yielded |\"down\"| to block with arity of 2")
|
395
397
|
end
|
396
398
|
|
397
399
|
it "fails when calling yielding method without block" do
|
398
|
-
@
|
400
|
+
@double.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
|
399
401
|
lambda {
|
400
|
-
@
|
402
|
+
@double.yield_back
|
401
403
|
}.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" asked to yield |[\"wha\", \"zup\"]| but no block was passed")
|
402
404
|
end
|
403
405
|
|
404
|
-
it "is able to
|
405
|
-
@
|
406
|
-
@
|
407
|
-
@
|
406
|
+
it "is able to double send" do
|
407
|
+
@double.should_receive(:send).with(any_args)
|
408
|
+
@double.send 'hi'
|
409
|
+
@double.rspec_verify
|
408
410
|
end
|
409
411
|
|
410
|
-
it "is able to raise from method calling yielding
|
411
|
-
@
|
412
|
+
it "is able to raise from method calling yielding double" do
|
413
|
+
@double.should_receive(:yield_me).and_yield 44
|
412
414
|
|
413
415
|
lambda {
|
414
|
-
@
|
416
|
+
@double.yield_me do |x|
|
415
417
|
raise "Bang"
|
416
418
|
end
|
417
419
|
}.should raise_error(StandardError, "Bang")
|
418
420
|
|
419
|
-
@
|
421
|
+
@double.rspec_verify
|
420
422
|
end
|
421
423
|
|
422
424
|
it "clears expectations after verify" do
|
423
|
-
@
|
424
|
-
@
|
425
|
-
@
|
425
|
+
@double.should_receive(:foobar)
|
426
|
+
@double.foobar
|
427
|
+
@double.rspec_verify
|
426
428
|
lambda {
|
427
|
-
@
|
429
|
+
@double.foobar
|
428
430
|
}.should raise_error(RSpec::Mocks::MockExpectationError, %q|Double "test double" received unexpected message :foobar with (no args)|)
|
429
431
|
end
|
430
432
|
|
431
433
|
it "restores objects to their original state on rspec_reset" do
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
434
|
+
double = double("this is a double")
|
435
|
+
double.should_receive(:blah)
|
436
|
+
double.rspec_reset
|
437
|
+
double.rspec_verify #should throw if reset didn't work
|
436
438
|
end
|
437
439
|
|
438
440
|
it "works even after method_missing starts raising NameErrors instead of NoMethodErrors" do
|
@@ -456,68 +458,68 @@ module RSpec
|
|
456
458
|
a_method_that_doesnt_exist rescue
|
457
459
|
|
458
460
|
|
459
|
-
@
|
460
|
-
@
|
461
|
-
@
|
461
|
+
@double.should_receive(:foobar)
|
462
|
+
@double.foobar
|
463
|
+
@double.rspec_verify
|
462
464
|
|
463
|
-
lambda { @
|
464
|
-
lambda { @
|
465
|
+
lambda { @double.foobar }.should_not raise_error(NameError)
|
466
|
+
lambda { @double.foobar }.should raise_error(RSpec::Mocks::MockExpectationError)
|
465
467
|
end
|
466
468
|
|
467
|
-
it "temporarily replaces a method stub on a
|
468
|
-
@
|
469
|
-
@
|
470
|
-
@
|
471
|
-
@
|
472
|
-
@
|
473
|
-
@
|
469
|
+
it "temporarily replaces a method stub on a double" do
|
470
|
+
@double.stub(:msg).and_return(:stub_value)
|
471
|
+
@double.should_receive(:msg).with(:arg).and_return(:double_value)
|
472
|
+
@double.msg(:arg).should equal(:double_value)
|
473
|
+
@double.msg.should equal(:stub_value)
|
474
|
+
@double.msg.should equal(:stub_value)
|
475
|
+
@double.rspec_verify
|
474
476
|
end
|
475
477
|
|
476
478
|
it "does not require a different signature to replace a method stub" do
|
477
|
-
@
|
478
|
-
@
|
479
|
-
@
|
480
|
-
@
|
481
|
-
@
|
482
|
-
@
|
479
|
+
@double.stub(:msg).and_return(:stub_value)
|
480
|
+
@double.should_receive(:msg).and_return(:double_value)
|
481
|
+
@double.msg(:arg).should equal(:double_value)
|
482
|
+
@double.msg.should equal(:stub_value)
|
483
|
+
@double.msg.should equal(:stub_value)
|
484
|
+
@double.rspec_verify
|
483
485
|
end
|
484
486
|
|
485
487
|
it "raises an error when a previously stubbed method has a negative expectation" do
|
486
|
-
@
|
487
|
-
@
|
488
|
-
expect { @
|
488
|
+
@double.stub(:msg).and_return(:stub_value)
|
489
|
+
@double.should_not_receive(:msg)
|
490
|
+
expect { @double.msg(:arg) }.to raise_error(RSpec::Mocks::MockExpectationError)
|
489
491
|
end
|
490
492
|
|
491
|
-
it "temporarily replaces a method stub on a non-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
493
|
+
it "temporarily replaces a method stub on a non-double" do
|
494
|
+
non_double = Object.new
|
495
|
+
non_double.stub(:msg).and_return(:stub_value)
|
496
|
+
non_double.should_receive(:msg).with(:arg).and_return(:double_value)
|
497
|
+
non_double.msg(:arg).should equal(:double_value)
|
498
|
+
non_double.msg.should equal(:stub_value)
|
499
|
+
non_double.msg.should equal(:stub_value)
|
500
|
+
non_double.rspec_verify
|
499
501
|
end
|
500
502
|
|
501
503
|
it "returns the stubbed value when no new value specified" do
|
502
|
-
@
|
503
|
-
@
|
504
|
-
@
|
505
|
-
@
|
504
|
+
@double.stub(:msg).and_return(:stub_value)
|
505
|
+
@double.should_receive(:msg)
|
506
|
+
@double.msg.should equal(:stub_value)
|
507
|
+
@double.rspec_verify
|
506
508
|
end
|
507
509
|
|
508
510
|
it "returns the stubbed value when stubbed with args and no new value specified" do
|
509
|
-
@
|
510
|
-
@
|
511
|
-
@
|
512
|
-
@
|
511
|
+
@double.stub(:msg).with(:arg).and_return(:stub_value)
|
512
|
+
@double.should_receive(:msg).with(:arg)
|
513
|
+
@double.msg(:arg).should equal(:stub_value)
|
514
|
+
@double.rspec_verify
|
513
515
|
end
|
514
516
|
|
515
|
-
it "does not mess with the stub's yielded values when also
|
516
|
-
@
|
517
|
-
@
|
518
|
-
@
|
519
|
-
@
|
520
|
-
@
|
517
|
+
it "does not mess with the stub's yielded values when also doubleed" do
|
518
|
+
@double.stub(:yield_back).and_yield(:stub_value)
|
519
|
+
@double.should_receive(:yield_back).and_yield(:double_value)
|
520
|
+
@double.yield_back{|v| v.should eq :double_value }
|
521
|
+
@double.yield_back{|v| v.should eq :stub_value }
|
522
|
+
@double.rspec_verify
|
521
523
|
end
|
522
524
|
|
523
525
|
it "yields multiple values after a similar stub" do
|
@@ -531,15 +533,15 @@ module RSpec
|
|
531
533
|
end
|
532
534
|
|
533
535
|
it "assigns stub return values" do
|
534
|
-
|
535
|
-
|
536
|
+
double = RSpec::Mocks::Mock.new('name', :message => :response)
|
537
|
+
double.message.should eq :response
|
536
538
|
end
|
537
539
|
|
538
540
|
end
|
539
541
|
|
540
|
-
describe "a
|
542
|
+
describe "a double message receiving a block" do
|
541
543
|
before(:each) do
|
542
|
-
@
|
544
|
+
@double = double("double")
|
543
545
|
@calls = 0
|
544
546
|
end
|
545
547
|
|
@@ -548,61 +550,61 @@ module RSpec
|
|
548
550
|
end
|
549
551
|
|
550
552
|
it "calls the block after #should_receive" do
|
551
|
-
@
|
553
|
+
@double.should_receive(:foo) { add_call }
|
552
554
|
|
553
|
-
@
|
555
|
+
@double.foo
|
554
556
|
|
555
557
|
@calls.should eq 1
|
556
558
|
end
|
557
559
|
|
558
560
|
it "calls the block after #should_receive after a similar stub" do
|
559
|
-
@
|
560
|
-
@
|
561
|
+
@double.stub(:foo).and_return(:bar)
|
562
|
+
@double.should_receive(:foo) { add_call }
|
561
563
|
|
562
|
-
@
|
564
|
+
@double.foo
|
563
565
|
|
564
566
|
@calls.should eq 1
|
565
567
|
end
|
566
568
|
|
567
569
|
it "calls the block after #once" do
|
568
|
-
@
|
570
|
+
@double.should_receive(:foo).once { add_call }
|
569
571
|
|
570
|
-
@
|
572
|
+
@double.foo
|
571
573
|
|
572
574
|
@calls.should eq 1
|
573
575
|
end
|
574
576
|
|
575
577
|
it "calls the block after #twice" do
|
576
|
-
@
|
578
|
+
@double.should_receive(:foo).twice { add_call }
|
577
579
|
|
578
|
-
@
|
579
|
-
@
|
580
|
+
@double.foo
|
581
|
+
@double.foo
|
580
582
|
|
581
583
|
@calls.should eq 2
|
582
584
|
end
|
583
585
|
|
584
586
|
it "calls the block after #times" do
|
585
|
-
@
|
587
|
+
@double.should_receive(:foo).exactly(10).times { add_call }
|
586
588
|
|
587
|
-
(1..10).each { @
|
589
|
+
(1..10).each { @double.foo }
|
588
590
|
|
589
591
|
@calls.should eq 10
|
590
592
|
end
|
591
593
|
|
592
594
|
it "calls the block after #any_number_of_times" do
|
593
|
-
@
|
595
|
+
@double.should_receive(:foo).any_number_of_times { add_call }
|
594
596
|
|
595
|
-
(1..7).each { @
|
597
|
+
(1..7).each { @double.foo }
|
596
598
|
|
597
599
|
@calls.should eq 7
|
598
600
|
end
|
599
601
|
|
600
602
|
it "calls the block after #ordered" do
|
601
|
-
@
|
602
|
-
@
|
603
|
+
@double.should_receive(:foo).ordered { add_call }
|
604
|
+
@double.should_receive(:bar).ordered { add_call }
|
603
605
|
|
604
|
-
@
|
605
|
-
@
|
606
|
+
@double.foo
|
607
|
+
@double.bar
|
606
608
|
|
607
609
|
@calls.should eq 2
|
608
610
|
end
|
@@ -610,8 +612,8 @@ module RSpec
|
|
610
612
|
|
611
613
|
describe 'string representation generated by #to_s' do
|
612
614
|
it 'does not contain < because that might lead to invalid HTML in some situations' do
|
613
|
-
|
614
|
-
valid_html_str = "#{
|
615
|
+
double = double("Dog")
|
616
|
+
valid_html_str = "#{double}"
|
615
617
|
valid_html_str.should_not include('<')
|
616
618
|
end
|
617
619
|
end
|
@@ -623,10 +625,10 @@ module RSpec
|
|
623
625
|
end
|
624
626
|
end
|
625
627
|
|
626
|
-
describe "
|
628
|
+
describe "double created with no name" do
|
627
629
|
it "does not use a name in a failure message" do
|
628
|
-
|
629
|
-
expect {
|
630
|
+
double = double()
|
631
|
+
expect {double.foo}.to raise_error(/Double received/)
|
630
632
|
end
|
631
633
|
|
632
634
|
it "does respond to initially stubbed methods" do
|
@@ -647,22 +649,22 @@ module RSpec
|
|
647
649
|
end
|
648
650
|
|
649
651
|
describe "with" do
|
650
|
-
before { @
|
652
|
+
before { @double = double('double') }
|
651
653
|
context "with args" do
|
652
654
|
context "with matching args" do
|
653
655
|
it "passes" do
|
654
|
-
@
|
655
|
-
@
|
656
|
+
@double.should_receive(:foo).with('bar')
|
657
|
+
@double.foo('bar')
|
656
658
|
end
|
657
659
|
end
|
658
660
|
|
659
661
|
context "with non-matching args" do
|
660
662
|
it "fails" do
|
661
|
-
@
|
663
|
+
@double.should_receive(:foo).with('bar')
|
662
664
|
expect do
|
663
|
-
@
|
665
|
+
@double.foo('baz')
|
664
666
|
end.to raise_error
|
665
|
-
@
|
667
|
+
@double.rspec_reset
|
666
668
|
end
|
667
669
|
end
|
668
670
|
|
@@ -670,11 +672,11 @@ module RSpec
|
|
670
672
|
it "fails" do
|
671
673
|
d1 = double('1')
|
672
674
|
d2 = double('2')
|
673
|
-
@
|
675
|
+
@double.should_receive(:foo).with(d1)
|
674
676
|
expect do
|
675
|
-
@
|
677
|
+
@double.foo(d2)
|
676
678
|
end.to raise_error
|
677
|
-
@
|
679
|
+
@double.rspec_reset
|
678
680
|
end
|
679
681
|
end
|
680
682
|
|
@@ -682,11 +684,11 @@ module RSpec
|
|
682
684
|
it "fails" do
|
683
685
|
d1 = double('1').as_null_object
|
684
686
|
d2 = double('2').as_null_object
|
685
|
-
@
|
687
|
+
@double.should_receive(:foo).with(d1)
|
686
688
|
expect do
|
687
|
-
@
|
689
|
+
@double.foo(d2)
|
688
690
|
end.to raise_error
|
689
|
-
@
|
691
|
+
@double.rspec_reset
|
690
692
|
end
|
691
693
|
end
|
692
694
|
end
|
@@ -694,18 +696,18 @@ module RSpec
|
|
694
696
|
context "with a block" do
|
695
697
|
context "with matching args" do
|
696
698
|
it "returns the result of the block" do
|
697
|
-
@
|
698
|
-
@
|
699
|
+
@double.should_receive(:foo).with('bar') { 'baz' }
|
700
|
+
@double.foo('bar').should eq('baz')
|
699
701
|
end
|
700
702
|
end
|
701
703
|
|
702
704
|
context "with non-matching args" do
|
703
705
|
it "fails" do
|
704
|
-
@
|
706
|
+
@double.should_receive(:foo).with('bar') { 'baz' }
|
705
707
|
expect do
|
706
|
-
@
|
708
|
+
@double.foo('wrong').should eq('baz')
|
707
709
|
end.to raise_error(/received :foo with unexpected arguments/)
|
708
|
-
@
|
710
|
+
@double.rspec_reset
|
709
711
|
end
|
710
712
|
end
|
711
713
|
end
|
@@ -111,7 +111,7 @@ module RSpec
|
|
111
111
|
|
112
112
|
context "using => value" do
|
113
113
|
context "starting with the same message" do
|
114
|
-
it "returns expected value"
|
114
|
+
it "returns expected value" do
|
115
115
|
subject.stub_chain(:msg1, :msg2, :msg3 => :first)
|
116
116
|
subject.stub_chain(:msg1, :msg2, :msg4 => :second)
|
117
117
|
|
@@ -121,7 +121,7 @@ module RSpec
|
|
121
121
|
end
|
122
122
|
|
123
123
|
context "starting with different messages" do
|
124
|
-
it "returns expected value"
|
124
|
+
it "returns expected value" do
|
125
125
|
subject.stub_chain(:msg1, :msg2, :msg3 => :first)
|
126
126
|
subject.stub_chain(:msg4, :msg2, :msg3 => :second)
|
127
127
|
|
data/spec/spec_helper.rb
CHANGED
@@ -39,7 +39,9 @@ RSpec.configure do |config|
|
|
39
39
|
config.order = :random
|
40
40
|
config.extend(Macros)
|
41
41
|
config.include(RSpec::Mocks::Methods)
|
42
|
-
|
42
|
+
config.run_all_when_everything_filtered = true
|
43
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
44
|
+
config.filter_run_including :focus
|
43
45
|
config.filter_run_excluding :ruby => lambda {|version|
|
44
46
|
case version.to_s
|
45
47
|
when "!jruby"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-mocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.
|
4
|
+
version: 2.10.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -182,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
182
|
version: '0'
|
183
183
|
segments:
|
184
184
|
- 0
|
185
|
-
hash:
|
185
|
+
hash: 2302057449526330825
|
186
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
187
|
none: false
|
188
188
|
requirements:
|
@@ -191,13 +191,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
version: '0'
|
192
192
|
segments:
|
193
193
|
- 0
|
194
|
-
hash:
|
194
|
+
hash: 2302057449526330825
|
195
195
|
requirements: []
|
196
196
|
rubyforge_project: rspec
|
197
197
|
rubygems_version: 1.8.24
|
198
198
|
signing_key:
|
199
199
|
specification_version: 3
|
200
|
-
summary: rspec-mocks-2.10.
|
200
|
+
summary: rspec-mocks-2.10.1
|
201
201
|
test_files:
|
202
202
|
- features/README.md
|
203
203
|
- features/Scope.md
|