Sha256: 156523af8f3e3bcc33d0131038642f7a0a4e5c69f0b5da0bc9f143cf5be25134

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

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

describe 'DataMapper::Validations::Fixtures::UDPPacket' do
  before :all do
    DataMapper::Validations::Fixtures::UDPPacket.auto_migrate!

    @model = DataMapper::Validations::Fixtures::UDPPacket.new
  end

  describe "that is transported encapsulated into IPv4 packet" do
    before :all do
      @model.underlying_ip_version = 4
    end

    describe "and has no checksum" do
      before :all do
        @model.checksum = nil
      end

      it_behaves_like 'valid model'
    end

    describe "and has no checksum algorithm" do
      before :all do
        @model.checksum_algorithm = nil
      end

      it_behaves_like 'valid model'
    end
  end


  describe "that is transported encapsulated into IPv6 packet" do
    before :all do
      @model.underlying_ip_version = 6
    end

    describe "and has no checksum" do
      before :all do
        @model.checksum = nil
      end

      it_behaves_like 'invalid model'

      it "has a meaningful error message" do
        expect(@model.errors.on(:checksum)).to eq [ 'Checksum is mandatory when used with IPv6' ]
      end
    end

    describe "and has no checksum algorithm" do
      before :all do
        @model.checksum_algorithm = nil
      end

      it_behaves_like 'invalid model'

      it "has a meaningful error message" do
        expect(@model.errors.on(:checksum_algorithm)).to eq [ 'Checksum is mandatory when used with IPv6' ]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sbf-dm-validations-1.4.0 spec/integration/conditional_validation/if_condition_spec.rb
sbf-dm-validations-1.3.0 spec/integration/conditional_validation/if_condition_spec.rb
sbf-dm-validations-1.3.0.beta spec/integration/conditional_validation/if_condition_spec.rb