diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/arel/algebra/unit/primitives/attribute_spec.rb | 12 | ||||
-rw-r--r-- | spec/arel/algebra/unit/primitives/expression_spec.rb | 2 | ||||
-rw-r--r-- | spec/arel/algebra/unit/relations/relation_spec.rb | 10 |
3 files changed, 16 insertions, 8 deletions
diff --git a/spec/arel/algebra/unit/primitives/attribute_spec.rb b/spec/arel/algebra/unit/primitives/attribute_spec.rb index bab9fad3d5..dcac5abf65 100644 --- a/spec/arel/algebra/unit/primitives/attribute_spec.rb +++ b/spec/arel/algebra/unit/primitives/attribute_spec.rb @@ -26,8 +26,16 @@ module Arel end describe '#to_attribute' do - it "returns self" do - @attribute.to_attribute.should == @attribute + describe 'when the given relation is the same as the attributes relation' do + it "returns self" do + @attribute.to_attribute(@relation).should == @attribute + end + end + + describe 'when the given relation differs from the attributes relation' do + it 'binds to the new relation' do + @attribute.to_attribute(new_relation = @relation.alias).should == @attribute.bind(new_relation) + end end end end diff --git a/spec/arel/algebra/unit/primitives/expression_spec.rb b/spec/arel/algebra/unit/primitives/expression_spec.rb index 10bdb56302..dfd2100048 100644 --- a/spec/arel/algebra/unit/primitives/expression_spec.rb +++ b/spec/arel/algebra/unit/primitives/expression_spec.rb @@ -31,7 +31,7 @@ module Arel describe '#to_attribute' do it "manufactures an attribute with the expression as an ancestor" do - @expression.to_attribute.should == Attribute.new(@expression.relation, @expression.alias, :ancestor => @expression) + @expression.to_attribute(@relation).should == Attribute.new(@relation, @expression.alias, :ancestor => @expression) end end end diff --git a/spec/arel/algebra/unit/relations/relation_spec.rb b/spec/arel/algebra/unit/relations/relation_spec.rb index 3286f373f5..9707f2887c 100644 --- a/spec/arel/algebra/unit/relations/relation_spec.rb +++ b/spec/arel/algebra/unit/relations/relation_spec.rb @@ -40,7 +40,7 @@ module Arel describe "when given a string" do it "manufactures a join operation with the string passed through" do - @relation.join(arbitrary_string = "ASDF").should == Join.new(arbitrary_string, @relation) + @relation.join(arbitrary_string = "ASDF").should == StringJoin.new(@relation, arbitrary_string) end end @@ -159,7 +159,7 @@ module Arel describe '#insert' do it 'manufactures an insertion relation' do Session.start do - record = {@relation[:name] => 'carl'} + record = { @relation[:name] => 'carl' } mock(Session.new).create(Insert.new(@relation, record)) @relation.insert(record) end @@ -169,7 +169,7 @@ module Arel describe '#update' do it 'manufactures an update relation' do Session.start do - assignments = {@relation[:name] => Value.new('bob', @relation)} + assignments = { @relation[:name] => Value.new('bob', @relation) } mock(Session.new).update(Update.new(@relation, assignments)) @relation.update(assignments) end @@ -180,8 +180,8 @@ module Arel describe Relation::Enumerable do it "implements enumerable" do - @relation.collect.should == @relation.session.read(@relation) - @relation.first.should == @relation.session.read(@relation).first + @relation.collect.should == @relation.session.read(@relation).collect + @relation.first.should == @relation.session.read(@relation).first end end end |