diff options
Diffstat (limited to 'spec/active_relation/relations/alias_spec.rb')
-rw-r--r-- | spec/active_relation/relations/alias_spec.rb | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/spec/active_relation/relations/alias_spec.rb b/spec/active_relation/relations/alias_spec.rb index 6f25df3ddb..418af7fe66 100644 --- a/spec/active_relation/relations/alias_spec.rb +++ b/spec/active_relation/relations/alias_spec.rb @@ -1,36 +1,38 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper') -describe ActiveRelation::Relations::Alias do - before do - @relation = ActiveRelation::Relations::Table.new(:users) - @alias_relation = @relation.as(:foo) - end +module ActiveRelation + describe Alias do + before do + @relation = Table.new(:users) + @alias_relation = @relation.as(:foo) + end - describe '#name' do - it 'returns the alias' do - @alias_relation.name.should == :foo + describe '#name' do + it 'returns the alias' do + @alias_relation.name.should == :foo + end end - end - describe '#attributes' do - it 'manufactures sql deleting a table relation' do - @alias_relation.attributes.should == @relation.attributes.collect { |a| ActiveRelation::Primitives::Attribute.new(@alias_relation, a.name) } + describe '#attributes' do + it 'manufactures sql deleting a table relation' do + @alias_relation.attributes.should == @relation.attributes.collect { |a| Attribute.new(@alias_relation, a.name) } + end end - end - describe '[]' do - it 'manufactures attributes associated with the aliased relation' do - @alias_relation[:id].relation.should == @alias_relation - @alias_relation[:does_not_exist].should be_nil + describe '[]' do + it 'manufactures attributes associated with the aliased relation' do + @alias_relation[:id].relation.should == @alias_relation + @alias_relation[:does_not_exist].should be_nil + end end - end - describe '#to_sql' do - it "manufactures an aliased select query" do - @alias_relation.to_sql.should be_like(""" - SELECT `foo`.`name`, `foo`.`id` - FROM `users` AS `foo` - """) + describe '#to_sql' do + it "manufactures an aliased select query" do + @alias_relation.to_sql.should be_like(""" + SELECT `foo`.`name`, `foo`.`id` + FROM `users` AS `foo` + """) + end end end end
\ No newline at end of file |