Sha256: 0d60cf4e7f00e309f8a4ace6487626ad630d33e21288ae1201beece439727c92

Contents?: true

Size: 1.19 KB

Versions: 15

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'
require 'integration/length_validator/spec_helper'

describe "barcode with invalid code length", :shared => true do
  it "has a meaninful error message with length restrictions mentioned" do
    @model.errors.on(:code).should == [ 'Code must be at most 10 characters long' ]
  end
end

describe 'DataMapper::Validations::Fixtures::Barcode' do
  before :all do
    DataMapper::Validations::Fixtures::Barcode.auto_migrate!

    @model = DataMapper::Validations::Fixtures::Barcode.valid_instance
  end

  it_should_behave_like "valid model"

  describe "with a 17 characters long code" do
    before :all do
      @model.code = "18283849284728124"
      @model.valid?
    end

    it_should_behave_like "invalid model"

    it_should_behave_like "barcode with invalid code length"
  end

  describe "with a 7 characters long code" do
    before :all do
      @model.code = "8372786"
      @model.valid?
    end

    it_should_behave_like "valid model"
  end

  describe "with an 11 characters long code" do
    before :all do
      @model.code = "83727868754"
      @model.valid?
    end

    it_should_behave_like "invalid model"

    it_should_behave_like "barcode with invalid code length"
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
ardm-validations-1.2.0 spec/integration/length_validator/maximum_spec.rb
aequitas-0.0.1 spec_legacy/integration/length_validator/maximum_spec.rb
dm-validations-1.2.0 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.2.0.rc2 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.2.0.rc1 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.1.0 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.1.0.rc3 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.1.0.rc2 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.1.0.rc1 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.0.2 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.0.1 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.0.0 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.0.0.rc3 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.0.0.rc2 spec/integration/length_validator/maximum_spec.rb
dm-validations-1.0.0.rc1 spec/integration/length_validator/maximum_spec.rb