rr 0.10.9 → 0.10.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -1
- data/VERSION.yml +1 -1
- data/lib/rr/adapters/rr_methods.rb +6 -5
- data/lib/rr/adapters/test_unit.rb +1 -1
- data/lib/rr/double_definitions/child_double_definition_creator.rb +1 -1
- data/lib/rr/double_definitions/double_definition.rb +8 -7
- data/lib/rr/double_definitions/strategies/strategy.rb +2 -1
- data/lib/rr/injections/double_injection.rb +5 -3
- data/lib/rr/injections/injection.rb +4 -2
- data/spec/api/mock/mock_spec.rb +1 -1
- data/spec/api/spy/spy_spec.rb +9 -8
- data/spec/rr/adapters/rr_methods_argument_matcher_spec.rb +10 -10
- data/spec/rr/adapters/rr_methods_creator_spec.rb +7 -7
- data/spec/rr/adapters/rr_methods_times_matcher_spec.rb +8 -12
- data/spec/rr/double_definitions/double_definition_creator_proxy_spec.rb +0 -31
- data/spec/rr/double_definitions/double_definition_creator_spec.rb +19 -19
- data/spec/rr/double_definitions/double_definition_spec.rb +19 -19
- data/spec/rr/double_injection/double_injection_spec.rb +16 -16
- data/spec/rr/double_injection/double_injection_verify_spec.rb +3 -3
- data/spec/rr/double_spec.rb +11 -5
- data/spec/rr/expectations/hash_including_argument_equality_expectation_spec.rb +2 -2
- data/spec/rr/expectations/satisfy_argument_equality_expectation_spec.rb +2 -2
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +2 -2
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +3 -3
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +6 -6
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +2 -2
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +2 -2
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb +2 -2
- metadata +2 -2
data/CHANGES
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
0.10.10
|
2
|
+
- Suite passes for Ruby 1.9.1
|
3
|
+
|
1
4
|
0.10.9
|
2
5
|
- Fixed 1.8.6 bug for real
|
3
6
|
|
@@ -14,7 +17,6 @@
|
|
14
17
|
- Fixed Bug - Can't stub attribute methods on a BelongsToAssociation (http://github.com/btakita/rr/issues#issue/24)
|
15
18
|
|
16
19
|
0.10.5
|
17
|
-
- Fixed issues with Ruby 1.9
|
18
20
|
- Fixed stack overflow caused by double include in Test::Unit adapter [http://github.com/btakita/rr/issues#issue/16]. Identified by Dave Myron (http://github.com/contentfree)
|
19
21
|
- Fixed warnings (Patch by Bryan Helmkamp)
|
20
22
|
|
data/VERSION.yml
CHANGED
@@ -50,7 +50,7 @@ module RR
|
|
50
50
|
# that succeeds when passed an argument of a certain type.
|
51
51
|
# mock(object).method_name(is_a(String)) {return_value}
|
52
52
|
# object.method_name("A String") # passes
|
53
|
-
|
53
|
+
def is_a(klass)
|
54
54
|
RR::WildcardMatchers::IsA.new(klass)
|
55
55
|
end
|
56
56
|
|
@@ -80,7 +80,7 @@ module RR
|
|
80
80
|
def duck_type(*args)
|
81
81
|
RR::WildcardMatchers::DuckType.new(*args)
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
# Sets up a HashIncluding wildcard ArgumentEqualityExpectation
|
85
85
|
# that succeeds when the passed argument contains at least those keys
|
86
86
|
# and values of the expectation.
|
@@ -99,9 +99,10 @@ module RR
|
|
99
99
|
expectation_proc ||= block
|
100
100
|
RR::WildcardMatchers::Satisfy.new(expectation_proc)
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
def spy(subject)
|
104
|
-
methods_to_stub = subject.public_methods
|
104
|
+
methods_to_stub = subject.public_methods.map {|method_name| method_name.to_sym} -
|
105
|
+
[:methods, :==, :__send__, :__id__, :object_id]
|
105
106
|
methods_to_stub.each do |method|
|
106
107
|
stub.proxy(subject, method)
|
107
108
|
end
|
@@ -110,7 +111,7 @@ module RR
|
|
110
111
|
def received(subject)
|
111
112
|
RR::SpyVerificationProxy.new(subject)
|
112
113
|
end
|
113
|
-
|
114
|
+
|
114
115
|
instance_methods.each do |name|
|
115
116
|
alias_method "rr_#{name}", name
|
116
117
|
end
|
@@ -5,7 +5,7 @@ module RR
|
|
5
5
|
def self.included(mod)
|
6
6
|
RR.trim_backtrace = true
|
7
7
|
mod.class_eval do
|
8
|
-
unless instance_methods.
|
8
|
+
unless instance_methods.detect {|method_name| method_name.to_sym == :setup_with_rr}
|
9
9
|
alias_method :setup_without_rr, :setup
|
10
10
|
def setup_with_rr
|
11
11
|
setup_without_rr
|
@@ -254,8 +254,8 @@ module RR
|
|
254
254
|
if implementation
|
255
255
|
install_method_callback implementation
|
256
256
|
else
|
257
|
-
install_method_callback(lambda do
|
258
|
-
|
257
|
+
install_method_callback(lambda do |*lambda_args|
|
258
|
+
args.first
|
259
259
|
end)
|
260
260
|
end
|
261
261
|
self
|
@@ -288,11 +288,12 @@ module RR
|
|
288
288
|
|
289
289
|
protected
|
290
290
|
def install_method_callback(block)
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
291
|
+
if block
|
292
|
+
if implementation_is_original_method?
|
293
|
+
after_call(&block)
|
294
|
+
else
|
295
|
+
implemented_by block
|
296
|
+
end
|
296
297
|
end
|
297
298
|
end
|
298
299
|
end
|
@@ -99,8 +99,10 @@ module RR
|
|
99
99
|
end
|
100
100
|
|
101
101
|
protected
|
102
|
-
def subject_is_proxy_for_method?(
|
103
|
-
!(class << @subject; self; end).
|
102
|
+
def subject_is_proxy_for_method?(method_name_in_question)
|
103
|
+
!(class << @subject; self; end).
|
104
|
+
instance_methods.
|
105
|
+
detect {|method_name| method_name.to_sym == method_name_in_question.to_sym}
|
104
106
|
end
|
105
107
|
|
106
108
|
def deferred_bind_method
|
@@ -116,7 +118,7 @@ module RR
|
|
116
118
|
end
|
117
119
|
|
118
120
|
def bind_method
|
119
|
-
subject = @subject.is_a?(Class) && !@subject.name.empty? ? @subject.name : "self"
|
121
|
+
subject = @subject.is_a?(Class) && !@subject.name.to_s.empty? ? @subject.name : "self"
|
120
122
|
subject_class.class_eval(<<-METHOD, __FILE__, __LINE__ + 1)
|
121
123
|
def #{@method_name}(*args, &block)
|
122
124
|
arguments = MethodArguments.new(args, block)
|
@@ -5,8 +5,10 @@ module RR
|
|
5
5
|
|
6
6
|
attr_reader :subject
|
7
7
|
|
8
|
-
def subject_has_method_defined?(
|
9
|
-
@subject.methods.
|
8
|
+
def subject_has_method_defined?(method_name_in_question)
|
9
|
+
@subject.methods.detect {|method_name| method_name.to_sym == method_name_in_question.to_sym} ||
|
10
|
+
@subject.protected_methods.detect {|method_name| method_name.to_sym == method_name_in_question.to_sym} ||
|
11
|
+
@subject.private_methods.detect {|method_name| method_name.to_sym == method_name_in_question.to_sym}
|
10
12
|
end
|
11
13
|
|
12
14
|
def subject_has_original_method?
|
data/spec/api/mock/mock_spec.rb
CHANGED
data/spec/api/spy/spy_spec.rb
CHANGED
@@ -2,17 +2,18 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
2
|
|
3
3
|
describe "spy" do
|
4
4
|
attr_reader :subject
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
before(:each) do
|
6
|
+
@subject = Object.new
|
7
|
+
extend RR::Adapters::RRMethods
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
after(:each) do
|
11
|
+
RR.reset
|
12
|
+
end
|
13
13
|
|
14
14
|
it "should record all method invocations" do
|
15
15
|
subject = Object.new
|
16
|
+
|
16
17
|
def subject.something
|
17
18
|
end
|
18
19
|
|
@@ -44,5 +45,5 @@ describe "spy" do
|
|
44
45
|
received(subject).pig_rabbit("bacon", "bunny meat").call
|
45
46
|
end.should raise_error(RR::Errors::SpyVerificationErrors::SpyVerificationError)
|
46
47
|
end
|
47
|
-
end
|
48
|
+
end
|
48
49
|
end
|
@@ -7,11 +7,11 @@ module RR
|
|
7
7
|
it_should_behave_like "RR::Adapters::RRMethods"
|
8
8
|
|
9
9
|
it "returns an Anything matcher" do
|
10
|
-
anything.should == WildcardMatchers::Anything.new
|
10
|
+
anything.should == RR::WildcardMatchers::Anything.new
|
11
11
|
end
|
12
12
|
|
13
13
|
it "rr_anything returns an Anything matcher" do
|
14
|
-
rr_anything.should == WildcardMatchers::Anything.new
|
14
|
+
rr_anything.should == RR::WildcardMatchers::Anything.new
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,11 +19,11 @@ module RR
|
|
19
19
|
it_should_behave_like "RR::Adapters::RRMethods"
|
20
20
|
|
21
21
|
it "returns an IsA matcher" do
|
22
|
-
is_a(Integer).should == WildcardMatchers::IsA.new(Integer)
|
22
|
+
is_a(Integer).should == RR::WildcardMatchers::IsA.new(Integer)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "rr_is_a returns an IsA matcher" do
|
26
|
-
rr_is_a(Integer).should == WildcardMatchers::IsA.new(Integer)
|
26
|
+
rr_is_a(Integer).should == RR::WildcardMatchers::IsA.new(Integer)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -31,11 +31,11 @@ module RR
|
|
31
31
|
it_should_behave_like "RR::Adapters::RRMethods"
|
32
32
|
|
33
33
|
it "returns an Numeric matcher" do
|
34
|
-
numeric.should == WildcardMatchers::Numeric.new
|
34
|
+
numeric.should == RR::WildcardMatchers::Numeric.new
|
35
35
|
end
|
36
36
|
|
37
37
|
it "rr_numeric returns an Numeric matcher" do
|
38
|
-
rr_numeric.should == WildcardMatchers::Numeric.new
|
38
|
+
rr_numeric.should == RR::WildcardMatchers::Numeric.new
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -43,11 +43,11 @@ module RR
|
|
43
43
|
it_should_behave_like "RR::Adapters::RRMethods"
|
44
44
|
|
45
45
|
it "returns an Boolean matcher" do
|
46
|
-
boolean.should == WildcardMatchers::Boolean.new
|
46
|
+
boolean.should == RR::WildcardMatchers::Boolean.new
|
47
47
|
end
|
48
48
|
|
49
49
|
it "rr_boolean returns an Boolean matcher" do
|
50
|
-
rr_boolean.should == WildcardMatchers::Boolean.new
|
50
|
+
rr_boolean.should == RR::WildcardMatchers::Boolean.new
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -55,11 +55,11 @@ module RR
|
|
55
55
|
it_should_behave_like "RR::Adapters::RRMethods"
|
56
56
|
|
57
57
|
it "returns a DuckType matcher" do
|
58
|
-
duck_type(:one, :two).should == WildcardMatchers::DuckType.new(:one, :two)
|
58
|
+
duck_type(:one, :two).should == RR::WildcardMatchers::DuckType.new(:one, :two)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "rr_duck_type returns a DuckType matcher" do
|
62
|
-
rr_duck_type(:one, :two).should == WildcardMatchers::DuckType.new(:one, :two)
|
62
|
+
rr_duck_type(:one, :two).should == RR::WildcardMatchers::DuckType.new(:one, :two)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -27,14 +27,14 @@ module RR
|
|
27
27
|
|
28
28
|
context "when passing no args" do
|
29
29
|
it "returns a DoubleDefinitionCreator" do
|
30
|
-
call_strategy.class.should == DoubleDefinitions::DoubleDefinitionCreator
|
30
|
+
call_strategy.class.should == RR::DoubleDefinitions::DoubleDefinitionCreator
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
context "when passed a method_name argument" do
|
35
35
|
it "creates a mock Double for method" do
|
36
36
|
double_definition = mock(subject, :foobar).returns {:baz}
|
37
|
-
double_definition.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
|
37
|
+
double_definition.times_matcher.should == RR::TimesCalledMatchers::IntegerMatcher.new(1)
|
38
38
|
double_definition.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
39
39
|
double_definition.argument_expectation.expected_arguments.should == []
|
40
40
|
subject.foobar.should == :baz
|
@@ -51,14 +51,14 @@ module RR
|
|
51
51
|
|
52
52
|
context "when passing no args" do
|
53
53
|
it "returns a DoubleDefinitionCreator" do
|
54
|
-
call_strategy.class.should == DoubleDefinitions::DoubleDefinitionCreator
|
54
|
+
call_strategy.class.should == RR::DoubleDefinitions::DoubleDefinitionCreator
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
context "when passed a method_name argument" do
|
59
59
|
it "creates a stub Double for method when passed a method_name argument" do
|
60
60
|
double_definition = stub(subject, :foobar).returns {:baz}
|
61
|
-
double_definition.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
|
61
|
+
double_definition.times_matcher.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
62
62
|
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
63
63
|
subject.foobar.should == :baz
|
64
64
|
end
|
@@ -74,19 +74,19 @@ module RR
|
|
74
74
|
|
75
75
|
context "when passing no args" do
|
76
76
|
it "returns a DoubleDefinitionCreator" do
|
77
|
-
call_strategy.class.should == DoubleDefinitions::DoubleDefinitionCreator
|
77
|
+
call_strategy.class.should == RR::DoubleDefinitions::DoubleDefinitionCreator
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
context "when passed a method_name argument_expectation" do
|
82
82
|
it "creates a mock Double for method" do
|
83
83
|
double_definition = dont_allow(subject, :foobar)
|
84
|
-
double_definition.times_matcher.should == TimesCalledMatchers::NeverMatcher.new
|
84
|
+
double_definition.times_matcher.should == RR::TimesCalledMatchers::NeverMatcher.new
|
85
85
|
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
86
86
|
|
87
87
|
lambda do
|
88
88
|
subject.foobar
|
89
|
-
end.should raise_error(Errors::TimesCalledError)
|
89
|
+
end.should raise_error(RR::Errors::TimesCalledError)
|
90
90
|
RR.reset
|
91
91
|
end
|
92
92
|
end
|
@@ -1,17 +1,13 @@
|
|
1
1
|
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
describe RRMethods, "#any_times" do
|
6
|
-
it_should_behave_like "RR::Adapters::RRMethods"
|
7
|
-
|
8
|
-
it "returns an AnyTimesMatcher" do
|
9
|
-
any_times.should == TimesCalledMatchers::AnyTimesMatcher.new
|
10
|
-
end
|
3
|
+
describe RR::Adapters::RRMethods, "#any_times" do
|
4
|
+
it_should_behave_like "RR::Adapters::RRMethods"
|
11
5
|
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
it "returns an AnyTimesMatcher" do
|
7
|
+
any_times.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "rr_any_times returns an AnyTimesMatcher" do
|
11
|
+
rr_any_times.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
15
12
|
end
|
16
|
-
end
|
17
13
|
end
|
@@ -94,37 +94,6 @@ module RR
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
context "when the block has an arity of -1" do
|
98
|
-
attr_reader :self_value, :passed_in_arguments
|
99
|
-
before do
|
100
|
-
self_value = nil
|
101
|
-
passed_in_arguments = nil
|
102
|
-
block = lambda do |*args|
|
103
|
-
self_value = self
|
104
|
-
passed_in_arguments = args
|
105
|
-
args[0].foobar(1, 2) {:one_two}
|
106
|
-
args[0].foobar(1) {:one}
|
107
|
-
args[0].foobar.with_any_args {:default}
|
108
|
-
args[0].baz() {:baz_result}
|
109
|
-
end
|
110
|
-
block.arity.should == -1
|
111
|
-
|
112
|
-
@the_proxy = DoubleDefinitionCreatorProxy.new(creator, &block)
|
113
|
-
@self_value = self_value
|
114
|
-
@passed_in_arguments = passed_in_arguments
|
115
|
-
end
|
116
|
-
|
117
|
-
send("calls the block to define the Doubles")
|
118
|
-
|
119
|
-
it "passes the self into the block" do
|
120
|
-
passed_in_arguments.map {|a| a.__creator__}.should == [creator]
|
121
|
-
end
|
122
|
-
|
123
|
-
it "evaluates the block with the context of self" do
|
124
|
-
self_value.__creator__.should == creator
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
97
|
context "when the block has an arity of 0" do
|
129
98
|
attr_reader :self_value
|
130
99
|
before do
|
@@ -39,7 +39,7 @@ module RR
|
|
39
39
|
context "when passed a subject and a method_name argument" do
|
40
40
|
it "creates a mock Double for method" do
|
41
41
|
double_definition = creator.mock(subject, :foobar).returns {:baz}
|
42
|
-
double_definition.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
|
42
|
+
double_definition.times_matcher.should == RR::TimesCalledMatchers::IntegerMatcher.new(1)
|
43
43
|
double_definition.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
44
44
|
double_definition.argument_expectation.expected_arguments.should == []
|
45
45
|
subject.foobar.should == :baz
|
@@ -72,7 +72,7 @@ module RR
|
|
72
72
|
context "when passed subject and a method_name argument" do
|
73
73
|
it "creates a stub Double for method when passed a method_name argument" do
|
74
74
|
double_definition = creator.stub(subject, :foobar).returns {:baz}
|
75
|
-
double_definition.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
|
75
|
+
double_definition.times_matcher.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
76
76
|
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
77
77
|
subject.foobar.should == :baz
|
78
78
|
end
|
@@ -105,18 +105,18 @@ module RR
|
|
105
105
|
creator.proxy
|
106
106
|
lambda do
|
107
107
|
creator.dont_allow
|
108
|
-
end.should raise_error(Errors::DoubleDefinitionError, "Doubles cannot be proxied when using dont_allow strategy")
|
108
|
+
end.should raise_error(RR::Errors::DoubleDefinitionError, "Doubles cannot be proxied when using dont_allow strategy")
|
109
109
|
end
|
110
110
|
|
111
111
|
context "when passed a subject and a method_name argument_expectation" do
|
112
112
|
it "creates a mock Double for method" do
|
113
113
|
double_definition = creator.dont_allow(subject, :foobar)
|
114
|
-
double_definition.times_matcher.should == TimesCalledMatchers::NeverMatcher.new
|
114
|
+
double_definition.times_matcher.should == RR::TimesCalledMatchers::NeverMatcher.new
|
115
115
|
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
116
116
|
|
117
117
|
lambda do
|
118
118
|
subject.foobar
|
119
|
-
end.should raise_error(Errors::TimesCalledError)
|
119
|
+
end.should raise_error(RR::Errors::TimesCalledError)
|
120
120
|
RR.reset
|
121
121
|
end
|
122
122
|
end
|
@@ -198,14 +198,14 @@ module RR
|
|
198
198
|
creator.dont_allow
|
199
199
|
lambda do
|
200
200
|
creator.proxy
|
201
|
-
end.should raise_error(Errors::DoubleDefinitionError, "Doubles cannot be proxied when using dont_allow strategy")
|
201
|
+
end.should raise_error(RR::Errors::DoubleDefinitionError, "Doubles cannot be proxied when using dont_allow strategy")
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
205
|
context "when passed a method_name argument" do
|
206
206
|
it "creates a proxy Double for method" do
|
207
207
|
double_definition = creator.stub.proxy(subject, :foobar).after_call {:baz}
|
208
|
-
double_definition.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
|
208
|
+
double_definition.times_matcher.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
209
209
|
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
210
210
|
subject.foobar.should == :baz
|
211
211
|
end
|
@@ -225,7 +225,7 @@ module RR
|
|
225
225
|
it "creates a proxy Double for method" do
|
226
226
|
klass = Class.new
|
227
227
|
double_definition = creator.stub.instance_of(klass, :foobar).returns {:baz}
|
228
|
-
double_definition.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
|
228
|
+
double_definition.times_matcher.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
229
229
|
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
230
230
|
klass.new.foobar.should == :baz
|
231
231
|
end
|
@@ -247,7 +247,7 @@ module RR
|
|
247
247
|
it "creates a instance_of Double for method" do
|
248
248
|
double_definition = instance_of.mock(@klass, :foobar)
|
249
249
|
double_definition.with(1, 2) {:baz}
|
250
|
-
double_definition.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
|
250
|
+
double_definition.times_matcher.should == RR::TimesCalledMatchers::IntegerMatcher.new(1)
|
251
251
|
double_definition.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
252
252
|
double_definition.argument_expectation.expected_arguments.should == [1, 2]
|
253
253
|
|
@@ -263,7 +263,7 @@ module RR
|
|
263
263
|
it "raises a DoubleDefinitionError" do
|
264
264
|
lambda do
|
265
265
|
creator.create(:foobar, 1, 2)
|
266
|
-
end.should raise_error(Errors::DoubleDefinitionError, "This Double has no strategy")
|
266
|
+
end.should raise_error(RR::Errors::DoubleDefinitionError, "This Double has no strategy")
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
@@ -276,7 +276,7 @@ module RR
|
|
276
276
|
it "sets expectation on the #subject that it will be sent the method_name once with the passed-in arguments" do
|
277
277
|
creator.create(:foobar, 1, 2)
|
278
278
|
subject.foobar(1, 2)
|
279
|
-
lambda {subject.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
|
279
|
+
lambda {subject.foobar(1, 2)}.should raise_error(RR::Errors::TimesCalledError)
|
280
280
|
end
|
281
281
|
|
282
282
|
describe "#subject.method_name being called" do
|
@@ -299,7 +299,7 @@ module RR
|
|
299
299
|
end
|
300
300
|
creator.create(:foobar, 1, 2)
|
301
301
|
subject.foobar(1, 2)
|
302
|
-
lambda {subject.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
|
302
|
+
lambda {subject.foobar(1, 2)}.should raise_error(RR::Errors::TimesCalledError)
|
303
303
|
end
|
304
304
|
|
305
305
|
describe "#subject.method_name being called" do
|
@@ -330,7 +330,7 @@ module RR
|
|
330
330
|
before do
|
331
331
|
@real_value = real_value = Object.new
|
332
332
|
(class << subject; self; end).class_eval do
|
333
|
-
define_method(:foobar) {real_value}
|
333
|
+
define_method(:foobar) {|arg1, arg2| real_value}
|
334
334
|
end
|
335
335
|
end
|
336
336
|
|
@@ -400,7 +400,7 @@ module RR
|
|
400
400
|
creator.create(:foobar, 1, 2) {:baz}
|
401
401
|
lambda do
|
402
402
|
subject.foobar
|
403
|
-
end.should raise_error(Errors::DoubleNotFoundError)
|
403
|
+
end.should raise_error(RR::Errors::DoubleNotFoundError)
|
404
404
|
end
|
405
405
|
end
|
406
406
|
end
|
@@ -457,7 +457,7 @@ module RR
|
|
457
457
|
creator.create(:foobar, 1, 2) {:baz}
|
458
458
|
lambda do
|
459
459
|
subject.foobar
|
460
|
-
end.should raise_error(Errors::DoubleNotFoundError)
|
460
|
+
end.should raise_error(RR::Errors::DoubleNotFoundError)
|
461
461
|
end
|
462
462
|
end
|
463
463
|
end
|
@@ -473,8 +473,8 @@ module RR
|
|
473
473
|
describe "#subject.method_name being called with any arguments" do
|
474
474
|
it "raises a TimesCalledError" do
|
475
475
|
creator.create(:foobar)
|
476
|
-
lambda {subject.foobar}.should raise_error(Errors::TimesCalledError)
|
477
|
-
lambda {subject.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
|
476
|
+
lambda {subject.foobar}.should raise_error(RR::Errors::TimesCalledError)
|
477
|
+
lambda {subject.foobar(1, 2)}.should raise_error(RR::Errors::TimesCalledError)
|
478
478
|
end
|
479
479
|
end
|
480
480
|
end
|
@@ -483,14 +483,14 @@ module RR
|
|
483
483
|
describe "#subject.method_name being called with the passed-in arguments" do
|
484
484
|
it "raises a TimesCalledError" do
|
485
485
|
creator.create(:foobar, 1, 2)
|
486
|
-
lambda {subject.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
|
486
|
+
lambda {subject.foobar(1, 2)}.should raise_error(RR::Errors::TimesCalledError)
|
487
487
|
end
|
488
488
|
end
|
489
489
|
|
490
490
|
describe "#subject.method_name being called with different arguments" do
|
491
491
|
it "raises a DoubleNotFoundError" do
|
492
492
|
creator.create(:foobar, 1, 2)
|
493
|
-
lambda {subject.foobar()}.should raise_error(Errors::DoubleNotFoundError)
|
493
|
+
lambda {subject.foobar()}.should raise_error(RR::Errors::DoubleNotFoundError)
|
494
494
|
end
|
495
495
|
end
|
496
496
|
end
|
@@ -167,7 +167,7 @@ module RR
|
|
167
167
|
end
|
168
168
|
|
169
169
|
it "sets an ArgumentEqualityExpectation with no arguments" do
|
170
|
-
definition.argument_expectation.should == Expectations::ArgumentEqualityExpectation.new()
|
170
|
+
definition.argument_expectation.should == RR::Expectations::ArgumentEqualityExpectation.new()
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
@@ -230,13 +230,13 @@ module RR
|
|
230
230
|
it "sets up a Times Called Expectation with 0" do
|
231
231
|
definition.with_any_args
|
232
232
|
definition.never
|
233
|
-
lambda {subject.foobar}.should raise_error(Errors::TimesCalledError)
|
233
|
+
lambda {subject.foobar}.should raise_error(RR::Errors::TimesCalledError)
|
234
234
|
end
|
235
235
|
|
236
236
|
describe "#subject.method_name being called" do
|
237
237
|
it "raises a TimesCalledError" do
|
238
238
|
definition.with_any_args.never
|
239
|
-
lambda {subject.foobar}.should raise_error(Errors::TimesCalledError)
|
239
|
+
lambda {subject.foobar}.should raise_error(RR::Errors::TimesCalledError)
|
240
240
|
end
|
241
241
|
end
|
242
242
|
end
|
@@ -248,7 +248,7 @@ module RR
|
|
248
248
|
end
|
249
249
|
|
250
250
|
it "sets up a Times Called Expectation with 1" do
|
251
|
-
lambda {subject.foobar}.should raise_error(Errors::TimesCalledError)
|
251
|
+
lambda {subject.foobar}.should raise_error(RR::Errors::TimesCalledError)
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
@@ -306,7 +306,7 @@ module RR
|
|
306
306
|
|
307
307
|
it "sets up a Times Called Expectation with 2" do
|
308
308
|
definition.twice.with_any_args
|
309
|
-
lambda {subject.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
|
309
|
+
lambda {subject.foobar(1, 2)}.should raise_error(RR::Errors::TimesCalledError)
|
310
310
|
end
|
311
311
|
end
|
312
312
|
|
@@ -365,7 +365,7 @@ module RR
|
|
365
365
|
end
|
366
366
|
|
367
367
|
it "sets up a Times Called Expectation with 1" do
|
368
|
-
definition.times_matcher.should == TimesCalledMatchers::AtLeastMatcher.new(2)
|
368
|
+
definition.times_matcher.should == RR::TimesCalledMatchers::AtLeastMatcher.new(2)
|
369
369
|
end
|
370
370
|
end
|
371
371
|
|
@@ -425,7 +425,7 @@ module RR
|
|
425
425
|
it "sets up a Times Called Expectation with 1" do
|
426
426
|
lambda do
|
427
427
|
subject.foobar
|
428
|
-
end.should raise_error(Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected at most 2 times.")
|
428
|
+
end.should raise_error(RR::Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected at most 2 times.")
|
429
429
|
end
|
430
430
|
end
|
431
431
|
|
@@ -484,7 +484,7 @@ module RR
|
|
484
484
|
end
|
485
485
|
|
486
486
|
it "sets up a Times Called Expectation with passed in times" do
|
487
|
-
lambda {subject.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
|
487
|
+
lambda {subject.foobar(1, 2)}.should raise_error(RR::Errors::TimesCalledError)
|
488
488
|
end
|
489
489
|
end
|
490
490
|
|
@@ -545,7 +545,7 @@ module RR
|
|
545
545
|
end
|
546
546
|
|
547
547
|
it "sets up a Times Called Expectation with AnyTimes matcher" do
|
548
|
-
definition.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
|
548
|
+
definition.times_matcher.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
549
549
|
end
|
550
550
|
end
|
551
551
|
|
@@ -600,12 +600,12 @@ module RR
|
|
600
600
|
macro "#ordered" do
|
601
601
|
it "adds itself to the ordered doubles list" do
|
602
602
|
definition.ordered
|
603
|
-
Space.instance.ordered_doubles.should include(double)
|
603
|
+
RR::Space.instance.ordered_doubles.should include(double)
|
604
604
|
end
|
605
605
|
|
606
606
|
it "does not double_injection add itself" do
|
607
607
|
definition.ordered
|
608
|
-
Space.instance.ordered_doubles.should == [double]
|
608
|
+
RR::Space.instance.ordered_doubles.should == [double]
|
609
609
|
end
|
610
610
|
|
611
611
|
it "sets ordered? to true" do
|
@@ -618,7 +618,7 @@ module RR
|
|
618
618
|
lambda do
|
619
619
|
definition.ordered
|
620
620
|
end.should raise_error(
|
621
|
-
Errors::DoubleDefinitionError,
|
621
|
+
RR::Errors::DoubleDefinitionError,
|
622
622
|
"Double Definitions must have a dedicated Double to be ordered. " <<
|
623
623
|
"For example, using instance_of does not allow ordered to be used. " <<
|
624
624
|
"proxy the class's #new method instead."
|
@@ -725,10 +725,10 @@ module RR
|
|
725
725
|
@return_value.should == :new_return_value
|
726
726
|
end
|
727
727
|
|
728
|
-
it "passes an array of the args with the block appended as a ProcFromBlock around the original block" do
|
728
|
+
it "passes an array of the args with the block appended as a RR::ProcFromBlock around the original block" do
|
729
729
|
@args.length.should == 3
|
730
730
|
@args[0..1].should == [1, 2]
|
731
|
-
@args[2].should be_instance_of(ProcFromBlock)
|
731
|
+
@args[2].should be_instance_of(RR::ProcFromBlock)
|
732
732
|
@block.should == Proc.new(&@block)
|
733
733
|
@args[2].should == @block
|
734
734
|
end
|
@@ -1024,7 +1024,7 @@ module RR
|
|
1024
1024
|
it "raises a DoubleDefinitionError" do
|
1025
1025
|
lambda do
|
1026
1026
|
definition.proxy!(:baz)
|
1027
|
-
end.should raise_error(Errors::DoubleDefinitionError)
|
1027
|
+
end.should raise_error(RR::Errors::DoubleDefinitionError)
|
1028
1028
|
end
|
1029
1029
|
end
|
1030
1030
|
|
@@ -1046,7 +1046,7 @@ module RR
|
|
1046
1046
|
it "raises a DoubleDefinitionError" do
|
1047
1047
|
lambda do
|
1048
1048
|
definition.strong!(:baz)
|
1049
|
-
end.should raise_error(Errors::DoubleDefinitionError)
|
1049
|
+
end.should raise_error(RR::Errors::DoubleDefinitionError)
|
1050
1050
|
end
|
1051
1051
|
end
|
1052
1052
|
end
|
@@ -1064,7 +1064,7 @@ module RR
|
|
1064
1064
|
definition.argument_expectation = nil
|
1065
1065
|
lambda do
|
1066
1066
|
definition.exact_match?
|
1067
|
-
end.should raise_error(Errors::DoubleDefinitionError)
|
1067
|
+
end.should raise_error(RR::Errors::DoubleDefinitionError)
|
1068
1068
|
end
|
1069
1069
|
end
|
1070
1070
|
|
@@ -1092,7 +1092,7 @@ module RR
|
|
1092
1092
|
definition.argument_expectation = nil
|
1093
1093
|
lambda do
|
1094
1094
|
definition.wildcard_match?
|
1095
|
-
end.should raise_error(Errors::DoubleDefinitionError)
|
1095
|
+
end.should raise_error(RR::Errors::DoubleDefinitionError)
|
1096
1096
|
end
|
1097
1097
|
end
|
1098
1098
|
|
@@ -1142,7 +1142,7 @@ module RR
|
|
1142
1142
|
definition.times_matcher = nil
|
1143
1143
|
lambda do
|
1144
1144
|
definition.terminal?
|
1145
|
-
end.should raise_error(Errors::DoubleDefinitionError)
|
1145
|
+
end.should raise_error(RR::Errors::DoubleDefinitionError)
|
1146
1146
|
end
|
1147
1147
|
end
|
1148
1148
|
end
|
@@ -28,7 +28,7 @@ module RR
|
|
28
28
|
end
|
29
29
|
|
30
30
|
subject.should respond_to(:foobar)
|
31
|
-
subject.methods.
|
31
|
+
(!!subject.methods.detect {|method| method.to_sym == :foobar}).should be_true
|
32
32
|
stub(subject).foobar {:new_foobar}
|
33
33
|
end
|
34
34
|
|
@@ -116,7 +116,7 @@ module RR
|
|
116
116
|
end
|
117
117
|
|
118
118
|
subject.should respond_to(:foobar)
|
119
|
-
subject.methods.
|
119
|
+
(!!subject.methods.detect {|method| method.to_sym == :foobar}).should be_true
|
120
120
|
stub.proxy(subject).foobar {:new_foobar}
|
121
121
|
end
|
122
122
|
|
@@ -131,7 +131,7 @@ module RR
|
|
131
131
|
describe "being called" do
|
132
132
|
it "calls the original method first and sends it into the block" do
|
133
133
|
original_return_value = nil
|
134
|
-
stub.proxy(subject).foobar {|
|
134
|
+
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
135
135
|
subject.foobar.should == :new_foobar
|
136
136
|
original_return_value.should == :original_foobar
|
137
137
|
end
|
@@ -187,13 +187,13 @@ module RR
|
|
187
187
|
|
188
188
|
describe "being called" do
|
189
189
|
it "defines __rr__original_{method_name} to be the lazily created method" do
|
190
|
-
subject.methods.
|
190
|
+
(!!subject.methods.detect {|method| method.to_sym == :__rr__original_foobar}).should be_true
|
191
191
|
subject.__rr__original_foobar.should == :original_foobar
|
192
192
|
end
|
193
193
|
|
194
194
|
it "calls the original method first and sends it into the block" do
|
195
195
|
original_return_value = nil
|
196
|
-
stub.proxy(subject).foobar {|
|
196
|
+
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
197
197
|
subject.foobar.should == :new_foobar
|
198
198
|
original_return_value.should == :original_foobar
|
199
199
|
end
|
@@ -234,13 +234,13 @@ module RR
|
|
234
234
|
describe "being called" do
|
235
235
|
it "defines __rr__original_{method_name} to be the lazily created method" do
|
236
236
|
subject.foobar
|
237
|
-
subject.methods.
|
237
|
+
(!!subject.methods.detect {|method| method.to_sym == :__rr__original_foobar}).should be_true
|
238
238
|
subject.__rr__original_foobar.should == :original_foobar
|
239
239
|
end
|
240
240
|
|
241
241
|
it "calls the lazily created method and returns the injected method return value" do
|
242
242
|
original_return_value = nil
|
243
|
-
stub.proxy(subject).foobar {|
|
243
|
+
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
244
244
|
subject.foobar.should == :new_foobar
|
245
245
|
original_return_value.should == :original_foobar
|
246
246
|
end
|
@@ -283,7 +283,7 @@ module RR
|
|
283
283
|
|
284
284
|
it "calls the lazily created method and returns the injected method return value" do
|
285
285
|
original_return_value = nil
|
286
|
-
stub.proxy(subject).foobar {|
|
286
|
+
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
287
287
|
subject.foobar.should == :new_foobar
|
288
288
|
original_return_value.should == :original_foobar
|
289
289
|
end
|
@@ -339,13 +339,13 @@ module RR
|
|
339
339
|
|
340
340
|
describe "being called" do
|
341
341
|
it "defines __rr__original_{method_name} to be the lazily created method" do
|
342
|
-
subject.methods.
|
342
|
+
(!!subject.methods.detect {|method| method.to_sym == :__rr__original_foobar}).should be_true
|
343
343
|
subject.__rr__original_foobar.should == :original_foobar
|
344
344
|
end
|
345
345
|
|
346
346
|
it "calls the original method first and sends it into the block" do
|
347
347
|
original_return_value = nil
|
348
|
-
stub.proxy(subject).foobar {|
|
348
|
+
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
349
349
|
subject.foobar.should == :new_foobar
|
350
350
|
original_return_value.should == :original_foobar
|
351
351
|
end
|
@@ -386,13 +386,13 @@ module RR
|
|
386
386
|
describe "being called" do
|
387
387
|
it "defines __rr__original_{method_name} to be the lazily created method" do
|
388
388
|
subject.foobar
|
389
|
-
subject.methods.
|
389
|
+
(!!subject.methods.detect {|method| method.to_sym == :__rr__original_foobar}).should be_true
|
390
390
|
subject.__rr__original_foobar.should == :original_foobar
|
391
391
|
end
|
392
392
|
|
393
393
|
it "calls the lazily created method and returns the injected method return value" do
|
394
394
|
original_return_value = nil
|
395
|
-
stub.proxy(subject).foobar {|
|
395
|
+
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
396
396
|
subject.foobar.should == :new_foobar
|
397
397
|
original_return_value.should == :original_foobar
|
398
398
|
end
|
@@ -435,7 +435,7 @@ module RR
|
|
435
435
|
|
436
436
|
it "calls the lazily created method and returns the injected method return value" do
|
437
437
|
original_return_value = nil
|
438
|
-
stub.proxy(subject).foobar {|
|
438
|
+
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
439
439
|
subject.foobar.should == :new_foobar
|
440
440
|
original_return_value.should == :original_foobar
|
441
441
|
end
|
@@ -481,13 +481,13 @@ module RR
|
|
481
481
|
|
482
482
|
it "adds the method to the subject" do
|
483
483
|
subject.should respond_to(:foobar)
|
484
|
-
subject.methods.
|
484
|
+
(!!subject.methods.detect {|method| method.to_sym == :foobar}).should be_true
|
485
485
|
end
|
486
486
|
|
487
487
|
describe "being called" do
|
488
488
|
it "calls the original method first and sends it into the block" do
|
489
489
|
original_return_value = nil
|
490
|
-
stub.proxy(subject).foobar {|
|
490
|
+
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
491
491
|
subject.foobar.should == :new_foobar
|
492
492
|
original_return_value.should == :original_foobar
|
493
493
|
end
|
@@ -516,7 +516,7 @@ module RR
|
|
516
516
|
|
517
517
|
it "adds the method to the subject" do
|
518
518
|
subject.should respond_to(:foobar)
|
519
|
-
subject.methods.
|
519
|
+
(!!subject.methods.detect {|method| method.to_sym == :foobar}).should be_true
|
520
520
|
end
|
521
521
|
|
522
522
|
describe "being called" do
|
@@ -13,14 +13,14 @@ module RR
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "verifies each double was met" do
|
16
|
-
double = Double.new(
|
16
|
+
double = RR::Double.new(
|
17
17
|
double_injection,
|
18
|
-
DoubleDefinitions::DoubleDefinition.new(DoubleDefinitions::DoubleDefinitionCreator.new, subject)
|
18
|
+
RR::DoubleDefinitions::DoubleDefinition.new(RR::DoubleDefinitions::DoubleDefinitionCreator.new, subject)
|
19
19
|
)
|
20
20
|
double_injection.register_double double
|
21
21
|
|
22
22
|
double.definition.with(1).once.returns {nil}
|
23
|
-
lambda {double_injection.verify}.should raise_error(Errors::TimesCalledError)
|
23
|
+
lambda {double_injection.verify}.should raise_error(RR::Errors::TimesCalledError)
|
24
24
|
subject.foobar(1)
|
25
25
|
lambda {double_injection.verify}.should_not raise_error
|
26
26
|
end
|
data/spec/rr/double_spec.rb
CHANGED
@@ -35,14 +35,20 @@ module RR
|
|
35
35
|
|
36
36
|
describe "#call" do
|
37
37
|
describe "when verbose" do
|
38
|
+
attr_reader :original_stdout
|
39
|
+
before do
|
40
|
+
@original_stdout = $stdout
|
41
|
+
end
|
42
|
+
|
43
|
+
after do
|
44
|
+
$stdout = original_stdout
|
45
|
+
end
|
46
|
+
|
38
47
|
it "prints the message call" do
|
39
48
|
double.definition.verbose
|
40
|
-
output =
|
41
|
-
(class << double; self; end).__send__(:define_method, :puts) do |output|
|
42
|
-
output = output
|
43
|
-
end
|
49
|
+
$stdout = StringIO.new(output = "")
|
44
50
|
subject.foobar(1, 2)
|
45
|
-
output.should == Double.formatted_name(:foobar, [1, 2])
|
51
|
+
output.strip.should == Double.formatted_name(:foobar, [1, 2])
|
46
52
|
end
|
47
53
|
end
|
48
54
|
|
@@ -15,11 +15,11 @@ module Expectations
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "returns true when passed in a HashIncluding matcher with the same hash" do
|
18
|
-
expectation.should be_exact_match(WildcardMatchers::HashIncluding.new(expected_hash))
|
18
|
+
expectation.should be_exact_match(RR::WildcardMatchers::HashIncluding.new(expected_hash))
|
19
19
|
end
|
20
20
|
|
21
21
|
it "returns false when passed in a HashIncluding matcher with a different argument list" do
|
22
|
-
expectation.should_not be_exact_match(WildcardMatchers::HashIncluding.new(:foo => 1))
|
22
|
+
expectation.should_not be_exact_match(RR::WildcardMatchers::HashIncluding.new(:foo => 1))
|
23
23
|
end
|
24
24
|
|
25
25
|
it "returns false otherwise" do
|
@@ -17,11 +17,11 @@ module Expectations
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "returns true when passed a Satisfy matcher with the same proc" do
|
20
|
-
expectation.should be_exact_match(WildcardMatchers::Satisfy.new(expectation_proc))
|
20
|
+
expectation.should be_exact_match(RR::WildcardMatchers::Satisfy.new(expectation_proc))
|
21
21
|
end
|
22
22
|
|
23
23
|
it "returns false when passed a Satisfy matcher with another proc" do
|
24
|
-
expectation.should_not be_exact_match(WildcardMatchers::Satisfy.new(lambda {}))
|
24
|
+
expectation.should_not be_exact_match(RR::WildcardMatchers::Satisfy.new(lambda {}))
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns false otherwise" do
|
@@ -39,7 +39,7 @@ module RR
|
|
39
39
|
|
40
40
|
it "raises error before attempted more than expected times" do
|
41
41
|
3.times {expectation.attempt}
|
42
|
-
lambda {expectation.attempt}.should raise_error( Errors::TimesCalledError )
|
42
|
+
lambda {expectation.attempt}.should raise_error( RR::Errors::TimesCalledError )
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -48,7 +48,7 @@ module RR
|
|
48
48
|
3.times {expectation.attempt}
|
49
49
|
lambda do
|
50
50
|
expectation.attempt
|
51
|
-
end.should raise_error(Errors::TimesCalledError, "foobar()\nCalled 4 times.\nExpected at most 3 times.")
|
51
|
+
end.should raise_error(RR::Errors::TimesCalledError, "foobar()\nCalled 4 times.\nExpected at most 3 times.")
|
52
52
|
end
|
53
53
|
|
54
54
|
it "passes when times called == times" do
|
@@ -7,8 +7,8 @@ module RR
|
|
7
7
|
@subject = Object.new
|
8
8
|
@method_name = :foobar
|
9
9
|
@double_injection = space.double_injection(subject, method_name)
|
10
|
-
@double_definition = DoubleDefinitions::DoubleDefinition.new(
|
11
|
-
DoubleDefinitions::DoubleDefinitionCreator.new,
|
10
|
+
@double_definition = RR::DoubleDefinitions::DoubleDefinition.new(
|
11
|
+
RR::DoubleDefinitions::DoubleDefinitionCreator.new,
|
12
12
|
subject
|
13
13
|
)
|
14
14
|
@double = new_double(double_injection)
|
@@ -16,7 +16,7 @@ module RR
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def raises_expectation_error(&block)
|
19
|
-
lambda {block.call}.should raise_error(Errors::TimesCalledError)
|
19
|
+
lambda {block.call}.should raise_error(RR::Errors::TimesCalledError)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -33,7 +33,7 @@ module RR
|
|
33
33
|
it "fails after attempt! called 1 time" do
|
34
34
|
expectation.attempt
|
35
35
|
lambda {expectation.verify!}.should raise_error(
|
36
|
-
Errors::TimesCalledError,
|
36
|
+
RR::Errors::TimesCalledError,
|
37
37
|
"foobar()\nCalled 1 time.\nExpected 2 times."
|
38
38
|
)
|
39
39
|
end
|
@@ -43,14 +43,14 @@ module RR
|
|
43
43
|
expectation.attempt
|
44
44
|
lambda do
|
45
45
|
expectation.attempt
|
46
|
-
end.should raise_error(Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected 2 times.")
|
46
|
+
end.should raise_error(RR::Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected 2 times.")
|
47
47
|
end
|
48
48
|
|
49
49
|
it "has a backtrace to where the TimesCalledExpectation was instantiated on failure" do
|
50
50
|
error = nil
|
51
51
|
begin
|
52
52
|
expectation.verify!
|
53
|
-
rescue Errors::TimesCalledError => e
|
53
|
+
rescue RR::Errors::TimesCalledError => e
|
54
54
|
error = e
|
55
55
|
end
|
56
56
|
e.backtrace.first.should include(__FILE__)
|
@@ -60,7 +60,7 @@ module RR
|
|
60
60
|
it "has an error message that includes the number of times called and expected number of times" do
|
61
61
|
lambda do
|
62
62
|
expectation.verify!
|
63
|
-
end.should raise_error(Errors::TimesCalledError, "foobar()\nCalled 0 times.\nExpected 2 times.")
|
63
|
+
end.should raise_error(RR::Errors::TimesCalledError, "foobar()\nCalled 0 times.\nExpected 2 times.")
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -78,7 +78,7 @@ module RR
|
|
78
78
|
it "raises error before attempted more than expected times" do
|
79
79
|
2.times {expectation.attempt}
|
80
80
|
lambda {expectation.attempt}.should raise_error(
|
81
|
-
Errors::TimesCalledError
|
81
|
+
RR::Errors::TimesCalledError
|
82
82
|
)
|
83
83
|
end
|
84
84
|
end
|
@@ -89,7 +89,7 @@ module RR
|
|
89
89
|
expectation.attempt
|
90
90
|
lambda do
|
91
91
|
expectation.attempt
|
92
|
-
end.should raise_error(Errors::TimesCalledError)
|
92
|
+
end.should raise_error(RR::Errors::TimesCalledError)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -34,14 +34,14 @@ module RR
|
|
34
34
|
|
35
35
|
it "fails after attempt! called 1 time" do
|
36
36
|
expectation.attempt
|
37
|
-
lambda {expectation.verify!}.should raise_error(Errors::TimesCalledError)
|
37
|
+
lambda {expectation.verify!}.should raise_error(RR::Errors::TimesCalledError)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "fails after attempt! called 3 times" do
|
41
41
|
expectation.attempt
|
42
42
|
expectation.attempt
|
43
43
|
expectation.attempt
|
44
|
-
lambda {expectation.verify!}.should raise_error(Errors::TimesCalledError)
|
44
|
+
lambda {expectation.verify!}.should raise_error(RR::Errors::TimesCalledError)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -40,7 +40,7 @@ module RR
|
|
40
40
|
expectation.attempt
|
41
41
|
lambda do
|
42
42
|
expectation.attempt
|
43
|
-
end.should raise_error(Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected 1..2 times.")
|
43
|
+
end.should raise_error(RR::Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected 1..2 times.")
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -59,7 +59,7 @@ module RR
|
|
59
59
|
it "raises error before attempted more than expected times" do
|
60
60
|
2.times {expectation.attempt}
|
61
61
|
lambda {expectation.attempt}.should raise_error(
|
62
|
-
Errors::TimesCalledError
|
62
|
+
RR::Errors::TimesCalledError
|
63
63
|
)
|
64
64
|
end
|
65
65
|
end
|
@@ -17,7 +17,7 @@ module RR
|
|
17
17
|
describe "#attempt!" do
|
18
18
|
it "raises error that includes the double" do
|
19
19
|
lambda {expectation.attempt}.should raise_error(
|
20
|
-
Errors::TimesCalledError,
|
20
|
+
RR::Errors::TimesCalledError,
|
21
21
|
"#{double.formatted_name}\n#{matcher.error_message(1)}"
|
22
22
|
)
|
23
23
|
end
|
@@ -27,7 +27,7 @@ module RR
|
|
27
27
|
it "raises error with passed in message prepended" do
|
28
28
|
expectation.instance_variable_set(:@times_called, 1)
|
29
29
|
lambda {expectation.verify!}.should raise_error(
|
30
|
-
Errors::TimesCalledError,
|
30
|
+
RR::Errors::TimesCalledError,
|
31
31
|
"#{double.formatted_name}\n#{matcher.error_message(1)}"
|
32
32
|
)
|
33
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Takita
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-25 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|