Skip to content

Instantly share code, notes, and snippets.

@jherdman
Created September 8, 2010 00:06
Show Gist options
  • Save jherdman/569367 to your computer and use it in GitHub Desktop.
Save jherdman/569367 to your computer and use it in GitHub Desktop.
##
# Helpers for mocking and stubbing using RR
module MockingAndStubbingHelper
# @param [#new] model The model class that you wish to have a stubbed instance of
#
# @return An instance of the provided model that quacks like an existing record
def stub_model(model)
stub(instance = model.new) do
new_record? { false }
end
instance.id = instance.object_id
instance
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment