Sha256: e55d2b4b99ef7e88ffaf1d0edfc43b9f513fa6aa0ebe3938c0705d707bf7a155

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'
require 'integration/conditional_validation/spec_helper'

describe DataMapper::Validate::Fixtures::UDPPacket do
  before :all do
    @model = DataMapper::Validate::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_should_behave_like "valid model"
    end

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

      it_should_behave_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_should_behave_like "invalid model"

      it "has a meaningful error message" do
        @model.errors.on(:checksum).should == [ '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_should_behave_like "invalid model"

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dm-validations-0.10.1 spec/integration/conditional_validation/if_condition_spec.rb
dm-validations-0.10.0 spec/integration/conditional_validation/if_condition_spec.rb