blob: 9022a543d18f51d2e19071d7ab8b2094ab89700a (
plain) (
blame)
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
|
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'spec_helper')
module Arel
describe Binary do
before do
@relation = Table.new(:users)
@attribute1 = @relation[:id]
@attribute2 = @relation[:name]
class ConcreteBinary < Binary
end
end
describe '#bind' do
before do
@another_relation = @relation.alias
end
describe 'when both operands are attributes' do
it "manufactures an expression with the attributes bound to the relation" do
ConcreteBinary.new(@attribute1, @attribute2).bind(@another_relation). \
should == ConcreteBinary.new(@another_relation[@attribute1], @another_relation[@attribute2])
end
end
describe 'when an operand is a value' do
it "manufactures an expression with unmodified values" do
ConcreteBinary.new(@attribute1, "asdf").bind(@another_relation). \
should == ConcreteBinary.new(@attribute1.find_correlate_in(@another_relation), "asdf".find_correlate_in(@another_relation))
end
end
end
end
end
|