diff options
Diffstat (limited to 'spec/arel/engines/sql/unit/primitives/value_spec.rb')
-rw-r--r-- | spec/arel/engines/sql/unit/primitives/value_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/arel/engines/sql/unit/primitives/value_spec.rb b/spec/arel/engines/sql/unit/primitives/value_spec.rb new file mode 100644 index 0000000000..ff3533f6ef --- /dev/null +++ b/spec/arel/engines/sql/unit/primitives/value_spec.rb @@ -0,0 +1,29 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..', 'spec_helper') + +module Arel + describe Value do + before do + @relation = Table.new(:users) + end + + describe '#to_sql' do + it "appropriately quotes the value" do + Value.new(1, @relation).to_sql.should be_like('1') + + adapter_is_not :postgresql do + Value.new('asdf', @relation).to_sql.should be_like("'asdf'") + end + + adapter_is :postgresql do + Value.new('asdf', @relation).to_sql.should be_like("E'asdf'") + end + end + end + + describe '#format' do + it "returns the sql of the provided object" do + Value.new(1, @relation).format(@relation[:id]).should == @relation[:id].to_sql + end + end + end +end |