Skip to content

Instantly share code, notes, and snippets.

@christoph-buente
Created May 25, 2009 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christoph-buente/117566 to your computer and use it in GitHub Desktop.
Save christoph-buente/117566 to your computer and use it in GitHub Desktop.
module Spec
module Mocks
module Methods
def stub_association!(association_name, methods_to_be_stubbed = {})
mock_association = Spec::Mocks::Mock.new(association_name.to_s)
methods_to_be_stubbed.each do |method, return_value|
mock_association.stub!(method).and_return(return_value)
end
self.stub!(association_name).and_return(mock_association)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment