Sha256: a150a5dbfbc74d175b1912ac13d68d1a7cba8c9a07f1429222db544a655ea532

Contents?: true

Size: 905 Bytes

Versions: 6

Compression:

Stored size: 905 Bytes

Contents

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

describe 'A model with a :set & :default options on a property' do
  before :all do
    class ::LimitedBoat
      include DataMapper::Resource
      property :id,      DataMapper::Property::Serial
      property :limited, String, :set => %w[ foo bar bang ], :default => 'foo'
    end
  end

  describe "without value on that property" do
    before :all do
      @model = LimitedBoat.new
    end

    # default value is respected
    it_should_behave_like "valid model"
  end

  describe "without value on that property that is not in allowed range/set" do
    before :all do
      @model = LimitedBoat.new(:limited => "blah")
    end

    it_should_behave_like "invalid model"

    it "has a meaningful error message" do
      @model.errors.on(:limited).should == [ 'Limited must be one of foo, bar, bang' ]
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dm-validations-1.1.0 spec/integration/automatic_validation/inferred_within_validation_spec.rb
dm-validations-1.1.0.rc3 spec/integration/automatic_validation/inferred_within_validation_spec.rb
dm-validations-1.1.0.rc2 spec/integration/automatic_validation/inferred_within_validation_spec.rb
dm-validations-1.1.0.rc1 spec/integration/automatic_validation/inferred_within_validation_spec.rb
dm-validations-1.0.2 spec/integration/automatic_validation/inferred_within_validation_spec.rb
dm-validations-1.0.1 spec/integration/automatic_validation/inferred_within_validation_spec.rb