Displaying 3 results from an estimated 3 matches for "parameters_to_yield".
2006 Sep 29
2
multiyield
...================================
--- lib/mocha/expectation.rb (revision 62)
+++ lib/mocha/expectation.rb (working copy)
@@ -26,6 +26,10 @@
@yield = nil
end
+ def multiyield?
+ @multiyield
+ end
+
def yield?
@yield
end
@@ -178,6 +182,12 @@
@parameters_to_yield = parameters
self
end
+
+ def multiyield(*parameters)
+ @multiyield = true
+ @parameters_to_yield = parameters
+ self
+ end
# :call-seq: returns(value) -> expectation
# :call-seq: returns(*values) -> expectation
@@ -218,6 +228,7 @@
def invo...
2006 Sep 29
1
yielding consecutive values
...t_equal 99, expectation.invoke
Index: lib/mocha/expectation.rb
===================================================================
--- lib/mocha/expectation.rb (revision 62)
+++ lib/mocha/expectation.rb (working copy)
@@ -217,7 +217,12 @@
def invoke
@invoked += 1
- yield(*@parameters_to_yield) if yield? and block_given?
+ if yield? and block_given?
+ params = @parameters_to_yield.collect do |element|
+ element.is_a?(Proc) ? element.call : element
+ end
+ yield(*params)
+ end
@return_value.is_a?(Proc) ? @return_value.call : @return_value...
2006 Sep 22
2
foo.expects(:blah).returns(10).then(11) syntax
...lue
+ @return_value ||= []
+ end
def raises(exception = RuntimeError, message = nil)
- @return_value = lambda{ raise exception, message }
+ return_value << lambda{ raise exception, message }
self
end
def invoke
@invoked += 1
yield(*@parameters_to_yield) if yield? and block_given?
- @return_value.is_a?(Proc) ? @return_value.call : @return_value
+ this_return = return_value.size > 1 ? return_value.shift :
return_value.first
+ this_return.is_a?(Proc) ? this_return.call : this_return
end
def verify