diff options
Diffstat (limited to 'spec/arel')
-rw-r--r-- | spec/arel/unit/relations/array_spec.rb | 27 | ||||
-rw-r--r-- | spec/arel/unit/relations/delete_spec.rb | 8 | ||||
-rw-r--r-- | spec/arel/unit/relations/insert_spec.rb | 11 | ||||
-rw-r--r-- | spec/arel/unit/relations/relation_spec.rb | 7 | ||||
-rw-r--r-- | spec/arel/unit/relations/update_spec.rb | 11 | ||||
-rw-r--r-- | spec/arel/unit/session/session_spec.rb | 10 |
6 files changed, 32 insertions, 42 deletions
diff --git a/spec/arel/unit/relations/array_spec.rb b/spec/arel/unit/relations/array_spec.rb new file mode 100644 index 0000000000..1330f0f205 --- /dev/null +++ b/spec/arel/unit/relations/array_spec.rb @@ -0,0 +1,27 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') + +module Arel + describe Array do + before do + @relation = Array.new([[1], [2], [3]], [:id]) + end + + describe '#attributes' do + it 'manufactures attributes corresponding to the names given on construction' do + @relation.attributes.should == [ + Attribute.new(@relation, :id) + ] + end + end + + describe '#call' do + it "manufactures an array of hashes of attributes to values" do + @relation.call.should == [ + { @relation[:id] => 1 }, + { @relation[:id] => 2 }, + { @relation[:id] => 3 } + ] + end + end + end +end
\ No newline at end of file diff --git a/spec/arel/unit/relations/delete_spec.rb b/spec/arel/unit/relations/delete_spec.rb index 3798178ccc..23aca563f7 100644 --- a/spec/arel/unit/relations/delete_spec.rb +++ b/spec/arel/unit/relations/delete_spec.rb @@ -59,13 +59,5 @@ module Arel end end end - - describe '#call' do - it 'executes a delete on the connection' do - deletion = Deletion.new(@relation) - mock(connection = Object.new).delete(deletion.to_sql) - deletion.call(connection) - end - end end end diff --git a/spec/arel/unit/relations/insert_spec.rb b/spec/arel/unit/relations/insert_spec.rb index 2fd07dd96c..5ab3ef1299 100644 --- a/spec/arel/unit/relations/insert_spec.rb +++ b/spec/arel/unit/relations/insert_spec.rb @@ -87,16 +87,5 @@ module Arel end end end - - describe '#call' do - before do - @insertion = Insert.new(@relation, @relation[:name] => "nick") - end - - it 'executes an insert on the connection' do - mock(connection = Object.new).insert(@insertion.to_sql) - @insertion.call(connection) - end - end end end diff --git a/spec/arel/unit/relations/relation_spec.rb b/spec/arel/unit/relations/relation_spec.rb index a3bfa67353..7df10be59c 100644 --- a/spec/arel/unit/relations/relation_spec.rb +++ b/spec/arel/unit/relations/relation_spec.rb @@ -165,12 +165,5 @@ module Arel @relation.first.should == @relation.session.read(@relation).first end end - - describe '#call' do - it 'executes a select_all on the connection' do - mock(connection = Object.new).execute(@relation.to_sql) { [] } - @relation.call(connection) - end - end end end diff --git a/spec/arel/unit/relations/update_spec.rb b/spec/arel/unit/relations/update_spec.rb index 0bbc9113c6..e0d7ddd295 100644 --- a/spec/arel/unit/relations/update_spec.rb +++ b/spec/arel/unit/relations/update_spec.rb @@ -117,16 +117,5 @@ module Arel end end - describe '#call' do - before do - @update = Update.new(@relation, @relation[:name] => "nick") - end - - it 'executes an update on the connection' do - mock(connection = Object.new).update(@update.to_sql) - @update.call(connection) - end - end - end end diff --git a/spec/arel/unit/session/session_spec.rb b/spec/arel/unit/session/session_spec.rb index 6e73d74f2d..c30ba6195f 100644 --- a/spec/arel/unit/session/session_spec.rb +++ b/spec/arel/unit/session/session_spec.rb @@ -40,19 +40,19 @@ module Arel describe '#create' do it "executes an insertion on the connection" do - mock(@insert).call(@insert.engine) + mock(@insert).call @session.create(@insert) end end describe '#read' do it "executes an selection on the connection" do - mock(@read).call(@read.engine) + mock(@read).call @session.read(@read) end it "is memoized" do - mock(@read).call(@read.engine).once + mock(@read).call.once @session.read(@read) @session.read(@read) end @@ -60,14 +60,14 @@ module Arel describe '#update' do it "executes an update on the connection" do - mock(@update).call(@update.engine) + mock(@update).call @session.update(@update) end end describe '#delete' do it "executes a delete on the connection" do - mock(@delete).call(@delete.engine) + mock(@delete).call @session.delete(@delete) end end |