Sha256: cdc4c27f4a24d47ff8d818fd6cdff6aea55fee203423dbd09ba94bc42a1f2b0b

Contents?: true

Size: 1.56 KB

Versions: 32

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe Comment do
  
  describe "should not be valid if it" do

    let(:comment) { build(:comment) }

    # nickname is a honey-pot
    it "has a value for nickname" do
      comment.nickname = "Gavin"
      comment.should_not be_valid
      comment.should have(1).error_on(:nickname)
    end

    it "doesn't have a value for name" do
      comment.name = ""
      comment.should_not be_valid
      comment.should have(1).error_on(:name)
    end

    it "doesn't have a value for email" do
      comment.email = ""
      comment.should_not be_valid
      comment.should have(1).error_on(:email)
    end

    it "doesn't have a valid email" do
      comment.email = "notvalid.com"
      comment.should_not be_valid
      comment.should have(1).error_on(:email)

      # has a space
      comment.email = "something else"
      comment.should_not be_valid
      comment.should have(1).error_on(:email)

      # Has two @s
      comment.email = "gavin@gavin@notvalid.com"
      comment.should_not be_valid
      comment.should have(1).error_on(:email)
    end

    it "doesn't have a value for body" do
      comment.body = ""
      comment.should_not be_valid
      comment.should have(1).error_on(:body)
    end

    it "doesn't have at least 4 characters in the body" do
      comment.body = "abc"
      comment.should_not be_valid
      comment.should have(1).error_on(:body)
    end
    
    it "doesn't have a valid website url" do
      comment.website = "not valid"
      comment.should_not be_valid
      comment.should have(1).error_on(:website)
    end

  end
  
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
blogit-admin-0.0.1 spec/models/blogit/comment_spec.rb
blogit-1.0.0.rc1 spec/models/blogit/comment_spec.rb
blogit-0.8.0 spec/models/blogit/comment_spec.rb
blogit-0.7.0 spec/models/blogit/comment_spec.rb
blogit-0.6.0 spec/models/blogit/comment_spec.rb
blogit-0.5.1 spec/models/blogit/comment_spec.rb
blogit-0.5.0 spec/models/blogit/comment_spec.rb
blogit-0.4.8 spec/models/blogit/comment_spec.rb
blogit-0.4.7 spec/models/blogit/comment_spec.rb
blogit-0.4.6 spec/models/blogit/comment_spec.rb
blogit-0.4.5 spec/models/blogit/comment_spec.rb
blogit-0.4.4 spec/models/blogit/comment_spec.rb
blogit-0.4.3 spec/models/blogit/comment_spec.rb
blogit-0.4.2 spec/models/blogit/comment_spec.rb
blogit-0.4.1 spec/models/blogit/comment_spec.rb
blogit-0.4.0 spec/models/blogit/comment_spec.rb
blogit-0.3.2 spec/models/blogit/comment_spec.rb
blogit-0.3.1 spec/models/blogit/comment_spec.rb
blogit-0.3.0 spec/models/blogit/comment_spec.rb
blogit-0.2.1 spec/models/blogit/comment_spec.rb