Sha256: ff97bd646f92f4452dbf0f15840412d8763f66cbb0967d48bbda2f3ea2808ad3

Contents?: true

Size: 1.59 KB

Versions: 19

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'
module Finitio
  describe MultiRelationType, "include?" do

    let(:heading){
      Heading.new([
        Attribute.new(:a, intType),
        Attribute.new(:b, intType, false)
      ])
    }

    let(:type){ MultiRelationType.new(heading) }

    subject{ type.include?(arg) }

    context 'when a empty set' do
      let(:arg){ Set.new }

      it{ should eq(true) }
    end

    context 'when a valid, non empty set' do
      let(:arg){ Set.new }

      before do
        arg << {a: 12, b: 15} << {a: 15, b: 16}
      end

      it{ should eq(true) }
    end

    context 'when a valid, non empty set but missing optionals' do
      let(:arg){ Set.new }

      before do
        arg << {a: 12} << {a: 15, b: 16}
      end

      it{ should eq(true) }
    end

    context 'when not a set' do
      let(:arg){ "foo" }

      it{ should eq(false) }
    end

    context 'when a set containing invalid tuples' do
      let(:arg){ Set.new }

      before do
        arg << {a: 12.0}
      end

      it{ should eq(false) }
    end

    context 'when a set containing tuples with missing required' do
      let(:arg){ Set.new }

      before do
        arg << {b: 12}
      end

      it{ should eq(false) }
    end

    context 'when a set containing tuples with extra' do
      let(:arg){ Set.new }

      before do
        arg << {a: 12, b: 12, c: 15}
      end

      it{ should eq(false) }
    end

    context 'when a set containing tuples with invalid optional' do
      let(:arg){ Set.new }

      before do
        arg << {a: 12, b: 12.5}
      end

      it{ should eq(false) }
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/type/multi_relation_type/test_include.rb
finitio-0.11.4 spec/type/multi_relation_type/test_include.rb
finitio-0.11.3 spec/type/multi_relation_type/test_include.rb
finitio-0.11.2 spec/type/multi_relation_type/test_include.rb
finitio-0.11.1 spec/type/multi_relation_type/test_include.rb
finitio-0.10.0 spec/type/multi_relation_type/test_include.rb
finitio-0.9.1 spec/type/multi_relation_type/test_include.rb
finitio-0.9.0 spec/type/multi_relation_type/test_include.rb
finitio-0.8.0 spec/type/multi_relation_type/test_include.rb
finitio-0.7.0 spec/type/multi_relation_type/test_include.rb
finitio-0.7.0.pre.rc4 spec/type/multi_relation_type/test_include.rb
finitio-0.7.0.pre.rc3 spec/type/multi_relation_type/test_include.rb
finitio-0.7.0.pre.rc2 spec/type/multi_relation_type/test_include.rb
finitio-0.7.0.pre.rc1 spec/type/multi_relation_type/test_include.rb
finitio-0.6.1 spec/type/multi_relation_type/test_include.rb
finitio-0.6.0 spec/type/multi_relation_type/test_include.rb
finitio-0.5.2 spec/type/multi_relation_type/test_include.rb
finitio-0.5.1 spec/type/multi_relation_type/test_include.rb
finitio-0.5.0 spec/type/multi_relation_type/test_include.rb