Sha256: ca156d6eafde6522c8e61926ecf6480b0ac8b5b03b83c41d049541d17dcf5ff4

Contents?: true

Size: 726 Bytes

Versions: 10

Compression:

Stored size: 726 Bytes

Contents

require 'spec_helper'

describe "Validations extension" do
  
  subject { Person.new }
  
  its(:valid?) { should be_false }
  
  [:name, :human].each do |a|
    it "should list #{a} among its errors" do
      subject.valid?
      subject.errors.to_hash.has_key?(a).should be_true
    end
  end
  
  it "should not allow creating a record if it is invalid" do
    subject.create.should be_false
    subject.errors.size.should == 2
  end
  
  it "should not allow updating record if it is invalid" do
    subject.name = "Neo"
    subject.human = true
    subject.vita = "Bad ass charcater who kicks everybody's ass."
    subject.create.should be_true
    
    subject.name = nil
    subject.update.should be_false
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
architect4r-0.4.3.1 spec/model/validations_spec.rb
architect4r-0.4.3 spec/model/validations_spec.rb
architect4r-0.4.2 spec/model/validations_spec.rb
architect4r-0.4.1 spec/model/validations_spec.rb
architect4r-0.4 spec/model/validations_spec.rb
architect4r-0.3.4.2 spec/model/validations_spec.rb
architect4r-0.3.4.1 spec/model/validations_spec.rb
architect4r-0.3.4 spec/model/validations_spec.rb
architect4r-0.3.3.1 spec/model/validations_spec.rb
architect4r-0.3.2 spec/model/validations_spec.rb