rspec-mocks 2.5.0 → 2.6.0.rc2
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/.travis.yml +7 -0
- data/Gemfile +13 -12
- data/Guardfile +3 -3
- data/README.md +2 -0
- data/features/.nav +4 -0
- data/features/Changelog.md +12 -0
- data/features/README.markdown +44 -4
- data/features/message_expectations/any_instance.feature +19 -0
- data/features/message_expectations/block_local_expectations.feature.pending +2 -2
- data/features/message_expectations/expect_message.feature +3 -3
- data/features/message_expectations/warn_when_expectation_is_set_on_nil.feature +3 -3
- data/features/method_stubs/README.md +32 -24
- data/features/method_stubs/any_instance.feature +23 -0
- data/features/method_stubs/as_null_object.feature +36 -0
- data/features/method_stubs/simple_return_value.feature +2 -2
- data/features/method_stubs/stub_chain.feature +13 -6
- data/features/method_stubs/stub_implementation.feature +1 -1
- data/features/method_stubs/to_ary.feature +45 -0
- data/features/outside_rspec/configuration.feature +3 -3
- data/features/outside_rspec/standalone.feature +2 -2
- data/features/step_definitions/additional_cli_steps.rb +4 -0
- data/features/support/env.rb +5 -1
- data/lib/rspec/mocks.rb +2 -1
- data/lib/rspec/mocks/any_instance.rb +246 -0
- data/lib/rspec/mocks/extensions/psych.rb +23 -0
- data/lib/rspec/mocks/framework.rb +1 -0
- data/lib/rspec/mocks/message_expectation.rb +7 -4
- data/lib/rspec/mocks/methods.rb +1 -1
- data/lib/rspec/mocks/mock.rb +2 -2
- data/lib/rspec/mocks/serialization.rb +5 -3
- data/lib/rspec/mocks/space.rb +1 -1
- data/lib/rspec/mocks/version.rb +1 -1
- data/spec/rspec/mocks/and_yield_spec.rb +3 -3
- data/spec/rspec/mocks/any_instance_spec.rb +578 -0
- data/spec/rspec/mocks/any_number_of_times_spec.rb +22 -28
- data/spec/rspec/mocks/at_least_spec.rb +6 -0
- data/spec/rspec/mocks/at_most_spec.rb +6 -0
- data/spec/rspec/mocks/bug_report_10263_spec.rb +12 -14
- data/spec/rspec/mocks/bug_report_7611_spec.rb +2 -4
- data/spec/rspec/mocks/failing_argument_matchers_spec.rb +45 -46
- data/spec/rspec/mocks/nil_expectation_warning_spec.rb +1 -2
- data/spec/rspec/mocks/passing_argument_matchers_spec.rb +119 -122
- data/spec/rspec/mocks/precise_counts_spec.rb +6 -0
- data/spec/rspec/mocks/serialization_spec.rb +21 -3
- data/spec/rspec/mocks/stub_chain_spec.rb +72 -37
- data/spec/rspec/mocks/stub_spec.rb +64 -61
- data/spec/rspec/mocks/to_ary_spec.rb +31 -0
- metadata +32 -15
- data/spec/rspec/mocks/bug_report_7805_spec.rb +0 -22
- data/spec/rspec/mocks/bug_report_8302_spec.rb +0 -26
@@ -1,36 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@mock = RSpec::Mocks::Mock.new("test mock")
|
9
|
-
end
|
3
|
+
describe "AnyNumberOfTimes" do
|
4
|
+
before(:each) do
|
5
|
+
@mock = RSpec::Mocks::Mock.new("test mock")
|
6
|
+
end
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
it "passes if any number of times method is called many times" do
|
9
|
+
@mock.should_receive(:random_call).any_number_of_times
|
10
|
+
(1..10).each do
|
11
|
+
@mock.random_call
|
12
|
+
end
|
13
|
+
end
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
it "passes if any number of times method is not called" do
|
24
|
-
@mock.should_receive(:random_call).any_number_of_times
|
25
|
-
end
|
15
|
+
it "passes if any number of times method is called once" do
|
16
|
+
@mock.should_receive(:random_call).any_number_of_times
|
17
|
+
@mock.random_call
|
18
|
+
end
|
26
19
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@mock.message.should == :mock_value
|
31
|
-
@mock.message.should == :mock_value
|
32
|
-
end
|
33
|
-
end
|
20
|
+
it "passes if any number of times method is not called" do
|
21
|
+
@mock.should_receive(:random_call).any_number_of_times
|
22
|
+
end
|
34
23
|
|
24
|
+
it "returns the mocked value when called after a similar stub" do
|
25
|
+
@mock.stub(:message).and_return :stub_value
|
26
|
+
@mock.should_receive(:message).any_number_of_times.and_return(:mock_value)
|
27
|
+
@mock.message.should == :mock_value
|
28
|
+
@mock.message.should == :mock_value
|
35
29
|
end
|
36
30
|
end
|
@@ -92,6 +92,12 @@ module RSpec
|
|
92
92
|
@mock.random_call
|
93
93
|
@mock.rspec_verify
|
94
94
|
end
|
95
|
+
|
96
|
+
it "returns the value given by a block when the at least once method is called" do
|
97
|
+
@mock.should_receive(:to_s).at_least(:once) { "testing" }
|
98
|
+
@mock.to_s.should == "testing"
|
99
|
+
@mock.rspec_verify
|
100
|
+
end
|
95
101
|
end
|
96
102
|
end
|
97
103
|
end
|
@@ -88,6 +88,12 @@ module RSpec
|
|
88
88
|
@mock.should_receive(:random_call).at_most(:twice)
|
89
89
|
@mock.rspec_verify
|
90
90
|
end
|
91
|
+
|
92
|
+
it "returns the value given by a block when the at most once method is called" do
|
93
|
+
@mock.should_receive(:to_s).at_most(:once) { "testing" }
|
94
|
+
@mock.to_s.should == "testing"
|
95
|
+
@mock.rspec_verify
|
96
|
+
end
|
91
97
|
end
|
92
98
|
end
|
93
99
|
end
|
@@ -1,26 +1,24 @@
|
|
1
|
-
describe "
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@double.should_receive(:msg) do |b|
|
8
|
-
b.should be_true #this call exposes the problem
|
1
|
+
describe "Double" do
|
2
|
+
let(:test_double) { double }
|
3
|
+
|
4
|
+
specify "when one example has an expectation inside the block passed to should_receive" do
|
5
|
+
test_double.should_receive(:msg) do |arg|
|
6
|
+
arg.should be_true #this call exposes the problem
|
9
7
|
end
|
10
8
|
begin
|
11
|
-
|
9
|
+
test_double.msg(false)
|
12
10
|
rescue Exception
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
14
|
specify "then the next example should behave as expected instead of saying" do
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
test_double.should_receive(:foobar)
|
16
|
+
test_double.foobar
|
17
|
+
test_double.rspec_verify
|
20
18
|
begin
|
21
|
-
|
19
|
+
test_double.foobar
|
22
20
|
rescue Exception => e
|
23
|
-
e.message.should == "Double
|
21
|
+
e.message.should == "Double received unexpected message :foobar with (no args)"
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
@@ -4,93 +4,92 @@ module RSpec
|
|
4
4
|
module Mocks
|
5
5
|
describe "failing MockArgumentMatchers" do
|
6
6
|
before(:each) do
|
7
|
-
@
|
8
|
-
@reporter =
|
7
|
+
@double = double("double")
|
8
|
+
@reporter = double("reporter").as_null_object
|
9
9
|
end
|
10
10
|
|
11
11
|
after(:each) do
|
12
|
-
@
|
12
|
+
@double.rspec_reset
|
13
13
|
end
|
14
14
|
|
15
15
|
it "rejects non boolean" do
|
16
|
-
@
|
17
|
-
|
18
|
-
@
|
19
|
-
end.
|
16
|
+
@double.should_receive(:random_call).with(boolean())
|
17
|
+
expect do
|
18
|
+
@double.random_call("false")
|
19
|
+
end.to raise_error(RSpec::Mocks::MockExpectationError)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "rejects non numeric" do
|
23
|
-
@
|
24
|
-
|
25
|
-
@
|
26
|
-
end.
|
23
|
+
@double.should_receive(:random_call).with(an_instance_of(Numeric))
|
24
|
+
expect do
|
25
|
+
@double.random_call("1")
|
26
|
+
end.to raise_error(RSpec::Mocks::MockExpectationError)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "rejects non string" do
|
30
|
-
@
|
31
|
-
|
32
|
-
@
|
33
|
-
end.
|
30
|
+
@double.should_receive(:random_call).with(an_instance_of(String))
|
31
|
+
expect do
|
32
|
+
@double.random_call(123)
|
33
|
+
end.to raise_error(RSpec::Mocks::MockExpectationError)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "rejects goose when expecting a duck" do
|
37
|
-
@
|
38
|
-
|
37
|
+
@double.should_receive(:random_call).with(duck_type(:abs, :div))
|
38
|
+
expect { @double.random_call("I don't respond to :abs or :div") }.to raise_error(RSpec::Mocks::MockExpectationError)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "fails if regexp does not match submitted string" do
|
42
|
-
@
|
43
|
-
|
42
|
+
@double.should_receive(:random_call).with(/bcd/)
|
43
|
+
expect { @double.random_call("abc") }.to raise_error(RSpec::Mocks::MockExpectationError)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "fails if regexp does not match submitted regexp" do
|
47
|
-
@
|
48
|
-
|
47
|
+
@double.should_receive(:random_call).with(/bcd/)
|
48
|
+
expect { @double.random_call(/bcde/) }.to raise_error(RSpec::Mocks::MockExpectationError)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "fails for a hash w/ wrong values" do
|
52
|
-
@
|
53
|
-
|
54
|
-
@
|
55
|
-
end.
|
52
|
+
@double.should_receive(:random_call).with(:a => "b", :c => "d")
|
53
|
+
expect do
|
54
|
+
@double.random_call(:a => "b", :c => "e")
|
55
|
+
end.to raise_error(RSpec::Mocks::MockExpectationError, /Double "double" received :random_call with unexpected arguments\n expected: \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\)\n got: \(\{(:a=>\"b\", :c=>\"e\"|:c=>\"e\", :a=>\"b\")\}\)/)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "fails for a hash w/ wrong keys" do
|
59
|
-
@
|
60
|
-
|
61
|
-
@
|
62
|
-
end.
|
59
|
+
@double.should_receive(:random_call).with(:a => "b", :c => "d")
|
60
|
+
expect do
|
61
|
+
@double.random_call("a" => "b", "c" => "d")
|
62
|
+
end.to raise_error(RSpec::Mocks::MockExpectationError, /Double "double" received :random_call with unexpected arguments\n expected: \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\)\n got: \(\{(\"a\"=>\"b\", \"c\"=>\"d\"|\"c\"=>\"d\", \"a\"=>\"b\")\}\)/)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "matches against a Matcher" do
|
66
|
-
|
67
|
-
@
|
68
|
-
@
|
69
|
-
end.
|
66
|
+
expect do
|
67
|
+
@double.should_receive(:msg).with(equal(3))
|
68
|
+
@double.msg(37)
|
69
|
+
end.to raise_error(RSpec::Mocks::MockExpectationError, "Double \"double\" received :msg with unexpected arguments\n expected: (equal 3)\n got: (37)")
|
70
70
|
end
|
71
71
|
|
72
72
|
it "fails no_args with one arg" do
|
73
|
-
|
74
|
-
@
|
75
|
-
@
|
76
|
-
end.
|
73
|
+
expect do
|
74
|
+
@double.should_receive(:msg).with(no_args)
|
75
|
+
@double.msg(37)
|
76
|
+
end.to raise_error(RSpec::Mocks::MockExpectationError, "Double \"double\" received :msg with unexpected arguments\n expected: (no args)\n got: (37)")
|
77
77
|
end
|
78
78
|
|
79
79
|
it "fails hash_including with missing key" do
|
80
|
-
|
81
|
-
@
|
82
|
-
@
|
83
|
-
end.
|
80
|
+
expect do
|
81
|
+
@double.should_receive(:msg).with(hash_including(:a => 1))
|
82
|
+
@double.msg({})
|
83
|
+
end.to raise_error(RSpec::Mocks::MockExpectationError, "Double \"double\" received :msg with unexpected arguments\n expected: (hash_including(:a=>1))\n got: ({})")
|
84
84
|
end
|
85
85
|
|
86
86
|
it "fails with block matchers" do
|
87
|
-
|
88
|
-
@
|
89
|
-
@
|
90
|
-
end.
|
87
|
+
expect do
|
88
|
+
@double.should_receive(:msg).with {|arg| arg.should == :received }
|
89
|
+
@double.msg :no_msg_for_you
|
90
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected: :received.*\s*.*got: :no_msg_for_you/)
|
91
91
|
end
|
92
92
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
96
|
-
|
@@ -13,9 +13,8 @@ module RSpec
|
|
13
13
|
module Mocks
|
14
14
|
|
15
15
|
describe "an expectation set on nil" do
|
16
|
-
|
17
16
|
it "issues a warning with file and line number information" do
|
18
|
-
expected_warning = %r%An expectation of :foo was set on nil. Called from #{__FILE__}:#{__LINE__+3}(:in
|
17
|
+
expected_warning = %r%An expectation of :foo was set on nil. Called from #{__FILE__}:#{__LINE__+3}(:in .+)?. Use allow_message_expectations_on_nil to disable warnings.%
|
19
18
|
Kernel.should_receive(:warn).with(expected_warning)
|
20
19
|
|
21
20
|
nil.should_receive(:foo)
|
@@ -1,144 +1,141 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
def include_mock_argument_matchers
|
4
|
-
before(:each) do
|
5
|
-
@mock = RSpec::Mocks::Mock.new("test mock")
|
6
|
-
Kernel.stub(:warn)
|
7
|
-
end
|
8
|
-
|
9
|
-
after(:each) do
|
10
|
-
@mock.rspec_verify
|
11
|
-
end
|
12
|
-
end
|
13
3
|
module RSpec
|
14
4
|
module Mocks
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
it "accepts true as boolean()" do
|
20
|
-
@mock.should_receive(:random_call).with(boolean())
|
21
|
-
@mock.random_call(true)
|
5
|
+
describe Methods do
|
6
|
+
before(:each) do
|
7
|
+
@double = double('double')
|
8
|
+
Kernel.stub(:warn)
|
22
9
|
end
|
23
10
|
|
24
|
-
|
25
|
-
@
|
26
|
-
@mock.random_call(false)
|
11
|
+
after(:each) do
|
12
|
+
@double.rspec_verify
|
27
13
|
end
|
28
14
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
15
|
+
context "handling argument matchers" do
|
16
|
+
it "accepts true as boolean()" do
|
17
|
+
@double.should_receive(:random_call).with(boolean())
|
18
|
+
@double.random_call(true)
|
19
|
+
end
|
33
20
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
it "accepts fixnum as instance_of(Fixnum)" do
|
40
|
-
@mock.should_receive(:random_call).with(instance_of(Fixnum))
|
41
|
-
@mock.random_call(1)
|
42
|
-
end
|
21
|
+
it "accepts false as boolean()" do
|
22
|
+
@double.should_receive(:random_call).with(boolean())
|
23
|
+
@double.random_call(false)
|
24
|
+
end
|
43
25
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
26
|
+
it "accepts fixnum as kind_of(Numeric)" do
|
27
|
+
@double.should_receive(:random_call).with(kind_of(Numeric))
|
28
|
+
@double.random_call(1)
|
29
|
+
end
|
48
30
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
31
|
+
it "accepts float as an_instance_of(Numeric)" do
|
32
|
+
@double.should_receive(:random_call).with(kind_of(Numeric))
|
33
|
+
@double.random_call(1.5)
|
34
|
+
end
|
53
35
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
36
|
+
it "accepts fixnum as instance_of(Fixnum)" do
|
37
|
+
@double.should_receive(:random_call).with(instance_of(Fixnum))
|
38
|
+
@double.random_call(1)
|
39
|
+
end
|
58
40
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
41
|
+
it "does NOT accept fixnum as instance_of(Numeric)" do
|
42
|
+
@double.should_not_receive(:random_call).with(instance_of(Numeric))
|
43
|
+
@double.random_call(1)
|
44
|
+
end
|
63
45
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
it "matches no args against any_args()" do
|
70
|
-
@mock.should_receive(:random_call).with(any_args)
|
71
|
-
@mock.random_call()
|
72
|
-
end
|
73
|
-
|
74
|
-
it "matches one arg against any_args()" do
|
75
|
-
@mock.should_receive(:random_call).with(any_args)
|
76
|
-
@mock.random_call("a string")
|
77
|
-
end
|
78
|
-
|
79
|
-
it "matches no args against no_args()" do
|
80
|
-
@mock.should_receive(:random_call).with(no_args)
|
81
|
-
@mock.random_call()
|
82
|
-
end
|
83
|
-
|
84
|
-
it "matches hash with hash_including same hash" do
|
85
|
-
@mock.should_receive(:random_call).with(hash_including(:a => 1))
|
86
|
-
@mock.random_call(:a => 1)
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
46
|
+
it "does NOT accept float as instance_of(Numeric)" do
|
47
|
+
@double.should_not_receive(:random_call).with(instance_of(Numeric))
|
48
|
+
@double.random_call(1.5)
|
49
|
+
end
|
90
50
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
@mock.should_receive(:random_call).with {|arg1, arg2, arr, *rest|
|
96
|
-
arg1.should == 5
|
97
|
-
arg2.should have_at_least(3).characters
|
98
|
-
arg2.should have_at_most(10).characters
|
99
|
-
arr.map {|i| i * 2}.should == [2,4,6]
|
100
|
-
rest.should == [:fee, "fi", 4]
|
101
|
-
}
|
102
|
-
@mock.random_call 5, "hello", [1,2,3], :fee, "fi", 4
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe Methods, "handling non-matcher arguments" do
|
107
|
-
|
108
|
-
before(:each) do
|
109
|
-
@mock = RSpec::Mocks::Mock.new("test mock")
|
110
|
-
end
|
111
|
-
|
112
|
-
it "matches non special symbol (can be removed when deprecated symbols are removed)" do
|
113
|
-
@mock.should_receive(:random_call).with(:some_symbol)
|
114
|
-
@mock.random_call(:some_symbol)
|
115
|
-
end
|
51
|
+
it "accepts string as anything()" do
|
52
|
+
@double.should_receive(:random_call).with("a", anything(), "c")
|
53
|
+
@double.random_call("a", "whatever", "c")
|
54
|
+
end
|
116
55
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
56
|
+
it "matches duck type with one method" do
|
57
|
+
@double.should_receive(:random_call).with(duck_type(:length))
|
58
|
+
@double.random_call([])
|
59
|
+
end
|
121
60
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
61
|
+
it "matches duck type with two methods" do
|
62
|
+
@double.should_receive(:random_call).with(duck_type(:abs, :div))
|
63
|
+
@double.random_call(1)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "matches no args against any_args()" do
|
67
|
+
@double.should_receive(:random_call).with(any_args)
|
68
|
+
@double.random_call()
|
69
|
+
end
|
70
|
+
|
71
|
+
it "matches one arg against any_args()" do
|
72
|
+
@double.should_receive(:random_call).with(any_args)
|
73
|
+
@double.random_call("a string")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "matches no args against no_args()" do
|
77
|
+
@double.should_receive(:random_call).with(no_args)
|
78
|
+
@double.random_call()
|
79
|
+
end
|
80
|
+
|
81
|
+
it "matches hash with hash_including same hash" do
|
82
|
+
@double.should_receive(:random_call).with(hash_including(:a => 1))
|
83
|
+
@double.random_call(:a => 1)
|
84
|
+
end
|
130
85
|
end
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
86
|
+
|
87
|
+
context "handling block matchers" do
|
88
|
+
it "matches arguments against RSpec expectations" do
|
89
|
+
@double.should_receive(:random_call).with {|arg1, arg2, arr, *rest|
|
90
|
+
arg1.should == 5
|
91
|
+
arg2.should have_at_least(3).characters
|
92
|
+
arg2.should have_at_most(10).characters
|
93
|
+
arr.map {|i| i * 2}.should == [2,4,6]
|
94
|
+
rest.should == [:fee, "fi", 4]
|
95
|
+
}
|
96
|
+
@double.random_call 5, "hello", [1,2,3], :fee, "fi", 4
|
97
|
+
end
|
98
|
+
|
99
|
+
it "does not eval the block as the return value" do
|
100
|
+
eval_count = 0
|
101
|
+
@double.should_receive(:msg).with {|a| eval_count += 1}
|
102
|
+
@double.msg(:ignore)
|
103
|
+
eval_count.should eq(1)
|
104
|
+
end
|
136
105
|
end
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
106
|
+
|
107
|
+
context "handling non-matcher arguments" do
|
108
|
+
it "matches non special symbol (can be removed when deprecated symbols are removed)" do
|
109
|
+
@double.should_receive(:random_call).with(:some_symbol)
|
110
|
+
@double.random_call(:some_symbol)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "matches string against regexp" do
|
114
|
+
@double.should_receive(:random_call).with(/bcd/)
|
115
|
+
@double.random_call("abcde")
|
116
|
+
end
|
117
|
+
|
118
|
+
it "matches regexp against regexp" do
|
119
|
+
@double.should_receive(:random_call).with(/bcd/)
|
120
|
+
@double.random_call(/bcd/)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "matches against a hash submitted and received by value" do
|
124
|
+
@double.should_receive(:random_call).with(:a => "a", :b => "b")
|
125
|
+
@double.random_call(:a => "a", :b => "b")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "matches against a hash submitted by reference and received by value" do
|
129
|
+
opts = {:a => "a", :b => "b"}
|
130
|
+
@double.should_receive(:random_call).with(opts)
|
131
|
+
@double.random_call(:a => "a", :b => "b")
|
132
|
+
end
|
133
|
+
|
134
|
+
it "matches against a hash submitted by value and received by reference" do
|
135
|
+
opts = {:a => "a", :b => "b"}
|
136
|
+
@double.should_receive(:random_call).with(:a => "a", :b => "b")
|
137
|
+
@double.random_call(opts)
|
138
|
+
end
|
142
139
|
end
|
143
140
|
end
|
144
141
|
end
|