Sha256: bad8087095f0a6d657722e2e380bba7553fd5827d99fd2bbee75e7a8014a8dd0
Contents?: true
Size: 915 Bytes
Versions: 1
Compression:
Stored size: 915 Bytes
Contents
require 'spec_helper' describe CpfValidator do context "when cpf is invalid" do before :each do @user = User.new(:cpf => "12345") I18n.stub(:t).with("activerecord.errors.models.user.attributes.cpf.invalid").and_return("is invalid") end it "should set object as invalid" do @user.valid?.should be_false end it "should set an error message on attribute" do @user.valid? @user.errors[:cpf].should == ['is invalid'] end end context "when cpf is valid" do before :each do @user = User.new(:cpf => "11144477735") end it "should set object as valid" do @user.valid?.should be_true end it "should not set an error message on attribute" do @user.valid? @user.errors[:cpf].should be_blank end end it "should accept a nil value" do @user = User.new(:cpf => nil) @user.valid?.should be_true end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
validates_cpf-1.1.0 | spec/validates_cpf_spec.rb |