Created
April 11, 2012 12:51
-
-
Save distributedlife/2359122 to your computer and use it in GitHub Desktop.
Is this necessary?
This file contains 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
def with object | |
yield(object) | |
end | |
#so I can do this: | |
with Project.create do |project| | |
Task.create(:project_id => project.id) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your
with
version reads nicely, and equivalent to:If Task and Project are ActiveRecord models, you could use:
And if it's an integration test setup, you might consider FactoryGirl or Machinist.