Sha256: bce1747a31f328029c38d191c1f705231b3e766bcd79465691358ae2f8c3628c

Contents?: true

Size: 1.54 KB

Versions: 7

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'
require 'integration/automatic_validation/spec_helper'

describe "A model with an Integer property" do
  before :all do
    SailBoat.auto_migrate!

    @model = SailBoat.new
  end

  describe "assigned to an integer" do
    before :all do
      @model.set(:id => 1)
    end

    it_should_behave_like "valid model"
  end

  describe "assigned to a float" do
    before :all do
      @model.set(:id => 1.0)
    end

    it "is invalid" do
      @model.should_not be_valid
    end

    it "has a meaningful default error message" do
      @model.errors.on(:id).should == [ 'Id must be an integer' ]
    end
  end

  describe "assigned to a BigDecimal" do
    before :all do
      @model.set(:id => BigDecimal('1'))
    end

    it "is invalid" do
      @model.should_not be_valid
    end

    it "has a meaningful default error message" do
      @model.errors.on(:id).should == [ 'Id must be an integer' ]
    end
  end

  describe "assigned to a too-small integer" do
    before :all do
      @model.set(:id => 0)
    end

    it "is invalid" do
      @model.should_not be_valid
    end

    it "has a meaningful default error message" do
      @model.errors.on(:id).should == [ 'Id must be greater than or equal to 1' ]
    end
  end

  describe "assigned to a too-large integer" do
    before :all do
      @model.set(:id => 11)
    end

    it "is invalid" do
      @model.should_not be_valid
    end

    it "has a meaningful default error message" do
      @model.errors.on(:id).should == [ 'Id must be less than or equal to 10' ]
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dm-validations-1.0.2 spec/integration/automatic_validation/inferred_integer_properties_validation_spec.rb
dm-validations-1.0.1 spec/integration/automatic_validation/inferred_integer_properties_validation_spec.rb
dm-validations-1.0.0 spec/integration/automatic_validation/inferred_integer_properties_validation_spec.rb
dm-validations-1.0.0.rc3 spec/integration/automatic_validation/inferred_integer_properties_validation_spec.rb
dm-validations-1.0.0.rc2 spec/integration/automatic_validation/inferred_integer_properties_validation_spec.rb
dm-validations-1.0.0.rc1 spec/integration/automatic_validation/inferred_integer_properties_validation_spec.rb
dm-validations-0.10.2 spec/integration/automatic_validation/inferred_integer_properties_validation_spec.rb