Skip to content

Instantly share code, notes, and snippets.

@gnufied
Created May 25, 2012 10:36
Show Gist options
  • Save gnufied/2787219 to your computer and use it in GitHub Desktop.
Save gnufied/2787219 to your computer and use it in GitHub Desktop.
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