Sha256: eb9eaecb2e9de6c648bc3d491ef12f32b510239302353fa83c09f97b7513c697

Contents?: true

Size: 829 Bytes

Versions: 12

Compression:

Stored size: 829 Bytes

Contents

require 'spec_helper'

describe SpudInquiryForm do

  it {should have_many(:spud_inquiries)}
  it {should have_many(:spud_inquiry_form_fields)}

  describe :validations do
    it "should be invalid if name is blank" do
      p = FactoryGirl.build(:spud_inquiry_form, :name => nil)
      p.should_not be_valid
    end

    it "should require a unique name" do
      p = FactoryGirl.create(:spud_inquiry_form, :name => "Test")
      p2 = FactoryGirl.build(:spud_inquiry_form, :name => "Test")
      p2.should_not be_valid
    end
  end

  describe :hooks do
    it "should generate a url_name before validating" do
      p = FactoryGirl.build(:spud_inquiry_form, :name => "Contact Us")
      p.should be_valid
      p.url_name.should == p.name.gsub(/[^a-zA-Z0-9\ ]/," ").gsub(/\ \ +/," ").gsub(/\ /,"-").downcase
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
spud_inquiries-1.0.1 spec/models/spud_inquiry_form_spec.rb
spud_inquiries-1.0.0 spec/models/spud_inquiry_form_spec.rb
tb_inquiries-1.0.1 spec/models/spud_inquiry_form_spec.rb
spud_inquiries-1.0.0.rc4 spec/models/spud_inquiry_form_spec.rb
spud_inquiries-1.0.0.rc3 spec/models/spud_inquiry_form_spec.rb
spud_inquiries-1.0.0.rc2 spec/models/spud_inquiry_form_spec.rb
tb_inquiries-1.0.0 spec/models/spud_inquiry_form_spec.rb
spud_inquiries-1.0.0.rc1.1 spec/models/spud_inquiry_form_spec.rb
spud_inquiries-1.0.0.rc1 spec/models/spud_inquiry_form_spec.rb
spud_inquiries-0.9.5 spec/models/spud_inquiry_form_spec.rb
spud_inquiries-0.9.3 spec/models/spud_inquiry_form_spec.rb
spud_inquiries-0.9.2 spec/models/spud_inquiry_form_spec.rb