rspec-mocks 2.0.0.beta.1 → 2.0.0.beta.2
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/VERSION +1 -1
- data/spec/rspec/mocks/any_number_of_times_spec.rb +1 -1
- data/spec/rspec/mocks/at_least_spec.rb +6 -6
- data/spec/rspec/mocks/at_most_spec.rb +4 -4
- data/spec/rspec/mocks/bug_report_496_spec.rb +9 -7
- data/spec/rspec/mocks/bug_report_600_spec.rb +6 -6
- data/spec/rspec/mocks/bug_report_7611_spec.rb +5 -6
- data/spec/rspec/mocks/bug_report_8302_spec.rb +6 -6
- data/spec/rspec/mocks/bug_report_830_spec.rb +1 -1
- data/spec/rspec/mocks/failing_argument_matchers_spec.rb +12 -12
- data/spec/rspec/mocks/mock_ordering_spec.rb +3 -3
- data/spec/rspec/mocks/mock_space_spec.rb +1 -1
- data/spec/rspec/mocks/mock_spec.rb +23 -23
- data/spec/rspec/mocks/multiple_return_value_spec.rb +11 -11
- data/spec/rspec/mocks/null_object_mock_spec.rb +2 -2
- data/spec/rspec/mocks/once_counts_spec.rb +3 -3
- data/spec/rspec/mocks/partial_mock_spec.rb +3 -3
- data/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb +2 -2
- data/spec/rspec/mocks/passing_argument_matchers_spec.rb +1 -1
- data/spec/rspec/mocks/precise_counts_spec.rb +2 -2
- data/spec/rspec/mocks/twice_counts_spec.rb +4 -4
- metadata +9 -9
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.beta.
|
1
|
+
2.0.0.beta.2
|
@@ -4,14 +4,14 @@ module Rspec
|
|
4
4
|
module Mocks
|
5
5
|
describe "at_least" do
|
6
6
|
before(:each) do
|
7
|
-
@mock = Mock.new("test mock")
|
7
|
+
@mock = Rspec::Mocks::Mock.new("test mock")
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should fail if method is never called" do
|
11
11
|
@mock.should_receive(:random_call).at_least(4).times
|
12
12
|
lambda do
|
13
13
|
@mock.rspec_verify
|
14
|
-
end.should raise_error(MockExpectationError)
|
14
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should fail when called less than n times" do
|
@@ -21,14 +21,14 @@ module Rspec
|
|
21
21
|
@mock.random_call
|
22
22
|
lambda do
|
23
23
|
@mock.rspec_verify
|
24
|
-
end.should raise_error(MockExpectationError)
|
24
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should fail when at least once method is never called" do
|
28
28
|
@mock.should_receive(:random_call).at_least(:once)
|
29
29
|
lambda do
|
30
30
|
@mock.rspec_verify
|
31
|
-
end.should raise_error(MockExpectationError)
|
31
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should fail when at least twice method is called once" do
|
@@ -36,14 +36,14 @@ module Rspec
|
|
36
36
|
@mock.random_call
|
37
37
|
lambda do
|
38
38
|
@mock.rspec_verify
|
39
|
-
end.should raise_error(MockExpectationError)
|
39
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should fail when at least twice method is never called" do
|
43
43
|
@mock.should_receive(:random_call).at_least(:twice)
|
44
44
|
lambda do
|
45
45
|
@mock.rspec_verify
|
46
|
-
end.should raise_error(MockExpectationError)
|
46
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should pass when at least n times method is called exactly n times" do
|
@@ -4,7 +4,7 @@ module Rspec
|
|
4
4
|
module Mocks
|
5
5
|
describe "at_most" do
|
6
6
|
before(:each) do
|
7
|
-
@mock = Mock.new("test mock")
|
7
|
+
@mock = Rspec::Mocks::Mock.new("test mock")
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should fail when at most n times method is called n plus 1 times" do
|
@@ -16,7 +16,7 @@ module Rspec
|
|
16
16
|
@mock.random_call
|
17
17
|
lambda do
|
18
18
|
@mock.rspec_verify
|
19
|
-
end.should raise_error(MockExpectationError)
|
19
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should fail when at most once method is called twice" do
|
@@ -25,7 +25,7 @@ module Rspec
|
|
25
25
|
@mock.random_call
|
26
26
|
lambda do
|
27
27
|
@mock.rspec_verify
|
28
|
-
end.should raise_error(MockExpectationError)
|
28
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should fail when at most twice method is called three times" do
|
@@ -35,7 +35,7 @@ module Rspec
|
|
35
35
|
@mock.random_call
|
36
36
|
lambda do
|
37
37
|
@mock.rspec_verify
|
38
|
-
end.should raise_error(MockExpectationError)
|
38
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should pass when at most n times method is called exactly n times" do
|
@@ -1,15 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module BugReport496
|
4
|
-
class
|
5
|
-
|
4
|
+
describe "a message expectation on a base class object" do
|
5
|
+
class BaseClass
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
class SubClass < BaseClass
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
it "is received" do
|
12
|
+
BaseClass.should_receive(:new).once
|
13
|
+
SubClass.new
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module BugReport600
|
4
|
-
class
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
describe "stubbing a class method" do
|
5
|
+
class ExampleClass
|
6
|
+
def self.method_that_uses_define_method
|
7
|
+
define_method "defined_method" do |attributes|
|
8
|
+
load_address(address, attributes)
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
10
|
-
end
|
11
12
|
|
12
|
-
describe "stubbing a class method" do
|
13
13
|
it "should work" do
|
14
14
|
ExampleClass.should_receive(:define_method).with("defined_method")
|
15
15
|
ExampleClass.method_that_uses_define_method
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Bug7611
|
4
|
-
class Foo
|
5
|
-
end
|
6
|
-
|
7
|
-
class Bar < Foo
|
8
|
-
end
|
9
|
-
|
10
4
|
describe "A Partial Mock" do
|
5
|
+
class Foo
|
6
|
+
end
|
7
|
+
|
8
|
+
class Bar < Foo
|
9
|
+
end
|
11
10
|
it "should respect subclasses" do
|
12
11
|
Foo.stub!(:new).and_return(Object.new)
|
13
12
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Bug8302
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
describe "Bug report 8302:" do
|
5
|
+
class Foo
|
6
|
+
def Foo.class_method(arg)
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
+
def instance_bar(arg)
|
10
|
+
end
|
9
11
|
end
|
10
|
-
end
|
11
12
|
|
12
|
-
describe "Bug report 8302:" do
|
13
13
|
it "class method is not restored correctly when proxied" do
|
14
14
|
Foo.should_not_receive(:class_method).with(Array.new)
|
15
15
|
Foo.rspec_verify
|
@@ -5,7 +5,7 @@ module Rspec
|
|
5
5
|
describe "failing MockArgumentMatchers" do
|
6
6
|
before(:each) do
|
7
7
|
@mock = mock("test mock")
|
8
|
-
@reporter = Mock.new("reporter", :null_object => true)
|
8
|
+
@reporter = Rspec::Mocks::Mock.new("reporter", :null_object => true)
|
9
9
|
end
|
10
10
|
|
11
11
|
after(:each) do
|
@@ -16,71 +16,71 @@ module Rspec
|
|
16
16
|
@mock.should_receive(:random_call).with(boolean())
|
17
17
|
lambda do
|
18
18
|
@mock.random_call("false")
|
19
|
-
end.should raise_error(MockExpectationError)
|
19
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should reject non numeric" do
|
23
23
|
@mock.should_receive(:random_call).with(an_instance_of(Numeric))
|
24
24
|
lambda do
|
25
25
|
@mock.random_call("1")
|
26
|
-
end.should raise_error(MockExpectationError)
|
26
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should reject non string" do
|
30
30
|
@mock.should_receive(:random_call).with(an_instance_of(String))
|
31
31
|
lambda do
|
32
32
|
@mock.random_call(123)
|
33
|
-
end.should raise_error(MockExpectationError)
|
33
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should reject goose when expecting a duck" do
|
37
37
|
@mock.should_receive(:random_call).with(duck_type(:abs, :div))
|
38
|
-
lambda { @mock.random_call("I don't respond to :abs or :div") }.should raise_error(MockExpectationError)
|
38
|
+
lambda { @mock.random_call("I don't respond to :abs or :div") }.should raise_error(Rspec::Mocks::MockExpectationError)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should fail if regexp does not match submitted string" do
|
42
42
|
@mock.should_receive(:random_call).with(/bcd/)
|
43
|
-
lambda { @mock.random_call("abc") }.should raise_error(MockExpectationError)
|
43
|
+
lambda { @mock.random_call("abc") }.should raise_error(Rspec::Mocks::MockExpectationError)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should fail if regexp does not match submitted regexp" do
|
47
47
|
@mock.should_receive(:random_call).with(/bcd/)
|
48
|
-
lambda { @mock.random_call(/bcde/) }.should raise_error(MockExpectationError)
|
48
|
+
lambda { @mock.random_call(/bcde/) }.should raise_error(Rspec::Mocks::MockExpectationError)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should fail for a hash w/ wrong values" do
|
52
52
|
@mock.should_receive(:random_call).with(:a => "b", :c => "d")
|
53
53
|
lambda do
|
54
54
|
@mock.random_call(:a => "b", :c => "e")
|
55
|
-
end.should raise_error(MockExpectationError, /Mock 'test mock' expected :random_call with \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\) but received it with \(\{(:a=>\"b\", :c=>\"e\"|:c=>\"e\", :a=>\"b\")\}\)/)
|
55
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError, /Mock 'test mock' expected :random_call with \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\) but received it with \(\{(:a=>\"b\", :c=>\"e\"|:c=>\"e\", :a=>\"b\")\}\)/)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should fail for a hash w/ wrong keys" do
|
59
59
|
@mock.should_receive(:random_call).with(:a => "b", :c => "d")
|
60
60
|
lambda do
|
61
61
|
@mock.random_call("a" => "b", "c" => "d")
|
62
|
-
end.should raise_error(MockExpectationError, /Mock 'test mock' expected :random_call with \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\) but received it with \(\{(\"a\"=>\"b\", \"c\"=>\"d\"|\"c\"=>\"d\", \"a\"=>\"b\")\}\)/)
|
62
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError, /Mock 'test mock' expected :random_call with \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\) but received it with \(\{(\"a\"=>\"b\", \"c\"=>\"d\"|\"c\"=>\"d\", \"a\"=>\"b\")\}\)/)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should match against a Matcher" do
|
66
66
|
lambda do
|
67
67
|
@mock.should_receive(:msg).with(equal(3))
|
68
68
|
@mock.msg(37)
|
69
|
-
end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (equal 3) but received it with (37)")
|
69
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :msg with (equal 3) but received it with (37)")
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should fail no_args with one arg" do
|
73
73
|
lambda do
|
74
74
|
@mock.should_receive(:msg).with(no_args)
|
75
75
|
@mock.msg(37)
|
76
|
-
end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (no args) but received it with (37)")
|
76
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :msg with (no args) but received it with (37)")
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should fail hash_including with missing key" do
|
80
80
|
lambda do
|
81
81
|
@mock.should_receive(:msg).with(hash_including(:a => 1))
|
82
82
|
@mock.msg({})
|
83
|
-
end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (hash_including(:a=>1)) but received it with ({})")
|
83
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :msg with (hash_including(:a=>1)) but received it with ({})")
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should fail with block matchers" do
|
@@ -36,7 +36,7 @@ module Rspec
|
|
36
36
|
@mock.should_receive(:two).ordered
|
37
37
|
lambda do
|
38
38
|
@mock.two
|
39
|
-
end.should raise_error(MockExpectationError, "Mock 'test mock' received :two out of order")
|
39
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' received :two out of order")
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should fail if third call comes first" do
|
@@ -46,7 +46,7 @@ module Rspec
|
|
46
46
|
@mock.one
|
47
47
|
lambda do
|
48
48
|
@mock.three
|
49
|
-
end.should raise_error(MockExpectationError, "Mock 'test mock' received :three out of order")
|
49
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' received :three out of order")
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should fail if third call comes second" do
|
@@ -56,7 +56,7 @@ module Rspec
|
|
56
56
|
@mock.one
|
57
57
|
lambda do
|
58
58
|
@mock.three
|
59
|
-
end.should raise_error(MockExpectationError, "Mock 'test mock' received :three out of order")
|
59
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' received :three out of order")
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should ignore order of non ordered calls" do
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Rspec
|
4
4
|
module Mocks
|
5
5
|
describe Mock do
|
6
|
-
treats_method_missing_as_private :subject => Mock.new, :noop => false
|
6
|
+
treats_method_missing_as_private :subject => Rspec::Mocks::Mock.new, :noop => false
|
7
7
|
|
8
8
|
before(:each) do
|
9
9
|
@mock = mock("test mock")
|
@@ -18,7 +18,7 @@ module Rspec
|
|
18
18
|
begin
|
19
19
|
@mock.rspec_verify
|
20
20
|
violated
|
21
|
-
rescue MockExpectationError => e
|
21
|
+
rescue Rspec::Mocks::MockExpectationError => e
|
22
22
|
# NOTE - this regexp ended w/ $, but jruby adds extra info at the end of the line
|
23
23
|
e.backtrace[0].should match(/#{File.basename(__FILE__)}:#{expected_error_line}/)
|
24
24
|
end
|
@@ -30,7 +30,7 @@ module Rspec
|
|
30
30
|
begin
|
31
31
|
@mock.rspec_verify
|
32
32
|
violated
|
33
|
-
rescue MockExpectationError => e
|
33
|
+
rescue Rspec::Mocks::MockExpectationError => e
|
34
34
|
# NOTE - this regexp ended w/ $, but jruby adds extra info at the end of the line
|
35
35
|
e.backtrace[0].should match(/#{File.basename(__FILE__)}:#{expected_error_line}/)
|
36
36
|
end
|
@@ -53,7 +53,7 @@ module Rspec
|
|
53
53
|
lambda {
|
54
54
|
@mock.not_expected
|
55
55
|
violated
|
56
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
|
56
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should fail when receiving message specified as not to be received with args" do
|
@@ -61,7 +61,7 @@ module Rspec
|
|
61
61
|
lambda {
|
62
62
|
@mock.not_expected("unexpected text")
|
63
63
|
violated
|
64
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (\"unexpected text\") 0 times, but received it once")
|
64
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :not_expected with (\"unexpected text\") 0 times, but received it once")
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should pass when receiving message specified as not to be received with wrong args" do
|
@@ -93,7 +93,7 @@ module Rspec
|
|
93
93
|
lambda {
|
94
94
|
@mock.something("a","d","c")
|
95
95
|
violated
|
96
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
|
96
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should raise exception if args don't match when method called even when the method is stubbed" do
|
@@ -102,7 +102,7 @@ module Rspec
|
|
102
102
|
lambda {
|
103
103
|
@mock.something("a","d","c")
|
104
104
|
@mock.rspec_verify
|
105
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with ([\"a\", \"d\", \"c\"])")
|
105
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with ([\"a\", \"d\", \"c\"])")
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should raise exception if args don't match when method called even when using null_object" do
|
@@ -111,14 +111,14 @@ module Rspec
|
|
111
111
|
lambda {
|
112
112
|
@mock.something("a","d","c")
|
113
113
|
@mock.rspec_verify
|
114
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with ([\"a\", \"d\", \"c\"])")
|
114
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with ([\"a\", \"d\", \"c\"])")
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should fail if unexpected method called" do
|
118
118
|
lambda {
|
119
119
|
@mock.something("a","b","c")
|
120
120
|
violated
|
121
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' received unexpected message :something with (\"a\", \"b\", \"c\")")
|
121
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' received unexpected message :something with (\"a\", \"b\", \"c\")")
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should use block for expectation if provided" do
|
@@ -135,21 +135,21 @@ module Rspec
|
|
135
135
|
@mock.should_receive(:something) {| bool | bool.should be_true}
|
136
136
|
lambda {
|
137
137
|
@mock.something false
|
138
|
-
}.should raise_error(MockExpectationError, /Mock 'test mock' received :something but passed block failed with: expected false to be true/)
|
138
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, /Mock 'test mock' received :something but passed block failed with: expected false to be true/)
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should fail right away when method defined as never is received" do
|
142
142
|
@mock.should_receive(:not_expected).never
|
143
143
|
lambda {
|
144
144
|
@mock.not_expected
|
145
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
|
145
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should eventually fail when method defined as never is received" do
|
149
149
|
@mock.should_receive(:not_expected).never
|
150
150
|
lambda {
|
151
151
|
@mock.not_expected
|
152
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
|
152
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should raise when told to" do
|
@@ -178,7 +178,7 @@ module Rspec
|
|
178
178
|
@mock.should_receive(:something).with(2).and_raise(RuntimeError)
|
179
179
|
lambda {
|
180
180
|
@mock.something 1
|
181
|
-
}.should raise_error(MockExpectationError)
|
181
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError)
|
182
182
|
end
|
183
183
|
|
184
184
|
it "should throw when told to" do
|
@@ -193,7 +193,7 @@ module Rspec
|
|
193
193
|
@mock.should_receive(:fruit) do |colour|
|
194
194
|
:strawberry
|
195
195
|
end.and_return :apple
|
196
|
-
}.should raise_error(AmbiguousReturnError)
|
196
|
+
}.should raise_error(Rspec::Mocks::AmbiguousReturnError)
|
197
197
|
end
|
198
198
|
|
199
199
|
it "should ignore args on any args" do
|
@@ -209,14 +209,14 @@ module Rspec
|
|
209
209
|
@mock.should_receive(:something).with(no_args())
|
210
210
|
lambda {
|
211
211
|
@mock.something 1
|
212
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (no args) but received it with (1)")
|
212
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :something with (no args) but received it with (1)")
|
213
213
|
end
|
214
214
|
|
215
215
|
it "should fail when args are expected but none are received" do
|
216
216
|
@mock.should_receive(:something).with(1)
|
217
217
|
lambda {
|
218
218
|
@mock.something
|
219
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (1) but received it with (no args)")
|
219
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' expected :something with (1) but received it with (no args)")
|
220
220
|
end
|
221
221
|
|
222
222
|
it "should return value from block by default" do
|
@@ -324,7 +324,7 @@ module Rspec
|
|
324
324
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
|
325
325
|
lambda {
|
326
326
|
@mock.yield_back {|a|}
|
327
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' yielded |\"wha\", \"zup\"| to block with arity of 1")
|
327
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' yielded |\"wha\", \"zup\"| to block with arity of 1")
|
328
328
|
end
|
329
329
|
|
330
330
|
it "should fail when calling yielding method consecutively with wrong arity" do
|
@@ -335,14 +335,14 @@ module Rspec
|
|
335
335
|
a, b = nil
|
336
336
|
c = []
|
337
337
|
@mock.yield_back {|a,b| c << [a, b]}
|
338
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' yielded |\"down\"| to block with arity of 2")
|
338
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' yielded |\"down\"| to block with arity of 2")
|
339
339
|
end
|
340
340
|
|
341
341
|
it "should fail when calling yielding method without block" do
|
342
342
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
|
343
343
|
lambda {
|
344
344
|
@mock.yield_back
|
345
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' asked to yield |[\"wha\", \"zup\"]| but no block was passed")
|
345
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' asked to yield |[\"wha\", \"zup\"]| but no block was passed")
|
346
346
|
end
|
347
347
|
|
348
348
|
it "should be able to mock send" do
|
@@ -369,7 +369,7 @@ module Rspec
|
|
369
369
|
@mock.rspec_verify
|
370
370
|
lambda {
|
371
371
|
@mock.foobar
|
372
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' received unexpected message :foobar with (no args)")
|
372
|
+
}.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'test mock' received unexpected message :foobar with (no args)")
|
373
373
|
end
|
374
374
|
|
375
375
|
it "should restore objects to their original state on rspec_reset" do
|
@@ -405,7 +405,7 @@ module Rspec
|
|
405
405
|
@mock.rspec_verify
|
406
406
|
|
407
407
|
lambda { @mock.foobar }.should_not raise_error(NameError)
|
408
|
-
lambda { @mock.foobar }.should raise_error(MockExpectationError)
|
408
|
+
lambda { @mock.foobar }.should raise_error(Rspec::Mocks::MockExpectationError)
|
409
409
|
end
|
410
410
|
|
411
411
|
it "should temporarily replace a method stub on a mock" do
|
@@ -429,7 +429,7 @@ module Rspec
|
|
429
429
|
it "should raise an error when a previously stubbed method has a negative expectation" do
|
430
430
|
@mock.stub!(:msg).and_return(:stub_value)
|
431
431
|
@mock.should_not_receive(:msg).and_return(:mock_value)
|
432
|
-
lambda {@mock.msg(:arg)}.should raise_error(MockExpectationError)
|
432
|
+
lambda {@mock.msg(:arg)}.should raise_error(Rspec::Mocks::MockExpectationError)
|
433
433
|
end
|
434
434
|
|
435
435
|
it "should temporarily replace a method stub on a non-mock" do
|
@@ -468,7 +468,7 @@ module Rspec
|
|
468
468
|
end
|
469
469
|
|
470
470
|
it "should assign stub return values" do
|
471
|
-
mock = Mock.new('name', :message => :response)
|
471
|
+
mock = Rspec::Mocks::Mock.new('name', :message => :response)
|
472
472
|
mock.message.should == :response
|
473
473
|
end
|
474
474
|
|
@@ -4,7 +4,7 @@ module Rspec
|
|
4
4
|
module Mocks
|
5
5
|
describe "a Mock expectation with multiple return values and no specified count" do
|
6
6
|
before(:each) do
|
7
|
-
@mock = Mock.new("mock")
|
7
|
+
@mock = Rspec::Mocks::Mock.new("mock")
|
8
8
|
@return_values = ["1",2,Object.new]
|
9
9
|
@mock.should_receive(:message).and_return(@return_values[0],@return_values[1],@return_values[2])
|
10
10
|
end
|
@@ -20,7 +20,7 @@ module Rspec
|
|
20
20
|
third = Object.new
|
21
21
|
@mock.message.should == @return_values[0]
|
22
22
|
@mock.message.should == @return_values[1]
|
23
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it twice")
|
23
|
+
lambda { @mock.rspec_verify }.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it twice")
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should complain when there are too many calls" do
|
@@ -29,13 +29,13 @@ module Rspec
|
|
29
29
|
@mock.message.should == @return_values[1]
|
30
30
|
@mock.message.should == @return_values[2]
|
31
31
|
@mock.message.should == @return_values[2]
|
32
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times")
|
32
|
+
lambda { @mock.rspec_verify }.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "a Mock expectation with multiple return values with a specified count equal to the number of values" do
|
37
37
|
before(:each) do
|
38
|
-
@mock = Mock.new("mock")
|
38
|
+
@mock = Rspec::Mocks::Mock.new("mock")
|
39
39
|
@return_values = ["1",2,Object.new]
|
40
40
|
@mock.should_receive(:message).exactly(3).times.and_return(@return_values[0],@return_values[1],@return_values[2])
|
41
41
|
end
|
@@ -51,7 +51,7 @@ module Rspec
|
|
51
51
|
third = Object.new
|
52
52
|
@mock.message.should == @return_values[0]
|
53
53
|
@mock.message.should == @return_values[1]
|
54
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it twice")
|
54
|
+
lambda { @mock.rspec_verify }.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it twice")
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should complain when there are too many calls" do
|
@@ -60,13 +60,13 @@ module Rspec
|
|
60
60
|
@mock.message.should == @return_values[1]
|
61
61
|
@mock.message.should == @return_values[2]
|
62
62
|
@mock.message.should == @return_values[2]
|
63
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times")
|
63
|
+
lambda { @mock.rspec_verify }.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times")
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "a Mock expectation with multiple return values specifying at_least less than the number of values" do
|
68
68
|
before(:each) do
|
69
|
-
@mock = Mock.new("mock")
|
69
|
+
@mock = Rspec::Mocks::Mock.new("mock")
|
70
70
|
@mock.should_receive(:message).at_least(:twice).with(no_args).and_return(11, 22)
|
71
71
|
end
|
72
72
|
|
@@ -79,12 +79,12 @@ module Rspec
|
|
79
79
|
|
80
80
|
it "should fail when called less than the specified number" do
|
81
81
|
@mock.message.should equal(11)
|
82
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (no args) twice, but received it once")
|
82
|
+
lambda { @mock.rspec_verify }.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'mock' expected :message with (no args) twice, but received it once")
|
83
83
|
end
|
84
84
|
end
|
85
85
|
describe "a Mock expectation with multiple return values with a specified count larger than the number of values" do
|
86
86
|
before(:each) do
|
87
|
-
@mock = Mock.new("mock")
|
87
|
+
@mock = Rspec::Mocks::Mock.new("mock")
|
88
88
|
@mock.should_receive(:message).exactly(3).times.and_return(11, 22)
|
89
89
|
end
|
90
90
|
|
@@ -97,7 +97,7 @@ module Rspec
|
|
97
97
|
|
98
98
|
it "should fail when called less than the specified number" do
|
99
99
|
@mock.message.should equal(11)
|
100
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it once")
|
100
|
+
lambda { @mock.rspec_verify }.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it once")
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should fail when called greater than the specified number" do
|
@@ -105,7 +105,7 @@ module Rspec
|
|
105
105
|
@mock.message.should equal(22)
|
106
106
|
@mock.message.should equal(22)
|
107
107
|
@mock.message.should equal(22)
|
108
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times")
|
108
|
+
lambda { @mock.rspec_verify }.should raise_error(Rspec::Mocks::MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times")
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
@@ -4,7 +4,7 @@ module Rspec
|
|
4
4
|
module Mocks
|
5
5
|
describe "a mock acting as a NullObject" do
|
6
6
|
before(:each) do
|
7
|
-
@mock = Mock.new("null_object", :null_object => true)
|
7
|
+
@mock = Rspec::Mocks::Mock.new("null_object", :null_object => true)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should allow explicit expectation" do
|
@@ -16,7 +16,7 @@ module Rspec
|
|
16
16
|
lambda do
|
17
17
|
@mock.should_receive(:something)
|
18
18
|
@mock.rspec_verify
|
19
|
-
end.should raise_error(MockExpectationError)
|
19
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should ignore unexpected methods" do
|
@@ -11,7 +11,7 @@ module Rspec
|
|
11
11
|
@mock.should_receive(:random_call).once.with("a", "b", "c")
|
12
12
|
lambda do
|
13
13
|
@mock.random_call("d", "e", "f")
|
14
|
-
end.should raise_error(MockExpectationError)
|
14
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
15
15
|
@mock.rspec_reset
|
16
16
|
end
|
17
17
|
|
@@ -21,14 +21,14 @@ module Rspec
|
|
21
21
|
@mock.random_call
|
22
22
|
lambda do
|
23
23
|
@mock.rspec_verify
|
24
|
-
end.should raise_error(MockExpectationError)
|
24
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "once should fail when not called" do
|
28
28
|
@mock.should_receive(:random_call).once
|
29
29
|
lambda do
|
30
30
|
@mock.rspec_verify
|
31
|
-
end.should raise_error(MockExpectationError)
|
31
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "once should pass when called once" do
|
@@ -31,11 +31,11 @@ module Rspec
|
|
31
31
|
@object.should_not_receive(:fuhbar)
|
32
32
|
lambda do
|
33
33
|
@object.fuhbar
|
34
|
-
end.should raise_error(MockExpectationError, /<Object:.*> expected :fuhbar with \(no args\) 0 times/)
|
34
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError, /<Object:.*> expected :fuhbar with \(no args\) 0 times/)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should_not_receive should return a negative message expectation" do
|
38
|
-
@object.should_not_receive(:foobar).should be_kind_of(NegativeMessageExpectation)
|
38
|
+
@object.should_not_receive(:foobar).should be_kind_of(Rspec::Mocks::NegativeMessageExpectation)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should_receive should mock out the method" do
|
@@ -55,7 +55,7 @@ module Rspec
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should_receive should return a message expectation" do
|
58
|
-
@object.should_receive(:foobar).should be_kind_of(MessageExpectation)
|
58
|
+
@object.should_receive(:foobar).should be_kind_of(Rspec::Mocks::MessageExpectation)
|
59
59
|
@object.foobar
|
60
60
|
end
|
61
61
|
|
@@ -29,14 +29,14 @@ describe "PartialMockUsingMocksDirectly" do
|
|
29
29
|
@obj.should_receive(:msg)
|
30
30
|
lambda do
|
31
31
|
@obj.rspec_verify
|
32
|
-
end.should raise_error(MockExpectationError)
|
32
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
33
33
|
|
34
34
|
end
|
35
35
|
it "should fail when message is received with incorrect args" do
|
36
36
|
@obj.should_receive(:msg).with(:correct_arg)
|
37
37
|
lambda do
|
38
38
|
@obj.msg(:incorrect_arg)
|
39
|
-
end.should raise_error(MockExpectationError)
|
39
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
40
40
|
@obj.msg(:correct_arg)
|
41
41
|
|
42
42
|
end
|
@@ -106,7 +106,7 @@ module Rspec
|
|
106
106
|
describe Methods, "handling non-matcher arguments" do
|
107
107
|
|
108
108
|
before(:each) do
|
109
|
-
@mock = Mock.new("test mock")
|
109
|
+
@mock = Rspec::Mocks::Mock.new("test mock")
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should match non special symbol (can be removed when deprecated symbols are removed)" do
|
@@ -13,14 +13,14 @@ module Rspec
|
|
13
13
|
@mock.random_call
|
14
14
|
lambda do
|
15
15
|
@mock.rspec_verify
|
16
|
-
end.should raise_error(MockExpectationError)
|
16
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should fail when exactly n times method is never called" do
|
20
20
|
@mock.should_receive(:random_call).exactly(3).times
|
21
21
|
lambda do
|
22
22
|
@mock.rspec_verify
|
23
|
-
end.should raise_error(MockExpectationError)
|
23
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should pass if exactly n times method is called exactly n times" do
|
@@ -14,7 +14,7 @@ module Rspec
|
|
14
14
|
@mock.random_call
|
15
15
|
lambda do
|
16
16
|
@mock.rspec_verify
|
17
|
-
end.should raise_error(MockExpectationError)
|
17
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "twice should fail when call count is lower than expected" do
|
@@ -22,14 +22,14 @@ module Rspec
|
|
22
22
|
@mock.random_call
|
23
23
|
lambda do
|
24
24
|
@mock.rspec_verify
|
25
|
-
end.should raise_error(MockExpectationError)
|
25
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "twice should fail when called twice with wrong args on the first call" do
|
29
29
|
@mock.should_receive(:random_call).twice.with("1", 1)
|
30
30
|
lambda do
|
31
31
|
@mock.random_call(1, "1")
|
32
|
-
end.should raise_error(MockExpectationError)
|
32
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
33
33
|
@mock.rspec_reset
|
34
34
|
end
|
35
35
|
|
@@ -38,7 +38,7 @@ module Rspec
|
|
38
38
|
@mock.random_call("1", 1)
|
39
39
|
lambda do
|
40
40
|
@mock.random_call(1, "1")
|
41
|
-
end.should raise_error(MockExpectationError)
|
41
|
+
end.should raise_error(Rspec::Mocks::MockExpectationError)
|
42
42
|
@mock.rspec_reset
|
43
43
|
end
|
44
44
|
|
metadata
CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- beta
|
10
|
-
-
|
11
|
-
version: 2.0.0.beta.
|
10
|
+
- 2
|
11
|
+
version: 2.0.0.beta.2
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- David Chelimsky
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-03-
|
20
|
+
date: 2010-03-04 00:00:00 -06:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -32,8 +32,8 @@ dependencies:
|
|
32
32
|
- 0
|
33
33
|
- 0
|
34
34
|
- beta
|
35
|
-
-
|
36
|
-
version: 2.0.0.beta.
|
35
|
+
- 2
|
36
|
+
version: 2.0.0.beta.2
|
37
37
|
type: :development
|
38
38
|
version_requirements: *id001
|
39
39
|
- !ruby/object:Gem::Dependency
|
@@ -48,8 +48,8 @@ dependencies:
|
|
48
48
|
- 0
|
49
49
|
- 0
|
50
50
|
- beta
|
51
|
-
-
|
52
|
-
version: 2.0.0.beta.
|
51
|
+
- 2
|
52
|
+
version: 2.0.0.beta.2
|
53
53
|
type: :development
|
54
54
|
version_requirements: *id002
|
55
55
|
description: Rspec's 'test double' framework, with support for stubbing and mocking
|
@@ -136,7 +136,7 @@ licenses: []
|
|
136
136
|
post_install_message: |
|
137
137
|
**************************************************
|
138
138
|
|
139
|
-
Thank you for installing rspec-mocks-2.0.0.beta.
|
139
|
+
Thank you for installing rspec-mocks-2.0.0.beta.2
|
140
140
|
|
141
141
|
This is beta software. If you are looking
|
142
142
|
for a supported production release, please
|
@@ -170,7 +170,7 @@ rubyforge_project: rspec
|
|
170
170
|
rubygems_version: 1.3.6
|
171
171
|
signing_key:
|
172
172
|
specification_version: 3
|
173
|
-
summary: rspec-mocks-2.0.0.beta.
|
173
|
+
summary: rspec-mocks-2.0.0.beta.2
|
174
174
|
test_files:
|
175
175
|
- spec/rspec/mocks/and_yield_spec.rb
|
176
176
|
- spec/rspec/mocks/any_number_of_times_spec.rb
|