Skip to content

Instantly share code, notes, and snippets.

Created February 2, 2010 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/292948 to your computer and use it in GitHub Desktop.
Save anonymous/292948 to your computer and use it in GitHub Desktop.
it "should not be valid without a name" do
@category = Category.new @valid_attributes
@category.name = nil
@category.should have(1).errors_on(:name)
end
it "should not be valid with a name having less than 3 or more than 100 characters, if name is given" do
@category = Category.new @valid_attributes
@category.name = 'to'
@category.should have(1).errors_on(:name)
@category.errors.on(:name).should include "too short"
@category = Category.new @valid_attributes
@category.name = 't'*101
@category.should have(1).errors_on(:name)
@category.errors.on(:name).should include "too long"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment