Skip to content

Instantly share code, notes, and snippets.

@ldenman
Forked from anonymous/gist:292948
Created February 2, 2010 19:50
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 ldenman/292955 to your computer and use it in GitHub Desktop.
Save ldenman/292955 to your computer and use it in GitHub Desktop.
test
# for testing validates_length_of :name, :within => 3..100, :allow_nil => true
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