blob: 554b69a5bdbba465e0e7139352554d00c8ba83d1 (
plain) (
tree)
|
|
require 'spec_helper'
module Arel
module Visitors
describe 'the to_sql visitor' do
before do
@visitor = ToSql.new Table.engine
@attr = Table.new(:users)[:id]
end
it "should visit visit_Arel_Attributes_Time" do
attr = Attributes::Time.new(@attr.relation, @attr.name, @attr.column)
@visitor.accept attr
end
it "should visit_TrueClass" do
@visitor.accept(@attr.eq(true)).should be_like %{ "users"."id" = 't' }
end
describe "Nodes::In" do
it "should know how to visit" do
node = @attr.in [1, 2, 3]
@visitor.accept(node).should be_like %{
"users"."id" IN (1, 2, 3)
}
end
end
describe 'Equality' do
it "should escape strings" do
test = @attr.eq 'Aaron Patterson'
@visitor.accept(test).should be_like %{
"users"."id" = 'Aaron Patterson'
}
end
end
end
end
end
|