Sha256: 65a07e8f36a4017214e0b50e8bfb93ad39d7389b4f8d9322194a46a2b574bf16

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 Bytes

Contents

require 'spec_helper'
require 'integration/format_validator/spec_helper'

describe 'DataMapper::Validate::Fixtures::BillOfLading' do
  before :all do
    DataMapper::Validate::Fixtures::BillOfLading.auto_migrate!
  end

  def valid_attributes
    { :id => 1, :doc_no => 'A1234', :email => 'user@example.com', :url => 'http://example.com' }
  end

  describe "with code of 123456" do
    before :all do
      @model = DataMapper::Validate::Fixtures::BillOfLading.new(valid_attributes.merge(:code => '123456'))
    end

    it_should_behave_like 'valid model'
  end


  describe "with code of 12" do
    before :all do
      @model = DataMapper::Validate::Fixtures::BillOfLading.new(valid_attributes.merge(:code => '12'))
    end

    it_should_behave_like 'invalid model'

    it "has a meaningful error message" do
      @model.errors.on(:code).should  == [ 'Code format is invalid' ]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-validations-0.10.2 spec/integration/format_validator/regexp_validator_spec.rb