Sha256: 07a0432140c21fb7c85577487af97a21286fea683fb58f6e56da0fa623d0e4ab
Contents?: true
Size: 1.79 KB
Versions: 3
Compression:
Stored size: 1.79 KB
Contents
require_relative '../../spec_helper' require_relative 'spec_helper' describe 'DataMapper::Validations::Fixtures::BillOfLading' do before :all do DataMapper::Validations::Fixtures::BillOfLading.auto_migrate! end def valid_attributes { :id => 1, :doc_no => 'A1234', :email => 'user@example.com', :url => 'http://example.com' } end describe "with doc no with value of 'BAD CODE :)'" do before :all do @model = DataMapper::Validations::Fixtures::BillOfLading.new(valid_attributes.merge(:doc_no => 'BAD CODE :)')) end it_behaves_like 'invalid model' it "has meaningful error message on invalid field" do expect(@model.errors.on(:doc_no)).to eq [ 'Doc no has an invalid format' ] end end describe "with doc no with value of 'A1234'" do before :all do @model = DataMapper::Validations::Fixtures::BillOfLading.new(valid_attributes.merge(:doc_no => 'A1234')) end it_behaves_like 'valid model' end describe "with doc no with value of 'B123456X12'" do before :all do @model = DataMapper::Validations::Fixtures::BillOfLading.new(valid_attributes.merge(:doc_no => 'B123456X12')) end it_behaves_like 'valid model' end describe "with missing url" do before :all do @model = DataMapper::Validations::Fixtures::BillOfLading.new(valid_attributes.except(:url)) end it_behaves_like 'invalid model' end describe "with blank name" do before :all do @model = DataMapper::Validations::Fixtures::BillOfLading.new(valid_attributes.merge(:username => '')) end it_behaves_like 'valid model' end describe "with blank email" do before :all do @model = DataMapper::Validations::Fixtures::BillOfLading.new(valid_attributes.merge(:email => '')) end it_behaves_like 'valid model' end end
Version data entries
3 entries across 3 versions & 1 rubygems