rr 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +5 -0
- data/README +13 -0
- data/Rakefile +1 -1
- data/lib/rr.rb +3 -3
- data/lib/rr/adapters/rr_methods.rb +5 -5
- data/lib/rr/double.rb +5 -5
- data/lib/rr/double_creator.rb +13 -13
- data/lib/rr/double_definition.rb +3 -3
- data/lib/rr/double_injection.rb +24 -24
- data/lib/rr/double_matches.rb +29 -29
- data/lib/rr/errors/{scenario_definition_error.rb → double_definition_error.rb} +0 -0
- data/lib/rr/errors/{scenario_not_found_error.rb → double_not_found_error.rb} +0 -0
- data/lib/rr/errors/{scenario_order_error.rb → double_order_error.rb} +0 -0
- data/lib/rr/expectations/times_called_expectation.rb +4 -4
- data/lib/rr/space.rb +22 -22
- data/spec/rr/adapters/rr_methods_creator_spec.rb +69 -69
- data/spec/rr/adapters/rr_methods_space_spec.rb +11 -11
- data/spec/rr/double/double_injection_dispatching_spec.rb +66 -66
- data/spec/rr/double/double_injection_register_scenario_spec.rb +8 -8
- data/spec/rr/double/double_injection_verify_spec.rb +4 -4
- data/spec/rr/double_creator_spec.rb +65 -65
- data/spec/rr/double_definition_spec.rb +9 -9
- data/spec/rr/double_method_proxy_spec.rb +7 -7
- data/spec/rr/double_spec.rb +199 -199
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +1 -1
- 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 +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb +4 -4
- data/spec/rr/rspec/rspec_adapter_spec.rb +2 -2
- data/spec/rr/space/space_create_spec.rb +37 -37
- data/spec/rr/space/space_register_spec.rb +9 -9
- data/spec/rr/space/space_reset_spec.rb +7 -7
- data/spec/rr/space/space_verify_spec.rb +31 -31
- metadata +5 -5
data/CHANGES
CHANGED
data/README
CHANGED
@@ -17,6 +17,19 @@ http://xunitpatterns.com/Test%20Double.html
|
|
17
17
|
Currently RR implements mocks, stubs, and proxies. In the future, RR will
|
18
18
|
support spies.
|
19
19
|
|
20
|
+
== Using RR
|
21
|
+
=== test/unit
|
22
|
+
class Test::Unit::TestCase
|
23
|
+
include RR::Adapters::TestUnit
|
24
|
+
end
|
25
|
+
|
26
|
+
=== rspec
|
27
|
+
Spec::Runners.configure do |config|
|
28
|
+
config.mock_with :rr
|
29
|
+
# or if that doesn't work due to a version incompatibility
|
30
|
+
# config.mock_with RR::Adapters::Rspec
|
31
|
+
end
|
32
|
+
|
20
33
|
== Syntax between RR and other double/mock frameworks
|
21
34
|
=== Terse Syntax
|
22
35
|
One of the goals of RR is to make doubles more scannable.
|
data/Rakefile
CHANGED
data/lib/rr.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
dir = File.dirname(__FILE__)
|
2
2
|
require "#{dir}/rr/errors/rr_error"
|
3
|
-
require "#{dir}/rr/errors/
|
4
|
-
require "#{dir}/rr/errors/
|
5
|
-
require "#{dir}/rr/errors/
|
3
|
+
require "#{dir}/rr/errors/double_definition_error"
|
4
|
+
require "#{dir}/rr/errors/double_not_found_error"
|
5
|
+
require "#{dir}/rr/errors/double_order_error"
|
6
6
|
require "#{dir}/rr/errors/argument_equality_error"
|
7
7
|
require "#{dir}/rr/errors/times_called_error"
|
8
8
|
|
@@ -41,7 +41,7 @@ module RR
|
|
41
41
|
# method_name_2(arg_1, arg_2) {return_value_2}
|
42
42
|
# end
|
43
43
|
def mock(subject=DoubleCreator::NO_SUBJECT_ARG, method_name=nil, &definition)
|
44
|
-
creator = RR::Space.
|
44
|
+
creator = RR::Space.double_creator
|
45
45
|
creator.mock(subject, method_name, &definition)
|
46
46
|
end
|
47
47
|
|
@@ -75,7 +75,7 @@ module RR
|
|
75
75
|
# method_name_2(arg_1, arg_2) {return_value_2}
|
76
76
|
# end
|
77
77
|
def stub(subject=DoubleCreator::NO_SUBJECT_ARG, method_name=nil, &definition)
|
78
|
-
creator = RR::Space.
|
78
|
+
creator = RR::Space.double_creator
|
79
79
|
creator.stub(subject, method_name, &definition)
|
80
80
|
end
|
81
81
|
|
@@ -125,7 +125,7 @@ module RR
|
|
125
125
|
# "My new return value"
|
126
126
|
# end
|
127
127
|
def proxy(subject=DoubleCreator::NO_SUBJECT_ARG, method_name=nil, &definition)
|
128
|
-
creator = RR::Space.
|
128
|
+
creator = RR::Space.double_creator
|
129
129
|
creator.proxy(subject, method_name, &definition)
|
130
130
|
end
|
131
131
|
|
@@ -146,7 +146,7 @@ module RR
|
|
146
146
|
# m.method3.with_no_args # Do not allow method3 with no arguments
|
147
147
|
# end
|
148
148
|
def dont_allow(subject=DoubleCreator::NO_SUBJECT_ARG, method_name=nil, &definition)
|
149
|
-
creator = RR::Space.
|
149
|
+
creator = RR::Space.double_creator
|
150
150
|
creator.dont_allow(subject, method_name, &definition)
|
151
151
|
end
|
152
152
|
alias_method :do_not_allow, :dont_allow
|
@@ -165,7 +165,7 @@ module RR
|
|
165
165
|
# projects[0..2]
|
166
166
|
# end
|
167
167
|
def instance_of(subject=DoubleCreator::NO_SUBJECT_ARG, method_name=nil, &definition)
|
168
|
-
creator = RR::Space.
|
168
|
+
creator = RR::Space.double_creator
|
169
169
|
creator.instance_of(subject, method_name, &definition)
|
170
170
|
end
|
171
171
|
|
data/lib/rr/double.rb
CHANGED
@@ -9,9 +9,9 @@ module RR
|
|
9
9
|
"#{method_name}(#{formatted_errors})"
|
10
10
|
end
|
11
11
|
|
12
|
-
def list_message_part(
|
13
|
-
|
14
|
-
"- #{formatted_name(
|
12
|
+
def list_message_part(doubles)
|
13
|
+
doubles.collect do |double|
|
14
|
+
"- #{formatted_name(double.method_name, double.expected_arguments)}"
|
15
15
|
end.join("\n")
|
16
16
|
end
|
17
17
|
end
|
@@ -218,7 +218,7 @@ module RR
|
|
218
218
|
# exceeds the expected TimesCalledExpectation.
|
219
219
|
def call(double_insertion, *args, &block)
|
220
220
|
self.times_called_expectation.attempt! if definition.times_matcher
|
221
|
-
@space.
|
221
|
+
@space.verify_ordered_double(self) if ordered?
|
222
222
|
yields!(block)
|
223
223
|
return_value = call_implementation(double_insertion, *args, &block)
|
224
224
|
return return_value unless definition.after_call_value
|
@@ -280,7 +280,7 @@ module RR
|
|
280
280
|
end
|
281
281
|
|
282
282
|
# Double#verify verifies the the TimesCalledExpectation
|
283
|
-
# is satisfied for this
|
283
|
+
# is satisfied for this double. A TimesCalledError
|
284
284
|
# is raised if the TimesCalledExpectation is not met.
|
285
285
|
def verify
|
286
286
|
return true unless definition.times_matcher
|
data/lib/rr/double_creator.rb
CHANGED
@@ -50,7 +50,7 @@ module RR
|
|
50
50
|
strategy_error! if @strategy
|
51
51
|
@strategy = :mock
|
52
52
|
return self if subject.__id__ === NO_SUBJECT_ARG.__id__
|
53
|
-
RR::Space.
|
53
|
+
RR::Space.double_method_proxy(self, subject, method_name, &definition)
|
54
54
|
end
|
55
55
|
|
56
56
|
# This method sets the Double to have a stub strategy. A stub strategy
|
@@ -85,7 +85,7 @@ module RR
|
|
85
85
|
strategy_error! if @strategy
|
86
86
|
@strategy = :stub
|
87
87
|
return self if subject.__id__ === NO_SUBJECT_ARG.__id__
|
88
|
-
RR::Space.
|
88
|
+
RR::Space.double_method_proxy(self, subject, method_name, &definition)
|
89
89
|
end
|
90
90
|
|
91
91
|
# This method sets the Double to have a dont_allow strategy.
|
@@ -109,7 +109,7 @@ module RR
|
|
109
109
|
proxy_when_dont_allow_error! if @proxy
|
110
110
|
@strategy = :dont_allow
|
111
111
|
return self if subject.__id__ === NO_SUBJECT_ARG.__id__
|
112
|
-
RR::Space.
|
112
|
+
RR::Space.double_method_proxy(self, subject, method_name, &definition)
|
113
113
|
end
|
114
114
|
alias_method :do_not_allow, :dont_allow
|
115
115
|
alias_method :dont_call, :dont_allow
|
@@ -164,7 +164,7 @@ module RR
|
|
164
164
|
proxy_when_dont_allow_error! if @strategy == :dont_allow
|
165
165
|
@proxy = true
|
166
166
|
return self if subject.__id__ === NO_SUBJECT_ARG.__id__
|
167
|
-
RR::Space.
|
167
|
+
RR::Space.double_method_proxy(self, subject, method_name, &definition)
|
168
168
|
end
|
169
169
|
alias_method :probe, :proxy
|
170
170
|
|
@@ -183,7 +183,7 @@ module RR
|
|
183
183
|
@instance_of = true
|
184
184
|
return self if subject === NO_SUBJECT_ARG
|
185
185
|
raise ArgumentError, "instance_of only accepts class objects" unless subject.is_a?(Class)
|
186
|
-
RR::Space.
|
186
|
+
RR::Space.double_method_proxy(self, subject, method_name, &definition)
|
187
187
|
end
|
188
188
|
|
189
189
|
def create!(subject, method_name, *args, &handler)
|
@@ -192,34 +192,34 @@ module RR
|
|
192
192
|
if @instance_of
|
193
193
|
setup_class_probing_instances(subject, method_name)
|
194
194
|
else
|
195
|
-
|
195
|
+
setup_double(subject, method_name)
|
196
196
|
end
|
197
197
|
transform!
|
198
198
|
@definition
|
199
199
|
end
|
200
200
|
|
201
201
|
protected
|
202
|
-
def
|
202
|
+
def setup_double(subject, method_name)
|
203
203
|
@double_insertion = @space.double_insertion(subject, method_name)
|
204
|
-
@
|
205
|
-
@definition = @
|
204
|
+
@double = @space.double(@double_insertion)
|
205
|
+
@definition = @double.definition
|
206
206
|
end
|
207
207
|
|
208
208
|
def setup_class_probing_instances(subject, method_name)
|
209
209
|
class_double = @space.double_insertion(subject, :new)
|
210
|
-
|
210
|
+
class_double = @space.double(class_double)
|
211
211
|
|
212
212
|
instance_method_name = method_name
|
213
213
|
|
214
|
-
@definition = @space.
|
214
|
+
@definition = @space.double_definition
|
215
215
|
class_handler = proc do |return_value|
|
216
216
|
double_insertion = @space.double_insertion(return_value, instance_method_name)
|
217
|
-
@space.
|
217
|
+
@space.double(double_insertion, @definition)
|
218
218
|
return_value
|
219
219
|
end
|
220
220
|
|
221
221
|
builder = DoubleDefinitionBuilder.new(
|
222
|
-
|
222
|
+
class_double.definition,
|
223
223
|
[],
|
224
224
|
class_handler
|
225
225
|
)
|
data/lib/rr/double_definition.rb
CHANGED
@@ -10,7 +10,7 @@ module RR
|
|
10
10
|
:implementation,
|
11
11
|
:after_call_value,
|
12
12
|
:yields_value,
|
13
|
-
:
|
13
|
+
:double
|
14
14
|
attr_reader :block_callback_strategy
|
15
15
|
|
16
16
|
def initialize(space)
|
@@ -157,9 +157,9 @@ module RR
|
|
157
157
|
"Double Definitions must have a dedicated Double to be ordered. " <<
|
158
158
|
"For example, using instance_of does not allow ordered to be used. " <<
|
159
159
|
"proxy the class's #new method instead."
|
160
|
-
) unless @
|
160
|
+
) unless @double
|
161
161
|
@ordered = true
|
162
|
-
@space.
|
162
|
+
@space.ordered_doubles << @double unless @space.ordered_doubles.include?(@double)
|
163
163
|
install_method_callback returns
|
164
164
|
self
|
165
165
|
end
|
data/lib/rr/double_injection.rb
CHANGED
@@ -4,7 +4,7 @@ module RR
|
|
4
4
|
# has Argument Expectations and Times called Expectations.
|
5
5
|
class DoubleInjection
|
6
6
|
MethodArguments = Struct.new(:arguments, :block)
|
7
|
-
attr_reader :space, :object, :method_name, :
|
7
|
+
attr_reader :space, :object, :method_name, :doubles
|
8
8
|
|
9
9
|
def initialize(space, object, method_name)
|
10
10
|
@space = space
|
@@ -13,13 +13,13 @@ module RR
|
|
13
13
|
if object_has_method?(method_name)
|
14
14
|
meta.send(:alias_method, original_method_name, method_name)
|
15
15
|
end
|
16
|
-
@
|
16
|
+
@doubles = []
|
17
17
|
end
|
18
18
|
|
19
|
-
# RR::DoubleInjection#
|
19
|
+
# RR::DoubleInjection#register_double adds the passed in Double
|
20
20
|
# into this DoubleInjection's list of Double objects.
|
21
|
-
def
|
22
|
-
@
|
21
|
+
def register_double(double)
|
22
|
+
@doubles << double
|
23
23
|
end
|
24
24
|
|
25
25
|
# RR::DoubleInjection#bind injects a method that acts as a dispatcher
|
@@ -39,8 +39,8 @@ module RR
|
|
39
39
|
# RR::DoubleInjection#verify verifies each Double
|
40
40
|
# TimesCalledExpectation are met.
|
41
41
|
def verify
|
42
|
-
@
|
43
|
-
|
42
|
+
@doubles.each do |double|
|
43
|
+
double.verify
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -74,42 +74,42 @@ module RR
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def call_method(args, block)
|
77
|
-
if
|
78
|
-
return
|
77
|
+
if double = find_double_to_attempt(args)
|
78
|
+
return double.call(self, *args, &block)
|
79
79
|
end
|
80
|
-
|
80
|
+
double_not_found_error(*args)
|
81
81
|
end
|
82
82
|
|
83
|
-
def
|
84
|
-
matches = DoubleMatches.new(@
|
83
|
+
def find_double_to_attempt(args)
|
84
|
+
matches = DoubleMatches.new(@doubles).find_all_matches!(args)
|
85
85
|
|
86
|
-
unless matches.
|
87
|
-
return matches.
|
86
|
+
unless matches.exact_terminal_doubles_to_attempt.empty?
|
87
|
+
return matches.exact_terminal_doubles_to_attempt.first
|
88
88
|
end
|
89
89
|
|
90
|
-
unless matches.
|
91
|
-
return matches.
|
90
|
+
unless matches.exact_non_terminal_doubles_to_attempt.empty?
|
91
|
+
return matches.exact_non_terminal_doubles_to_attempt.last
|
92
92
|
end
|
93
93
|
|
94
|
-
unless matches.
|
95
|
-
return matches.
|
94
|
+
unless matches.wildcard_terminal_doubles_to_attempt.empty?
|
95
|
+
return matches.wildcard_terminal_doubles_to_attempt.first
|
96
96
|
end
|
97
97
|
|
98
|
-
unless matches.
|
99
|
-
return matches.
|
98
|
+
unless matches.wildcard_non_terminal_doubles_to_attempt.empty?
|
99
|
+
return matches.wildcard_non_terminal_doubles_to_attempt.last
|
100
100
|
end
|
101
101
|
|
102
|
-
unless matches.
|
102
|
+
unless matches.matching_doubles.empty?
|
103
103
|
# This will raise a TimesCalledError
|
104
|
-
return matches.
|
104
|
+
return matches.matching_doubles.first
|
105
105
|
end
|
106
106
|
|
107
107
|
return nil
|
108
108
|
end
|
109
109
|
|
110
|
-
def
|
110
|
+
def double_not_found_error(*args)
|
111
111
|
message = "Unexpected method invocation #{Double.formatted_name(@method_name, args)}, expected\n"
|
112
|
-
message << Double.list_message_part(@
|
112
|
+
message << Double.list_message_part(@doubles)
|
113
113
|
raise Errors::DoubleNotFoundError, message
|
114
114
|
end
|
115
115
|
|
data/lib/rr/double_matches.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
module RR
|
2
2
|
class DoubleMatches
|
3
|
-
attr_reader :
|
4
|
-
:
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
8
|
-
def initialize(
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
3
|
+
attr_reader :matching_doubles,
|
4
|
+
:exact_terminal_doubles_to_attempt,
|
5
|
+
:exact_non_terminal_doubles_to_attempt,
|
6
|
+
:wildcard_terminal_doubles_to_attempt,
|
7
|
+
:wildcard_non_terminal_doubles_to_attempt
|
8
|
+
def initialize(doubles) #:nodoc:
|
9
|
+
@doubles = doubles
|
10
|
+
@matching_doubles = []
|
11
|
+
@exact_terminal_doubles_to_attempt = []
|
12
|
+
@exact_non_terminal_doubles_to_attempt = []
|
13
|
+
@wildcard_terminal_doubles_to_attempt = []
|
14
|
+
@wildcard_non_terminal_doubles_to_attempt = []
|
15
15
|
end
|
16
16
|
|
17
17
|
def find_all_matches!(args)
|
18
|
-
@
|
19
|
-
if
|
20
|
-
|
21
|
-
if
|
22
|
-
|
18
|
+
@doubles.each do |double|
|
19
|
+
if double.exact_match?(*args)
|
20
|
+
matching_doubles << double
|
21
|
+
if double.attempt?
|
22
|
+
exact_double_is_terminal_or_non_terminal double
|
23
23
|
end
|
24
|
-
elsif
|
25
|
-
|
26
|
-
if
|
27
|
-
|
24
|
+
elsif double.wildcard_match?(*args)
|
25
|
+
matching_doubles << double
|
26
|
+
if double.attempt?
|
27
|
+
wildcard_double_is_terminal_or_non_terminal double
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -32,19 +32,19 @@ class DoubleMatches
|
|
32
32
|
end
|
33
33
|
|
34
34
|
protected
|
35
|
-
def
|
36
|
-
if
|
37
|
-
|
35
|
+
def exact_double_is_terminal_or_non_terminal(double)
|
36
|
+
if double.terminal?
|
37
|
+
exact_terminal_doubles_to_attempt << double
|
38
38
|
else
|
39
|
-
|
39
|
+
exact_non_terminal_doubles_to_attempt << double
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
if
|
45
|
-
|
43
|
+
def wildcard_double_is_terminal_or_non_terminal(double)
|
44
|
+
if double.terminal?
|
45
|
+
wildcard_terminal_doubles_to_attempt << double
|
46
46
|
else
|
47
|
-
|
47
|
+
wildcard_non_terminal_doubles_to_attempt << double
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module RR
|
2
2
|
module Expectations
|
3
3
|
class TimesCalledExpectation #:nodoc:
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :double, :times_called
|
5
5
|
attr_accessor :matcher
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(double, matcher=nil)
|
8
|
+
@double = double
|
9
9
|
@matcher = matcher
|
10
10
|
@times_called = 0
|
11
11
|
@verify_backtrace = caller[1..-1]
|
@@ -48,7 +48,7 @@ module RR
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def error_message
|
51
|
-
"#{
|
51
|
+
"#{double.formatted_name}\n#{@matcher.error_message(@times_called)}"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
data/lib/rr/space.rb
CHANGED
@@ -15,15 +15,15 @@ module RR
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
attr_reader :double_insertions, :
|
18
|
+
attr_reader :double_insertions, :ordered_doubles
|
19
19
|
attr_accessor :trim_backtrace
|
20
20
|
def initialize
|
21
21
|
@double_insertions = HashWithObjectIdKey.new
|
22
|
-
@
|
22
|
+
@ordered_doubles = []
|
23
23
|
@trim_backtrace = false
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def double_method_proxy(creator, object, method_name=nil, &definition)
|
27
27
|
if method_name && definition
|
28
28
|
raise ArgumentError, "Cannot pass in a method name and a block"
|
29
29
|
end
|
@@ -33,19 +33,19 @@ module RR
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# Creates a DoubleCreator.
|
36
|
-
def
|
36
|
+
def double_creator
|
37
37
|
DoubleCreator.new(self)
|
38
38
|
end
|
39
39
|
|
40
40
|
# Creates and registers a Double to be verified.
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
double_insertion.
|
45
|
-
|
41
|
+
def double(double_insertion, definition = double_definition)
|
42
|
+
double = Double.new(self, double_insertion, definition)
|
43
|
+
double.definition.double = double
|
44
|
+
double_insertion.register_double double
|
45
|
+
double
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def double_definition
|
49
49
|
DoubleDefinition.new(self)
|
50
50
|
end
|
51
51
|
|
@@ -64,25 +64,25 @@ module RR
|
|
64
64
|
end
|
65
65
|
|
66
66
|
# Registers the ordered Double to be verified.
|
67
|
-
def
|
68
|
-
@
|
67
|
+
def register_ordered_double(double)
|
68
|
+
@ordered_doubles << double
|
69
69
|
end
|
70
70
|
|
71
71
|
# Verifies that the passed in ordered Double is being called
|
72
72
|
# in the correct position.
|
73
|
-
def
|
74
|
-
unless
|
73
|
+
def verify_ordered_double(double)
|
74
|
+
unless double.terminal?
|
75
75
|
raise Errors::DoubleOrderError,
|
76
76
|
"Ordered Doubles cannot have a NonTerminal TimesCalledExpectation"
|
77
77
|
end
|
78
|
-
unless @
|
79
|
-
message = Double.formatted_name(
|
78
|
+
unless @ordered_doubles.first == double
|
79
|
+
message = Double.formatted_name(double.method_name, double.expected_arguments)
|
80
80
|
message << " called out of order in list\n"
|
81
|
-
message << Double.list_message_part(@
|
81
|
+
message << Double.list_message_part(@ordered_doubles)
|
82
82
|
raise Errors::DoubleOrderError, message
|
83
83
|
end
|
84
|
-
@
|
85
|
-
|
84
|
+
@ordered_doubles.shift unless double.attempt?
|
85
|
+
double
|
86
86
|
end
|
87
87
|
|
88
88
|
# Verifies all the DoubleInjection objects have met their
|
@@ -97,7 +97,7 @@ module RR
|
|
97
97
|
|
98
98
|
# Resets the registered Doubles and ordered Doubles
|
99
99
|
def reset
|
100
|
-
|
100
|
+
reset_ordered_doubles
|
101
101
|
reset_double_insertions
|
102
102
|
end
|
103
103
|
|
@@ -117,8 +117,8 @@ module RR
|
|
117
117
|
|
118
118
|
protected
|
119
119
|
# Removes the ordered Doubles from the list
|
120
|
-
def
|
121
|
-
@
|
120
|
+
def reset_ordered_doubles
|
121
|
+
@ordered_doubles.clear
|
122
122
|
end
|
123
123
|
|
124
124
|
# Resets the registered Doubles for the next test run.
|