Sha256: a3969e14d61812c3a35c556d404b9d847e61898ab1d56208a87c641baa0960a6

Contents?: true

Size: 841 Bytes

Versions: 6

Compression:

Stored size: 841 Bytes

Contents

require 'spec_helper'

describe CnpjValidator do
  context "when cnpj is invalid" do
    before :each do
      @company = Company.new(:cnpj => "12345")
    end

    it "should set object as invalid" do
      @company.valid?.should be_false
    end

    it "should set an error on attribute" do
      @company.valid?
      @company.errors[:cnpj].should == ['is invalid']
    end
  end

  context "when cnpj is valid" do
    before :each do
      @company = Company.new(:cnpj => "37525685000108")
    end

    it "should set object as valid" do
      @company.valid?.should be_true
    end

    it "should not set an error on attribute" do
      @company.valid?
      @company.errors[:cnpj].should be_blank
    end
  end

  it "should accept a nil value" do
    @company = Company.new(:cnpj => nil)
    @company.valid?.should be_true
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
validates_cnpj-1.1.1 spec/validates_cnpj_spec.rb
validates_cnpj-1.0.0 spec/validates_cnpj_spec.rb
validates_cnpj-0.1.2 spec/validates_cnpj_spec.rb
validates_cnpj-0.1.1 spec/validates_cnpj_spec.rb
validates_cnpj-0.1.0 spec/validates_cnpj_spec.rb
validates_cnpj-0.0.1 spec/validates_cnpj_spec.rb