Sha256: 2150e30472e929a44749587dfa9a90d15dc908d075d99a75486ffb60daa253c3
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
require 'spec_helper' module Alf module Operator::Relational describe Join::HashBased do let(:suppliers) {[ {:sid => 'S1', :city => 'London'}, {:sid => 'S2', :city => 'Paris'}, {:sid => 'S3', :city => 'Paris'} ]} let(:statuses) {[ {:sid => 'S1', :status => 20}, {:sid => 'S2', :status => 10}, {:sid => 'S3', :status => 30} ]} let(:countries) {[ {:city => 'London', :country => 'England'}, {:city => 'Paris', :country => 'France'}, {:city => 'Bruxelles', :country => 'Belgium (until ?)'} ]} let(:operator){ Join::HashBased.new } subject{ operator.to_a } describe "when applied on both candidate keys" do before{ operator.pipe [suppliers, statuses] } let(:expected){[ {:sid => 'S1', :city => 'London', :status => 20}, {:sid => 'S2', :city => 'Paris', :status => 10}, {:sid => 'S3', :city => 'Paris', :status => 30} ]} it { should == expected } end describe "when applied on a typical foreign key" do let(:expected){[ {:sid => 'S1', :city => 'London', :country => 'England'}, {:sid => 'S2', :city => 'Paris', :country => 'France'}, {:sid => 'S3', :city => 'Paris', :country => 'France'} ]} describe "on one way" do before{ operator.pipe [suppliers, countries] } it { should == expected } end describe "on the other way around" do before{ operator.pipe [countries, suppliers] } it { should == expected } end end describe "when no attributes are in common" do before{ operator.pipe [statuses, countries] } let(:expected){ statuses.collect{|s| countries.collect{|c| c.merge(s)}}.flatten } it { should == expected } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alf-0.10.1 | spec/unit/operator/relational/join/test_hash_based.rb |
alf-0.10.0 | spec/unit/operator/relational/join/test_hash_based.rb |