Sha256: 2c5772b36b584f36163f1da3cf89be7c95ad07d63ea84d3e930a5432304177a6

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 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::Validate::Fixtures::Barcode' do
  before :all do
    DataMapper::Validate::Fixtures::Barcode.auto_migrate!

    @model = DataMapper::Validate::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

1 entries across 1 versions & 1 rubygems

Version Path
dm-validations-0.10.2 spec/integration/length_validator/maximum_spec.rb