Sha256: ca31befdfa7ae2453ed870c20d7321883ceb0557ca93f27f7812a6a9242fdcb0

Contents?: true

Size: 841 Bytes

Versions: 3

Compression:

Stored size: 841 Bytes

Contents

require_relative '../../spec_helper'
require_relative 'spec_helper'

describe 'SailBoat', "with a :format option on a property" do
  before :all do
    SailBoat.auto_migrate!

    @model = SailBoat.new
    expect(@model).to be_valid_for_format_test
  end

  describe "and value that matches the format" do
    before :all do
      @model.code = 'A1234'
    end

    it "passes inferred format validation" do
      expect(@model).to be_valid_for_format_test
    end
  end

  describe "and value that DOES NOT match the format" do
    before :all do
      @model.code = 'BAD CODE'
    end

    it "does not pass inferred format validation" do
      expect(@model).not_to be_valid_for_format_test
    end

    it "has a meaningful error message" do
      expect(@model.errors.on(:code)).to eq [ 'Code has an invalid format' ]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sbf-dm-validations-1.4.0 spec/integration/automatic_validation/inferred_format_validation_spec.rb
sbf-dm-validations-1.3.0 spec/integration/automatic_validation/inferred_format_validation_spec.rb
sbf-dm-validations-1.3.0.beta spec/integration/automatic_validation/inferred_format_validation_spec.rb