Skip to content

Instantly share code, notes, and snippets.

@nazgob
Created March 15, 2012 21:22
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 nazgob/2047053 to your computer and use it in GitHub Desktop.
Save nazgob/2047053 to your computer and use it in GitHub Desktop.
should test your models like a pro
should validate_presence_of(:name)
should ensure_length_of(:name).is_at_most(15)
should ensure_length_of(:name).is_at_least(5)
should ensure_length_of(:name).is_at_least(5).is_at_most(15)
should have_many(:tweets)
should validate_uniqueness_of(:name)
should validate_numericality_of(:age)
should_not allow_value("wutlol").for(:email)
should allow_value("a@b.com").for(:email)
should ensure_inclusion_of(:age).in_range(1..100)
should_not allow_mass_assignment_of(:password)
should belong_to(:me)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment