rspec-mocks 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.
- data/.gitignore +1 -0
- data/Rakefile +0 -7
- data/VERSION +1 -1
- data/lib/rspec/mocks/argument_expectation.rb +7 -10
- data/lib/rspec/mocks/extensions/instance_exec.rb +3 -3
- data/lib/rspec/mocks/message_expectation.rb +26 -26
- data/lib/rspec/mocks/methods.rb +22 -6
- data/lib/rspec/mocks/mock.rb +3 -3
- data/lib/rspec/mocks/proxy.rb +10 -10
- data/rspec-mocks.gemspec +9 -15
- data/spec/rspec/mocks/any_number_of_times_spec.rb +4 -4
- data/spec/rspec/mocks/argument_expectation_spec.rb +4 -4
- data/spec/rspec/mocks/at_least_spec.rb +11 -11
- data/spec/rspec/mocks/at_most_spec.rb +11 -11
- data/spec/rspec/mocks/bug_report_10260_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_11545_spec.rb +3 -3
- data/spec/rspec/mocks/bug_report_15719_spec.rb +2 -2
- data/spec/rspec/mocks/bug_report_600_spec.rb +2 -2
- data/spec/rspec/mocks/bug_report_7611_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_8165_spec.rb +2 -2
- data/spec/rspec/mocks/bug_report_957_spec.rb +2 -2
- data/spec/rspec/mocks/failing_argument_matchers_spec.rb +12 -12
- data/spec/rspec/mocks/hash_including_matcher_spec.rb +18 -18
- data/spec/rspec/mocks/hash_not_including_matcher_spec.rb +13 -13
- data/spec/rspec/mocks/mock_ordering_spec.rb +7 -7
- data/spec/rspec/mocks/mock_space_spec.rb +4 -4
- data/spec/rspec/mocks/mock_spec.rb +65 -65
- data/spec/rspec/mocks/multiple_return_value_spec.rb +11 -11
- data/spec/rspec/mocks/nil_expectation_warning_spec.rb +4 -4
- data/spec/rspec/mocks/null_object_mock_spec.rb +7 -7
- data/spec/rspec/mocks/once_counts_spec.rb +6 -6
- data/spec/rspec/mocks/options_hash_spec.rb +3 -3
- data/spec/rspec/mocks/partial_mock_spec.rb +17 -17
- data/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb +1 -1
- data/spec/rspec/mocks/passing_argument_matchers_spec.rb +20 -20
- data/spec/rspec/mocks/precise_counts_spec.rb +5 -5
- data/spec/rspec/mocks/record_messages_spec.rb +4 -4
- data/spec/rspec/mocks/stash_spec.rb +1 -1
- data/spec/rspec/mocks/stub_chain_spec.rb +13 -0
- data/spec/rspec/mocks/stub_implementation_spec.rb +4 -4
- data/spec/rspec/mocks/stub_spec.rb +26 -26
- data/spec/spec_helper.rb +2 -2
- data/spec/support/macros.rb +2 -2
- metadata +17 -27
@@ -9,14 +9,14 @@ module RSpec
|
|
9
9
|
@mock.should_receive(:message).and_return(@return_values[0],@return_values[1],@return_values[2])
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "returns values in order to consecutive calls" do
|
13
13
|
@mock.message.should == @return_values[0]
|
14
14
|
@mock.message.should == @return_values[1]
|
15
15
|
@mock.message.should == @return_values[2]
|
16
16
|
@mock.rspec_verify
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "complains when there are too few calls" do
|
20
20
|
@mock.message.should == @return_values[0]
|
21
21
|
@mock.message.should == @return_values[1]
|
22
22
|
expect { @mock.rspec_verify }.to raise_error(
|
@@ -25,7 +25,7 @@ module RSpec
|
|
25
25
|
)
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "complains when there are too many calls" do
|
29
29
|
@mock.message.should == @return_values[0]
|
30
30
|
@mock.message.should == @return_values[1]
|
31
31
|
@mock.message.should == @return_values[2]
|
@@ -44,14 +44,14 @@ module RSpec
|
|
44
44
|
@mock.should_receive(:message).exactly(3).times.and_return(@return_values[0],@return_values[1],@return_values[2])
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
47
|
+
it "returns values in order to consecutive calls" do
|
48
48
|
@mock.message.should == @return_values[0]
|
49
49
|
@mock.message.should == @return_values[1]
|
50
50
|
@mock.message.should == @return_values[2]
|
51
51
|
@mock.rspec_verify
|
52
52
|
end
|
53
53
|
|
54
|
-
it "
|
54
|
+
it "complains when there are too few calls" do
|
55
55
|
third = Object.new
|
56
56
|
@mock.message.should == @return_values[0]
|
57
57
|
@mock.message.should == @return_values[1]
|
@@ -61,7 +61,7 @@ module RSpec
|
|
61
61
|
)
|
62
62
|
end
|
63
63
|
|
64
|
-
it "
|
64
|
+
it "complains when there are too many calls" do
|
65
65
|
third = Object.new
|
66
66
|
@mock.message.should == @return_values[0]
|
67
67
|
@mock.message.should == @return_values[1]
|
@@ -80,14 +80,14 @@ module RSpec
|
|
80
80
|
@mock.should_receive(:message).at_least(:twice).with(no_args).and_return(11, 22)
|
81
81
|
end
|
82
82
|
|
83
|
-
it "
|
83
|
+
it "uses the last return value for subsequent calls" do
|
84
84
|
@mock.message.should equal(11)
|
85
85
|
@mock.message.should equal(22)
|
86
86
|
@mock.message.should equal(22)
|
87
87
|
@mock.rspec_verify
|
88
88
|
end
|
89
89
|
|
90
|
-
it "
|
90
|
+
it "fails when called less than the specified number" do
|
91
91
|
@mock.message.should equal(11)
|
92
92
|
expect { @mock.rspec_verify }.to raise_error(
|
93
93
|
RSpec::Mocks::MockExpectationError,
|
@@ -102,14 +102,14 @@ module RSpec
|
|
102
102
|
@mock.should_receive(:message).exactly(3).times.and_return(11, 22)
|
103
103
|
end
|
104
104
|
|
105
|
-
it "
|
105
|
+
it "uses the last return value for subsequent calls" do
|
106
106
|
@mock.message.should equal(11)
|
107
107
|
@mock.message.should equal(22)
|
108
108
|
@mock.message.should equal(22)
|
109
109
|
@mock.rspec_verify
|
110
110
|
end
|
111
111
|
|
112
|
-
it "
|
112
|
+
it "fails when called less than the specified number" do
|
113
113
|
@mock.message.should equal(11)
|
114
114
|
expect { @mock.rspec_verify }.to raise_error(
|
115
115
|
RSpec::Mocks::MockExpectationError,
|
@@ -117,7 +117,7 @@ module RSpec
|
|
117
117
|
)
|
118
118
|
end
|
119
119
|
|
120
|
-
it "
|
120
|
+
it "fails when called greater than the specified number" do
|
121
121
|
@mock.message.should equal(11)
|
122
122
|
@mock.message.should equal(22)
|
123
123
|
@mock.message.should equal(22)
|
@@ -14,7 +14,7 @@ module RSpec
|
|
14
14
|
|
15
15
|
describe "an expectation set on nil" do
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "issues a warning with file and line number information" do
|
18
18
|
expected_warning = %r%An expectation of :foo was set on nil. Called from #{__FILE__}:#{__LINE__+3}(:in `block \(2 levels\) in <module:Mocks>')?. Use allow_message_expectations_on_nil to disable warnings.%
|
19
19
|
Kernel.should_receive(:warn).with(expected_warning)
|
20
20
|
|
@@ -22,13 +22,13 @@ module RSpec
|
|
22
22
|
nil.foo
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
25
|
+
it "issues a warning when the expectation is negative" do
|
26
26
|
Kernel.should_receive(:warn)
|
27
27
|
|
28
28
|
nil.should_not_receive(:foo)
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "does not issue a warning when expectations are set to be allowed" do
|
32
32
|
allow_message_expectations_on_nil
|
33
33
|
Kernel.should_not_receive(:warn)
|
34
34
|
|
@@ -42,7 +42,7 @@ module RSpec
|
|
42
42
|
describe "#allow_message_expectations_on_nil" do
|
43
43
|
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "does not effect subsequent examples" do
|
46
46
|
example_group = empty_example_group
|
47
47
|
example_group.it("when called in one example that doesn't end up setting an expectation on nil") do
|
48
48
|
allow_message_expectations_on_nil
|
@@ -7,30 +7,30 @@ module RSpec
|
|
7
7
|
@mock = RSpec::Mocks::Mock.new("null_object").as_null_object
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
10
|
+
it "allows explicit expectation" do
|
11
11
|
@mock.should_receive(:something)
|
12
12
|
@mock.something
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "fails verification when explicit exception not met" do
|
16
16
|
lambda do
|
17
17
|
@mock.should_receive(:something)
|
18
18
|
@mock.rspec_verify
|
19
19
|
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
22
|
+
it "ignores unexpected methods" do
|
23
23
|
@mock.random_call("a", "d", "c")
|
24
24
|
@mock.rspec_verify
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "allows expected message with different args first" do
|
28
28
|
@mock.should_receive(:message).with(:expected_arg)
|
29
29
|
@mock.message(:unexpected_arg)
|
30
30
|
@mock.message(:expected_arg)
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
33
|
+
it "allows expected message with different args second" do
|
34
34
|
@mock.should_receive(:message).with(:expected_arg)
|
35
35
|
@mock.message(:expected_arg)
|
36
36
|
@mock.message(:unexpected_arg)
|
@@ -38,14 +38,14 @@ module RSpec
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "#null_object?" do
|
41
|
-
it "
|
41
|
+
it "defaults to false" do
|
42
42
|
obj = double('anything')
|
43
43
|
obj.should_not be_null_object
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "#as_null_object" do
|
48
|
-
it "
|
48
|
+
it "sets the object to null_object" do
|
49
49
|
obj = double('anything').as_null_object
|
50
50
|
obj.should be_null_object
|
51
51
|
end
|
@@ -7,7 +7,7 @@ module RSpec
|
|
7
7
|
@mock = double("test mock")
|
8
8
|
end
|
9
9
|
|
10
|
-
it "once
|
10
|
+
it "once fails when called once with wrong args" do
|
11
11
|
@mock.should_receive(:random_call).once.with("a", "b", "c")
|
12
12
|
lambda do
|
13
13
|
@mock.random_call("d", "e", "f")
|
@@ -15,7 +15,7 @@ module RSpec
|
|
15
15
|
@mock.rspec_reset
|
16
16
|
end
|
17
17
|
|
18
|
-
it "once
|
18
|
+
it "once fails when called twice" do
|
19
19
|
@mock.should_receive(:random_call).once
|
20
20
|
@mock.random_call
|
21
21
|
@mock.random_call
|
@@ -24,26 +24,26 @@ module RSpec
|
|
24
24
|
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
25
25
|
end
|
26
26
|
|
27
|
-
it "once
|
27
|
+
it "once fails when not called" do
|
28
28
|
@mock.should_receive(:random_call).once
|
29
29
|
lambda do
|
30
30
|
@mock.rspec_verify
|
31
31
|
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
32
32
|
end
|
33
33
|
|
34
|
-
it "once
|
34
|
+
it "once passes when called once" do
|
35
35
|
@mock.should_receive(:random_call).once
|
36
36
|
@mock.random_call
|
37
37
|
@mock.rspec_verify
|
38
38
|
end
|
39
39
|
|
40
|
-
it "once
|
40
|
+
it "once passes when called once with specified args" do
|
41
41
|
@mock.should_receive(:random_call).once.with("a", "b", "c")
|
42
42
|
@mock.random_call("a", "b", "c")
|
43
43
|
@mock.rspec_verify
|
44
44
|
end
|
45
45
|
|
46
|
-
it "once
|
46
|
+
it "once passes when called once with unspecified args" do
|
47
47
|
@mock.should_receive(:random_call).once
|
48
48
|
@mock.random_call("a", "b", "c")
|
49
49
|
@mock.rspec_verify
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module RSpec
|
4
4
|
module Mocks
|
5
5
|
describe "calling :should_receive with an options hash" do
|
6
|
-
it "
|
6
|
+
it "reports the file and line submitted with :expected_from" do
|
7
7
|
begin
|
8
8
|
mock = RSpec::Mocks::Mock.new("a mock")
|
9
9
|
mock.should_receive(:message, :expected_from => "/path/to/blah.ext:37")
|
@@ -14,7 +14,7 @@ module RSpec
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "uses the message supplied with :message" do
|
18
18
|
lambda {
|
19
19
|
m = RSpec::Mocks::Mock.new("a mock")
|
20
20
|
m.should_receive(:message, :message => "recebi nada")
|
@@ -22,7 +22,7 @@ module RSpec
|
|
22
22
|
}.should raise_error("recebi nada")
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
25
|
+
it "uses the message supplied with :message after a similar stub" do
|
26
26
|
lambda {
|
27
27
|
m = RSpec::Mocks::Mock.new("a mock")
|
28
28
|
m.stub(:message)
|
@@ -7,27 +7,27 @@ module RSpec
|
|
7
7
|
@object = Object.new
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
10
|
+
it "names the class in the failure message" do
|
11
11
|
@object.should_receive(:foo)
|
12
12
|
expect do
|
13
13
|
@object.rspec_verify
|
14
14
|
end.to raise_error(RSpec::Mocks::MockExpectationError, /\(#<Object:.*>\).foo/)
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "names the class in the failure message when expectation is on class" do
|
18
18
|
Object.should_receive(:foo)
|
19
19
|
lambda do
|
20
20
|
Object.rspec_verify
|
21
21
|
end.should raise_error(RSpec::Mocks::MockExpectationError, /<Object \(class\)>/)
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
24
|
+
it "does not conflict with @options in the object" do
|
25
25
|
@object.instance_eval { @options = Object.new }
|
26
26
|
@object.should_receive(:blah)
|
27
27
|
@object.blah
|
28
28
|
end
|
29
29
|
|
30
|
-
it "should_not_receive
|
30
|
+
it "should_not_receive mocks out the method" do
|
31
31
|
@object.should_not_receive(:fuhbar)
|
32
32
|
expect {
|
33
33
|
@object.fuhbar
|
@@ -37,51 +37,51 @@ module RSpec
|
|
37
37
|
)
|
38
38
|
end
|
39
39
|
|
40
|
-
it "should_not_receive
|
40
|
+
it "should_not_receive returns a negative message expectation" do
|
41
41
|
@object.should_not_receive(:foobar).should be_kind_of(RSpec::Mocks::NegativeMessageExpectation)
|
42
42
|
end
|
43
43
|
|
44
|
-
it "should_receive
|
44
|
+
it "should_receive mocks out the method" do
|
45
45
|
@object.should_receive(:foobar).with(:test_param).and_return(1)
|
46
46
|
@object.foobar(:test_param).should equal(1)
|
47
47
|
end
|
48
48
|
|
49
|
-
it "should_receive
|
49
|
+
it "should_receive handles a hash" do
|
50
50
|
@object.should_receive(:foobar).with(:key => "value").and_return(1)
|
51
51
|
@object.foobar(:key => "value").should equal(1)
|
52
52
|
end
|
53
53
|
|
54
|
-
it "should_receive
|
54
|
+
it "should_receive handles an inner hash" do
|
55
55
|
hash = {:a => {:key => "value"}}
|
56
56
|
@object.should_receive(:foobar).with(:key => "value").and_return(1)
|
57
57
|
@object.foobar(hash[:a]).should equal(1)
|
58
58
|
end
|
59
59
|
|
60
|
-
it "should_receive
|
60
|
+
it "should_receive returns a message expectation" do
|
61
61
|
@object.should_receive(:foobar).should be_kind_of(RSpec::Mocks::MessageExpectation)
|
62
62
|
@object.foobar
|
63
63
|
end
|
64
64
|
|
65
|
-
it "should_receive
|
65
|
+
it "should_receive verifies method was called" do
|
66
66
|
@object.should_receive(:foobar).with(:test_param).and_return(1)
|
67
67
|
lambda do
|
68
68
|
@object.rspec_verify
|
69
69
|
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
70
70
|
end
|
71
71
|
|
72
|
-
it "should_receive
|
72
|
+
it "should_receive also takes a String argument" do
|
73
73
|
@object.should_receive('foobar')
|
74
74
|
@object.foobar
|
75
75
|
end
|
76
76
|
|
77
|
-
it "should_not_receive
|
77
|
+
it "should_not_receive also takes a String argument" do
|
78
78
|
@object.should_not_receive('foobar')
|
79
79
|
lambda do
|
80
80
|
@object.foobar
|
81
81
|
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
82
82
|
end
|
83
83
|
|
84
|
-
it "
|
84
|
+
it "uses reports nil in the error message" do
|
85
85
|
allow_message_expectations_on_nil
|
86
86
|
|
87
87
|
@this_will_resolve_to_nil.should_receive(:foobar)
|
@@ -110,7 +110,7 @@ module RSpec
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
it "
|
113
|
+
it "does not raise an error when stubbing the object" do
|
114
114
|
o = PartiallyMockedEquals.new :foo
|
115
115
|
lambda { o.stub(:bar) }.should_not raise_error(NoMethodError)
|
116
116
|
end
|
@@ -132,7 +132,7 @@ module RSpec
|
|
132
132
|
@object = MockableClass.new
|
133
133
|
end
|
134
134
|
|
135
|
-
it '
|
135
|
+
it 'keeps public methods public' do
|
136
136
|
@object.should_receive(:public_method)
|
137
137
|
with_ruby('1.9') do
|
138
138
|
@object.public_methods.should include(:public_method)
|
@@ -143,7 +143,7 @@ module RSpec
|
|
143
143
|
@object.public_method
|
144
144
|
end
|
145
145
|
|
146
|
-
it '
|
146
|
+
it 'keeps private methods private' do
|
147
147
|
@object.should_receive(:private_method)
|
148
148
|
with_ruby('1.9') do
|
149
149
|
@object.private_methods.should include(:private_method)
|
@@ -154,7 +154,7 @@ module RSpec
|
|
154
154
|
@object.public_method
|
155
155
|
end
|
156
156
|
|
157
|
-
it '
|
157
|
+
it 'keeps protected methods protected' do
|
158
158
|
@object.should_receive(:protected_method)
|
159
159
|
with_ruby('1.9') do
|
160
160
|
@object.protected_methods.should include(:protected_method)
|
@@ -63,7 +63,7 @@ module RSpec::Mocks
|
|
63
63
|
obj.rspec_verify
|
64
64
|
end
|
65
65
|
|
66
|
-
it "
|
66
|
+
it "restores the original method if it existed" do
|
67
67
|
obj.existing_method.should equal(:original_value)
|
68
68
|
obj.should_receive(:existing_method).and_return(:mock_value)
|
69
69
|
obj.existing_method.should equal(:mock_value)
|
@@ -16,22 +16,22 @@ module RSpec
|
|
16
16
|
describe Methods, "handling argument matchers" do
|
17
17
|
include_mock_argument_matchers
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "accepts true as boolean()" do
|
20
20
|
@mock.should_receive(:random_call).with(boolean())
|
21
21
|
@mock.random_call(true)
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
24
|
+
it "accepts false as boolean()" do
|
25
25
|
@mock.should_receive(:random_call).with(boolean())
|
26
26
|
@mock.random_call(false)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "accepts fixnum as kind_of(Numeric)" do
|
30
30
|
@mock.should_receive(:random_call).with(kind_of(Numeric))
|
31
31
|
@mock.random_call(1)
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "accepts float as an_instance_of(Numeric)" do
|
35
35
|
@mock.should_receive(:random_call).with(kind_of(Numeric))
|
36
36
|
@mock.random_call(1.5)
|
37
37
|
end
|
@@ -41,47 +41,47 @@ module RSpec
|
|
41
41
|
@mock.random_call(1)
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "does NOT accept fixnum as instance_of(Numeric)" do
|
45
45
|
@mock.should_not_receive(:random_call).with(instance_of(Numeric))
|
46
46
|
@mock.random_call(1)
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "does NOT accept float as instance_of(Numeric)" do
|
50
50
|
@mock.should_not_receive(:random_call).with(instance_of(Numeric))
|
51
51
|
@mock.random_call(1.5)
|
52
52
|
end
|
53
53
|
|
54
|
-
it "
|
54
|
+
it "accepts string as anything()" do
|
55
55
|
@mock.should_receive(:random_call).with("a", anything(), "c")
|
56
56
|
@mock.random_call("a", "whatever", "c")
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
59
|
+
it "matches duck type with one method" do
|
60
60
|
@mock.should_receive(:random_call).with(duck_type(:length))
|
61
61
|
@mock.random_call([])
|
62
62
|
end
|
63
63
|
|
64
|
-
it "
|
64
|
+
it "matches duck type with two methods" do
|
65
65
|
@mock.should_receive(:random_call).with(duck_type(:abs, :div))
|
66
66
|
@mock.random_call(1)
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
69
|
+
it "matches no args against any_args()" do
|
70
70
|
@mock.should_receive(:random_call).with(any_args)
|
71
71
|
@mock.random_call()
|
72
72
|
end
|
73
73
|
|
74
|
-
it "
|
74
|
+
it "matches one arg against any_args()" do
|
75
75
|
@mock.should_receive(:random_call).with(any_args)
|
76
76
|
@mock.random_call("a string")
|
77
77
|
end
|
78
78
|
|
79
|
-
it "
|
79
|
+
it "matches no args against no_args()" do
|
80
80
|
@mock.should_receive(:random_call).with(no_args)
|
81
81
|
@mock.random_call()
|
82
82
|
end
|
83
83
|
|
84
|
-
it "
|
84
|
+
it "matches hash with hash_including same hash" do
|
85
85
|
@mock.should_receive(:random_call).with(hash_including(:a => 1))
|
86
86
|
@mock.random_call(:a => 1)
|
87
87
|
end
|
@@ -91,7 +91,7 @@ module RSpec
|
|
91
91
|
describe Methods, "handling block matchers" do
|
92
92
|
include_mock_argument_matchers
|
93
93
|
|
94
|
-
it "
|
94
|
+
it "matches arguments against RSpec expectations" do
|
95
95
|
@mock.should_receive(:random_call).with {|arg1, arg2, arr, *rest|
|
96
96
|
arg1.should == 5
|
97
97
|
arg2.should have_at_least(3).characters
|
@@ -109,33 +109,33 @@ module RSpec
|
|
109
109
|
@mock = RSpec::Mocks::Mock.new("test mock")
|
110
110
|
end
|
111
111
|
|
112
|
-
it "
|
112
|
+
it "matches non special symbol (can be removed when deprecated symbols are removed)" do
|
113
113
|
@mock.should_receive(:random_call).with(:some_symbol)
|
114
114
|
@mock.random_call(:some_symbol)
|
115
115
|
end
|
116
116
|
|
117
|
-
it "
|
117
|
+
it "matches string against regexp" do
|
118
118
|
@mock.should_receive(:random_call).with(/bcd/)
|
119
119
|
@mock.random_call("abcde")
|
120
120
|
end
|
121
121
|
|
122
|
-
it "
|
122
|
+
it "matches regexp against regexp" do
|
123
123
|
@mock.should_receive(:random_call).with(/bcd/)
|
124
124
|
@mock.random_call(/bcd/)
|
125
125
|
end
|
126
126
|
|
127
|
-
it "
|
127
|
+
it "matches against a hash submitted and received by value" do
|
128
128
|
@mock.should_receive(:random_call).with(:a => "a", :b => "b")
|
129
129
|
@mock.random_call(:a => "a", :b => "b")
|
130
130
|
end
|
131
131
|
|
132
|
-
it "
|
132
|
+
it "matches against a hash submitted by reference and received by value" do
|
133
133
|
opts = {:a => "a", :b => "b"}
|
134
134
|
@mock.should_receive(:random_call).with(opts)
|
135
135
|
@mock.random_call(:a => "a", :b => "b")
|
136
136
|
end
|
137
137
|
|
138
|
-
it "
|
138
|
+
it "matches against a hash submitted by value and received by reference" do
|
139
139
|
opts = {:a => "a", :b => "b"}
|
140
140
|
@mock.should_receive(:random_call).with(:a => "a", :b => "b")
|
141
141
|
@mock.random_call(opts)
|