diff options
Diffstat (limited to 'spec/arel/unit/predicates/predicates_spec.rb')
-rw-r--r-- | spec/arel/unit/predicates/predicates_spec.rb | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/spec/arel/unit/predicates/predicates_spec.rb b/spec/arel/unit/predicates/predicates_spec.rb index d11637cabe..8f9cec5376 100644 --- a/spec/arel/unit/predicates/predicates_spec.rb +++ b/spec/arel/unit/predicates/predicates_spec.rb @@ -9,23 +9,43 @@ module Arel @operand1 = Equality.new(@attribute1, 1) @operand2 = Equality.new(@attribute2, "name") end - + describe "when being combined with another predicate with AND logic" do describe "#to_sql" do it "manufactures sql with an AND operation" do - @operand1.and(@operand2).to_sql.should be_like(" - (`users`.`id` = 1 AND `users`.`name` = 'name') - ") + sql = @operand1.and(@operand2).to_sql + + adapter_is :mysql do + sql.should be_like(%Q{ + (`users`.`id` = 1 AND `users`.`name` = 'name') + }) + end + + adapter_is_not :mysql do + sql.should be_like(%Q{ + ("users"."id" = 1 AND "users"."name" = 'name') + }) + end end end end - + describe "when being combined with another predicate with OR logic" do describe "#to_sql" do it "manufactures sql with an OR operation" do - @operand1.or(@operand2).to_sql.should be_like(" - (`users`.`id` = 1 OR `users`.`name` = 'name') - ") + sql = @operand1.or(@operand2).to_sql + + adapter_is :mysql do + sql.should be_like(%Q{ + (`users`.`id` = 1 OR `users`.`name` = 'name') + }) + end + + adapter_is_not :mysql do + sql.should be_like(%Q{ + ("users"."id" = 1 OR "users"."name" = 'name') + }) + end end end end |