Skip to content

Instantly share code, notes, and snippets.

@macournoyer
Created November 18, 2008 19:40
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 macournoyer/26234 to your computer and use it in GitHub Desktop.
Save macournoyer/26234 to your computer and use it in GitHub Desktop.
class User
has_many :cats
end
class UserTest < Test::Unit::TestCase
# Useless
should_have_many :cats
# Useful
def test_should_add_a_cat
user = User.create
cat = user.cats.create(:name => "Bob")
assert_valid cat
assert_equal user, cat.reload.user
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment