Sha256: a4dcfc4f1910cb6f243caab3b276f7bff82b17a14d0a3b5dda452f57e53457e3

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 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
    @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

2 entries across 2 versions & 1 rubygems

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