rr 0.4.5 → 0.4.6

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/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ * 0.4.6
2
+ - Added Double#verbose and Double#verbose?
3
+
1
4
  * 0.4.5
2
5
  - Fixed doubles for == and #eql? methods
3
6
 
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ def run_suite
26
26
  end
27
27
 
28
28
  PKG_NAME = "rr"
29
- PKG_VERSION = "0.4.5"
29
+ PKG_VERSION = "0.4.6"
30
30
  PKG_FILES = FileList[
31
31
  '[A-Z]*',
32
32
  '*.rb',
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)
@@ -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
  #