Created
May 25, 2012 10:36
-
-
Save gnufied/2787219 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def should_chain_receive(*args,&block) | |
current_object = self | |
args[0..-2].each do |argument| | |
temp = Object.new() | |
current_object.should_receive(argument).and_return(temp) | |
current_object = temp | |
end | |
result = yield | |
current_object.should_receive(args.last).and_return result | |
end | |
end | |
# usage: | |
User.should_chain_receive(:active,:paginate) { @users } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment