rr 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/Rakefile +1 -1
- data/lib/rr/double.rb +16 -0
- data/lib/rr/double_definition.rb +15 -0
- data/spec/rr/double_definition_spec.rb +597 -587
- data/spec/rr/double_spec.rb +133 -90
- metadata +2 -2
data/CHANGES
CHANGED
data/Rakefile
CHANGED
data/lib/rr/double.rb
CHANGED
@@ -146,6 +146,19 @@ module RR
|
|
146
146
|
definition.ordered?
|
147
147
|
end
|
148
148
|
|
149
|
+
# Double#verbose sets the Double to print out each method call it receives.
|
150
|
+
#
|
151
|
+
# Passing in a block sets the return value
|
152
|
+
def verbose(&block)
|
153
|
+
definition.verbose(&block)
|
154
|
+
end
|
155
|
+
|
156
|
+
# Double#verbose? returns true when verbose has been called on it. It returns
|
157
|
+
# true when the double is set to print each method call it receives.
|
158
|
+
def verbose?
|
159
|
+
definition.verbose?
|
160
|
+
end
|
161
|
+
|
149
162
|
# Double#yields sets the Double to invoke a passed in block when
|
150
163
|
# the Double is called.
|
151
164
|
# An Expection will be raised if no block is passed in when the
|
@@ -217,6 +230,9 @@ module RR
|
|
217
230
|
# A TimesCalledError is raised when the times called
|
218
231
|
# exceeds the expected TimesCalledExpectation.
|
219
232
|
def call(double_injection, *args, &block)
|
233
|
+
if verbose?
|
234
|
+
puts Double.formatted_name(double_injection.method_name, args)
|
235
|
+
end
|
220
236
|
self.times_called_expectation.attempt! if definition.times_matcher
|
221
237
|
@space.verify_ordered_double(self) if ordered?
|
222
238
|
yields!(block)
|
data/lib/rr/double_definition.rb
CHANGED
@@ -202,6 +202,21 @@ module RR
|
|
202
202
|
self
|
203
203
|
end
|
204
204
|
|
205
|
+
# Double#verbose sets the Double to print out each method call it receives.
|
206
|
+
#
|
207
|
+
# Passing in a block sets the return value
|
208
|
+
def verbose(&block)
|
209
|
+
@verbose = true
|
210
|
+
@after_call_value = block
|
211
|
+
self
|
212
|
+
end
|
213
|
+
|
214
|
+
# Double#verbose? returns true when verbose has been called on it. It returns
|
215
|
+
# true when the double is set to print each method call it receives.
|
216
|
+
def verbose?
|
217
|
+
@verbose ? true : false
|
218
|
+
end
|
219
|
+
|
205
220
|
# Double#returns accepts an argument value or a block.
|
206
221
|
# It will raise an ArgumentError if both are passed in.
|
207
222
|
#
|