Please sign in to comment.
As Tobias Crawley correctly pointed out in feature request #23055 "st…
…ubs(with_hash) not working with existing object" , following the principle of least surprise, it should be possible to call ObjectMethods#expects & ObjectMethods#stubs with a Hash of method_names vs return_values like you can with Mock#expects & Mock#stubs. I've extracted out some shared logic into the ArgumentIterator - not sure this is the best solution, but at least it keeps duplication to a minimum. I've also updated & improved the docs to reflect the changes.  http://rubyforge.org/tracker/index.php?func=detail&aid=23055&group_id=1917&atid=7480
- Loading branch information...
Showing with 136 additions and 40 deletions.
|@@ -0,0 +1,21 @@|
|+ class ArgumentIterator|
|+ def initialize(argument)|
|+ @argument = argument|
|+ def each(&block)|
|+ if @argument.is_a?(Hash) then|
|+ @argument.each do |method_name, return_value||
|+ block.call(method_name, return_value)|