Created
September 8, 2010 00:06
-
-
Save jherdman/569367 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# 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