aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/unit/relations/update_spec.rb
diff options
context:
space:
mode:
authorBryan Helmkamp <bryan@brynary.com>2009-05-16 21:13:32 -0400
committerBryan Helmkamp <bryan@brynary.com>2009-05-17 13:17:07 -0400
commit49d119ae84bbb7cd180ca855cf48997dc731554c (patch)
tree3bae397d3e2b5ee76bd89a87ccbf421d814fec74 /spec/arel/unit/relations/update_spec.rb
parent4096d192a1e7cdf0115f5a4cf33d102b176cb8cd (diff)
downloadrails-49d119ae84bbb7cd180ca855cf48997dc731554c.tar.gz
rails-49d119ae84bbb7cd180ca855cf48997dc731554c.tar.bz2
rails-49d119ae84bbb7cd180ca855cf48997dc731554c.zip
Adding spec:mysql and spec:sqlite3 tasks
Diffstat (limited to 'spec/arel/unit/relations/update_spec.rb')
-rw-r--r--spec/arel/unit/relations/update_spec.rb95
1 files changed, 73 insertions, 22 deletions
diff --git a/spec/arel/unit/relations/update_spec.rb b/spec/arel/unit/relations/update_spec.rb
index b67369251f..0bbc9113c6 100644
--- a/spec/arel/unit/relations/update_spec.rb
+++ b/spec/arel/unit/relations/update_spec.rb
@@ -8,18 +8,41 @@ module Arel
describe '#to_sql' do
it "manufactures sql updating attributes when given multiple attributes" do
- Update.new(@relation, @relation[:id] => 1, @relation[:name] => "nick").to_sql.should be_like("
- UPDATE `users`
- SET `id` = 1, `name` = 'nick'
- ")
+ sql = Update.new(@relation, @relation[:id] => 1, @relation[:name] => "nick").to_sql
+
+ adapter_is :mysql do
+ sql.should be_like(%Q{
+ UPDATE `users`
+ SET `id` = 1, `name` = 'nick'
+ })
+ end
+
+ adapter_is_not :mysql do
+ sql.should be_like(%Q{
+ UPDATE "users"
+ SET "id" = 1, "name" = 'nick'
+ })
+ end
end
it "manufactures sql updating attributes when given a ranged relation" do
- Update.new(@relation.take(1), @relation[:name] => "nick").to_sql.should be_like("
- UPDATE `users`
- SET `name` = 'nick'
- LIMIT 1
- ")
+ sql = Update.new(@relation.take(1), @relation[:name] => "nick").to_sql
+
+ adapter_is :mysql do
+ sql.should be_like(%Q{
+ UPDATE `users`
+ SET `name` = 'nick'
+ LIMIT 1
+ })
+ end
+
+ adapter_is_not :mysql do
+ sql.should be_like(%Q{
+ UPDATE "users"
+ SET "name" = 'nick'
+ LIMIT 1
+ })
+ end
end
describe 'when given values whose types correspond to the types of the attributes' do
@@ -28,10 +51,19 @@ module Arel
end
it 'manufactures sql updating attributes' do
- @update.to_sql.should be_like("
- UPDATE `users`
- SET `name` = 'nick'
- ")
+ adapter_is :mysql do
+ @update.to_sql.should be_like(%Q{
+ UPDATE `users`
+ SET `name` = 'nick'
+ })
+ end
+
+ adapter_is_not :mysql do
+ @update.to_sql.should be_like(%Q{
+ UPDATE "users"
+ SET "name" = 'nick'
+ })
+ end
end
end
@@ -41,10 +73,19 @@ module Arel
end
it 'manufactures sql updating attributes' do
- @update.to_sql.should be_like("
- UPDATE `users`
- SET `id` = 1
- ")
+ adapter_is :mysql do
+ @update.to_sql.should be_like(%Q{
+ UPDATE `users`
+ SET `id` = 1
+ })
+ end
+
+ adapter_is_not :mysql do
+ @update.to_sql.should be_like(%Q{
+ UPDATE "users"
+ SET "id" = 1
+ })
+ end
end
end
@@ -57,11 +98,21 @@ module Arel
end
it 'manufactures sql updating a where relation' do
- @update.to_sql.should be_like("
- UPDATE `users`
- SET `name` = 'nick'
- WHERE `users`.`id` = 1
- ")
+ adapter_is :mysql do
+ @update.to_sql.should be_like(%Q{
+ UPDATE `users`
+ SET `name` = 'nick'
+ WHERE `users`.`id` = 1
+ })
+ end
+
+ adapter_is_not :mysql do
+ @update.to_sql.should be_like(%Q{
+ UPDATE "users"
+ SET "name" = 'nick'
+ WHERE "users"."id" = 1
+ })
+ end
end
end
end