aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorBryan Helmkamp <bryan@brynary.com>2009-05-17 13:58:29 -0400
committerBryan Helmkamp <bryan@brynary.com>2009-05-17 13:58:29 -0400
commit2bbf8ca9d2af3ea959a21c3729b4894bc31f088b (patch)
treed28994667dbebe135cc7c43d3948a5e5d968f214 /spec
parent49d119ae84bbb7cd180ca855cf48997dc731554c (diff)
downloadrails-2bbf8ca9d2af3ea959a21c3729b4894bc31f088b.tar.gz
rails-2bbf8ca9d2af3ea959a21c3729b4894bc31f088b.tar.bz2
rails-2bbf8ca9d2af3ea959a21c3729b4894bc31f088b.zip
reorganized call
Conflicts: doc/TODO lib/arel/relations/relation.rb lib/arel/relations/writes/delete.rb lib/arel/relations/writes/insert.rb lib/arel/relations/writes/update.rb lib/arel/session.rb spec/arel/unit/relations/delete_spec.rb spec/arel/unit/relations/insert_spec.rb spec/arel/unit/relations/relation_spec.rb spec/arel/unit/relations/update_spec.rb spec/arel/unit/session/session_spec.rb
Diffstat (limited to 'spec')
-rw-r--r--spec/arel/unit/relations/array_spec.rb27
-rw-r--r--spec/arel/unit/relations/delete_spec.rb8
-rw-r--r--spec/arel/unit/relations/insert_spec.rb11
-rw-r--r--spec/arel/unit/relations/relation_spec.rb7
-rw-r--r--spec/arel/unit/relations/update_spec.rb11
-rw-r--r--spec/arel/unit/session/session_spec.rb10
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