Permalink
Browse files

added some fancy category model tests

  • Loading branch information...
1 parent 20735af commit a8ccbfc21345c3304c0fb1c31fd6eadd4a5832d6 @janpieper janpieper committed Apr 28, 2012
Showing with 18 additions and 1 deletion.
  1. +18 −1 spec/models/category_spec.rb
View
19 spec/models/category_spec.rb
@@ -1,5 +1,22 @@
require 'spec_helper'
describe Category do
- pending "add some examples to (or delete) #{__FILE__}"
+ describe "Validation" do
+ it "should not allow names with less than 3 characters" do
+ Category.new(:name => "XX").should_not be_valid
+ end
+
+ it "should not allow names with more than 25 characters" do
+ Category.new(:name => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").should_not be_valid
+ end
+
+ it "should not be possible to use an empty name" do
+ Category.new(:name => nil).should_not be_valid
+ end
+
+ it "should not be possible to use a name twice" do
+ Category.create!(:name => "Music")
+ Category.new(:name => "Music").should_not be_valid
+ end
+ end
end

0 comments on commit a8ccbfc

Please sign in to comment.