blob: 97ef098e0e86e73813deaf1da8cb8a93d2223fa9 (
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 '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
|