Skip to content

Instantly share code, notes, and snippets.

@jstewart
Created September 2, 2009 19:48
Show Gist options
  • Save jstewart/179927 to your computer and use it in GitHub Desktop.
Save jstewart/179927 to your computer and use it in GitHub Desktop.
def self.should_delegate(*options)
klass = self.name.gsub(/Test$/, '').constantize
receiver = options.pop[:to]
context "#{klass}" do
setup do
klass.any_instance.stubs(receiver).returns(receiver_stub = stub)
options.each { |opt| receiver_stub.expects(opt) }
end
should "delegate methods to receiving object" do
instance = get_instance_of(klass)
options.each { |opt| instance.send(receiver).send(opt) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment