Skip to content

Instantly share code, notes, and snippets.

@larrywright
Created April 21, 2009 02:39
Show Gist options
  • Save larrywright/98901 to your computer and use it in GitHub Desktop.
Save larrywright/98901 to your computer and use it in GitHub Desktop.
class PostTest < Test::Unit::TestCase
fixtures :all
should_belong_to :user
should_have_many :tags, :through => :taggings
should_validate_uniqueness_of :title
should_validate_presence_of :body, :message => /wtf/
should_validate_presence_of :title
should_validate_numericality_of :user_id
end
class UserTest < Test::Unit::TestCase
should_have_many :posts
should_not_allow_values_for :email, "blah", "b lah"
should_allow_values_for :email, "a@b.com", "asdf@asdf.com"
should_ensure_length_in_range :email, 1..100
should_ensure_value_in_range :age, 1..100
should_not_allow_mass_assignment_of :password
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment