1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
describe RenameRelation do
before do
@relation = TableRelation.new(:foo)
@renamed_relation = RenameRelation.new(@relation, @relation[:id] => :schmid)
end
describe '#initialize' do
it "manufactures nested rename relations if multiple renames are provided" do
RenameRelation.new(@relation, @relation[:id] => :humpty, @relation[:name] => :dumpty). \
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
end
describe '==' do
it "obtains if the relation, attribute, and alias are identical" do
pending
end
end
describe '#attributes' do
it "manufactures a list of attributes with the renamed attribute aliased" do
RenameRelation.new(@relation, @relation[:id] => :schmid).attributes.should ==
(@relation.attributes - [@relation[:id]]) + [@relation[:id].aliazz(:schmid)]
end
end
describe '[]' do
it 'indexes attributes by alias' do
@renamed_relation[:id].should be_nil
@renamed_relation[:schmid].should == @relation[:id]
end
end
describe '#schmattribute' do
it "should be renamed" do
pending
end
end
describe '#qualify' do
it "manufactures a rename relation with an identical attribute and alias, but with a qualified relation" do
RenameRelation.new(@relation, @relation[:id] => :schmid).qualify. \
should == RenameRelation.new(@relation.qualify, @relation[:id].qualify => :schmid)
end
end
describe '#to_sql' do
it 'manufactures sql aliasing the attribute' do
@renamed_relation.to_sql.to_s.should == SelectBuilder.new do
select do
column :foo, :name
column :foo, :id, :schmid
end
from :foo
end.to_s
end
end
end
|