From d1e5265a1db424e7361878772d32ae4ec39babe2 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Sat, 5 Jan 2008 15:32:22 -0800 Subject: join relation qualification --- spec/relations/join_relation_spec.rb | 9 ++++++++- spec/relations/order_relation_spec.rb | 2 +- spec/relations/projection_relation_spec.rb | 2 +- spec/relations/range_relation_spec.rb | 2 +- spec/relations/rename_relation_spec.rb | 6 +----- spec/relations/selection_relation_spec.rb | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) (limited to 'spec/relations') diff --git a/spec/relations/join_relation_spec.rb b/spec/relations/join_relation_spec.rb index bae294440e..b7357b02e8 100644 --- a/spec/relations/join_relation_spec.rb +++ b/spec/relations/join_relation_spec.rb @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper') -describe 'between two relations' do +describe JoinRelation do before do @relation1 = TableRelation.new(:foo) @relation2 = TableRelation.new(:bar) @@ -18,6 +18,13 @@ describe 'between two relations' do end end + describe '#qualify' do + it 'distributes over the relations and predicates' do + JoinRelation.new(@relation1, @relation2, @predicate).qualify. \ + should == JoinRelation.new(@relation1.qualify, @relation2.qualify, @predicate.qualify) + end + end + describe '#to_sql' do before do @relation1 = @relation1.select(@relation1[:id] == @relation2[:foo_id]) diff --git a/spec/relations/order_relation_spec.rb b/spec/relations/order_relation_spec.rb index 62275ff0ac..8792683eec 100644 --- a/spec/relations/order_relation_spec.rb +++ b/spec/relations/order_relation_spec.rb @@ -17,7 +17,7 @@ describe OrderRelation do end describe '#qualify' do - it "manufactures an order relation with qualified attributes and qualified relation" do + it "distributes over the relation and attributes" do OrderRelation.new(@relation1, @attribute1).qualify. \ should == OrderRelation.new(@relation1.qualify, @attribute1.qualify) end diff --git a/spec/relations/projection_relation_spec.rb b/spec/relations/projection_relation_spec.rb index eb74b5cedf..149669c5b2 100644 --- a/spec/relations/projection_relation_spec.rb +++ b/spec/relations/projection_relation_spec.rb @@ -17,7 +17,7 @@ describe ProjectionRelation do end describe '#qualify' do - it "manufactures a projection relation with qualified attributes and qualified relation" do + it "distributes over teh relation and attributes" do ProjectionRelation.new(@relation1, @attribute1).qualify. \ should == ProjectionRelation.new(@relation1.qualify, @attribute1.qualify) end diff --git a/spec/relations/range_relation_spec.rb b/spec/relations/range_relation_spec.rb index 261afcaf8e..947bf35120 100644 --- a/spec/relations/range_relation_spec.rb +++ b/spec/relations/range_relation_spec.rb @@ -17,7 +17,7 @@ describe RangeRelation do end describe '#qualify' do - it "manufactures a range relation with a qualified relation and a qualified range" do + it "distributes over the relation and attributes" do pending end end diff --git a/spec/relations/rename_relation_spec.rb b/spec/relations/rename_relation_spec.rb index e7792d146a..7db329ad7a 100644 --- a/spec/relations/rename_relation_spec.rb +++ b/spec/relations/rename_relation_spec.rb @@ -12,10 +12,6 @@ describe RenameRelation do should == RenameRelation.new(RenameRelation.new(@relation, @relation[:id] => :humpty), @relation[:name] => :dumpty) end - it "make this test less brittle wrt/ hash order" do - pending - end - it "raises an exception if the alias provided is already used" do pending end @@ -48,7 +44,7 @@ describe RenameRelation do end describe '#qualify' do - it "manufactures a rename relation with an identical attribute and alias, but with a qualified relation" do + it "distributes over the relation and renames" do RenameRelation.new(@relation, @relation[:id] => :schmid).qualify. \ should == RenameRelation.new(@relation.qualify, @relation[:id].qualify => :schmid) end diff --git a/spec/relations/selection_relation_spec.rb b/spec/relations/selection_relation_spec.rb index 395a3f7693..7ffb3b3676 100644 --- a/spec/relations/selection_relation_spec.rb +++ b/spec/relations/selection_relation_spec.rb @@ -27,7 +27,7 @@ describe SelectionRelation do end describe '#qualify' do - it "manufactures a selection relation with qualified predicates and qualified relation" do + it "distributes over the relation and predicates" do SelectionRelation.new(@relation1, @predicate1).qualify. \ should == SelectionRelation.new(@relation1.qualify, @predicate1.qualify) end -- cgit v1.2.3