Permalink
Browse files

Object#stub_chain rules!

  • Loading branch information...
1 parent abd305e commit 7a48dd2deb35ea5840f7b3841414456b2428a3f8 GIT_AUTHOR_NAME committed May 20, 2009
Showing with 9 additions and 0 deletions.
  1. +9 −0 spec/spec_helper.rb
View
@@ -132,3 +132,12 @@ def has_dollar_field(clazz, field_name)
rec.send(cents_field).should == 1234
end
end
+
+class Object
+ def stub_chain(*methods)
+ while methods.length > 1 do
+ stub!(methods.shift).and_return(self)
+ end
+ stub!(methods.shift)
+ end
+end

0 comments on commit 7a48dd2

Please sign in to comment.