Sha256: 8c87630f69bb651dd0167231a71dfc7e8cf88fe16c1053bd153717398e40ef80
Contents?: true
Size: 1.39 KB
Versions: 5
Compression:
Stored size: 1.39 KB
Contents
require 'spec_helper' module Alf module Operator::Relational describe Intersect do let(:operator_class){ Intersect } it_should_behave_like("An operator class") let(:left) {[ {:sid => 'S1', :city => 'London'}, {:sid => 'S2', :city => 'Paris'}, {:sid => 'S3', :city => 'Paris'} ]} let(:right) {[ {:sid => 'S2', :city => 'Paris'}, {:sid => 'S1', :city => 'London'}, ]} let(:disjoint) {[ {:sid => 'S4', :city => 'Oslo'}, {:sid => 'S5', :city => 'Bruxelles'}, ]} let(:operator){ Lispy.intersect(*args) } subject{ operator.to_a } context "with same operand twice" do let(:args){ [left, left] } it { should eq(left) } end context "on operands sharing tuples" do let(:args){ [left, right] } let(:expected) {[ {:sid => 'S1', :city => 'London'}, {:sid => 'S2', :city => 'Paris'}, ]} it { should eq(expected) } end context "on disjoint operands" do let(:args){ [left, disjoint] } it { should be_empty } end context "with Lispy" do let(:operator){ Lispy.intersect(left, right) } let(:expected) {[ {:sid => 'S1', :city => 'London'}, {:sid => 'S2', :city => 'Paris'}, ]} it { should == expected } end end end end
Version data entries
5 entries across 5 versions & 1 rubygems