Skip to content

Instantly share code, notes, and snippets.

@tatey
Last active December 10, 2015 03:48
Show Gist options
  • Select an option

  • Save tatey/4376776 to your computer and use it in GitHub Desktop.

Select an option

Save tatey/4376776 to your computer and use it in GitHub Desktop.
# Person has a polymorphic relationship called contactable.
# We want the person's contactable method to return a contact
# of our choosing.
contact = Contact.new
real_person = Person.find(1)
mock_person = SimpleMock.new(real_person)
mock_person.expect(:contactable, contact)
mock_person.contact == contact # => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment