diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/active_relation/relations/range_spec.rb | 4 | ||||
-rw-r--r-- | spec/active_relation/relations/relation_spec.rb | 4 | ||||
-rw-r--r-- | spec/active_relation/relations/rename_spec.rb | 27 | ||||
-rw-r--r-- | spec/active_relation/relations/table_spec.rb | 5 |
4 files changed, 19 insertions, 21 deletions
diff --git a/spec/active_relation/relations/range_spec.rb b/spec/active_relation/relations/range_spec.rb index f417626fed..51171c759b 100644 --- a/spec/active_relation/relations/range_spec.rb +++ b/spec/active_relation/relations/range_spec.rb @@ -10,8 +10,8 @@ module ActiveRelation end describe '#qualify' do - it "distributes over the relation and attributes" do - pending + it "distributes over the relation" do + Range.new(@relation1, @range1).qualify.should == Range.new(@relation1.qualify, @range1) end end diff --git a/spec/active_relation/relations/relation_spec.rb b/spec/active_relation/relations/relation_spec.rb index f78f1b31b7..05330206e0 100644 --- a/spec/active_relation/relations/relation_spec.rb +++ b/spec/active_relation/relations/relation_spec.rb @@ -51,10 +51,6 @@ module ActiveRelation end describe '#project' do - it "collapses identical projections" do - pending - end - it "manufactures a projection relation" do @relation1.project(@attribute1, @attribute2).should == Projection.new(@relation1, @attribute1, @attribute2) end diff --git a/spec/active_relation/relations/rename_spec.rb b/spec/active_relation/relations/rename_spec.rb index eb0e1f48dd..1616d5fdb7 100644 --- a/spec/active_relation/relations/rename_spec.rb +++ b/spec/active_relation/relations/rename_spec.rb @@ -3,45 +3,44 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper') module ActiveRelation describe Rename do before do - @relation = Table.new(:foo) - @renamed_relation = Rename.new(@relation, @relation[:id] => :schmid) + @relation1 = Table.new(:foo) + @relation2 = Table.new(:bar) + @renamed_relation = Rename.new(@relation1, @relation1[:id] => :schmid) end describe '#initialize' do it "manufactures nested rename relations if multiple renames are provided" do - Rename.new(@relation, @relation[:id] => :humpty, @relation[:name] => :dumpty). \ - should == Rename.new(Rename.new(@relation, @relation[:id] => :humpty), @relation[:name] => :dumpty) - end - - it "raises an exception if the rename provided is already used" do - pending + Rename.new(@relation1, @relation1[:id] => :humpty, @relation1[:name] => :dumpty). \ + should == Rename.new(Rename.new(@relation1, @relation1[:id] => :humpty), @relation1[:name] => :dumpty) end end describe '==' do it "obtains if the relation, attribute, and rename are identical" do - pending + Rename.new(@relation1, @relation1[:id] => :humpty).should == Rename.new(@relation1, @relation1[:id] => :humpty) + Rename.new(@relation1, @relation1[:id] => :humpty).should_not == Rename.new(@relation1, @relation1[:id] => :dumpty) + Rename.new(@relation1, @relation1[:id] => :humpty).should_not == Rename.new(@relation2, @relation2[:id] => :humpty) end end describe '#attributes' do it "manufactures a list of attributes with the renamed attribute renameed" do - Rename.new(@relation, @relation[:id] => :schmid).attributes.should == - (@relation.attributes - [@relation[:id]]) + [@relation[:id].as(:schmid)] + Rename.new(@relation1, @relation1[:id] => :schmid).attributes.should == + (@relation1.attributes - [@relation1[:id]]) + [@relation1[:id].as(:schmid)] end end describe '[]' do it 'indexes attributes by rename' do @renamed_relation[:id].should be_nil - @renamed_relation[:schmid].should == @relation[:id].as(:schmid) + @renamed_relation[:schmid].should == @relation1[:id].as(:schmid) end end describe '#qualify' do it "distributes over the relation and renames" do - Rename.new(@relation, @relation[:id] => :schmid).qualify. \ - should == Rename.new(@relation.qualify, @relation[:id].qualify => :schmid) + Rename.new(@relation1, @relation1[:id] => :schmid).qualify. \ + should == Rename.new(@relation1.qualify, @relation1[:id].qualify => :schmid) end end diff --git a/spec/active_relation/relations/table_spec.rb b/spec/active_relation/relations/table_spec.rb index ec6e6e10bd..c8679707f5 100644 --- a/spec/active_relation/relations/table_spec.rb +++ b/spec/active_relation/relations/table_spec.rb @@ -17,7 +17,10 @@ module ActiveRelation describe '#attributes' do it 'manufactures attributes corresponding to columns in the table' do - pending + @relation.attributes.should == [ + Attribute.new(@relation, :name), + Attribute.new(@relation, :id) + ] end end |