aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/algebra/unit/session
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-26 21:02:23 -0700
committerBryan Helmkamp <bryan@brynary.com>2009-05-17 15:36:05 -0400
commita7aacd29460aa137c3b06ee214ff8ffdff8ee365 (patch)
treee88f8894c830b4f95822ecb970294ca4c793a722 /spec/arel/algebra/unit/session
parent9d77c08cf8a75636b058c1b85af52ef96e07cee5 (diff)
downloadrails-a7aacd29460aa137c3b06ee214ff8ffdff8ee365.tar.gz
rails-a7aacd29460aa137c3b06ee214ff8ffdff8ee365.tar.bz2
rails-a7aacd29460aa137c3b06ee214ff8ffdff8ee365.zip
reorganizing tests
Diffstat (limited to 'spec/arel/algebra/unit/session')
-rw-r--r--spec/arel/algebra/unit/session/session_spec.rb84
1 files changed, 84 insertions, 0 deletions
diff --git a/spec/arel/algebra/unit/session/session_spec.rb b/spec/arel/algebra/unit/session/session_spec.rb
new file mode 100644
index 0000000000..e17b5d638a
--- /dev/null
+++ b/spec/arel/algebra/unit/session/session_spec.rb
@@ -0,0 +1,84 @@
+require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'spec_helper')
+
+module Arel
+ describe Session do
+ before do
+ @relation = Table.new(:users)
+ @session = Session.new
+ end
+
+ describe '::start' do
+ describe '::instance' do
+ it "it is a singleton within the started session" do
+ Session.start do
+ Session.new.should == Session.new
+ end
+ end
+
+ it "is a singleton across nested sessions" do
+ Session.start do
+ outside = Session.new
+ Session.start do
+ Session.new.should == outside
+ end
+ end
+ end
+
+ it "manufactures new sessions outside of the started session" do
+ Session.new.should_not == Session.new
+ end
+ end
+ end
+
+ describe Session::CRUD do
+ before do
+ @insert = Insert.new(@relation, @relation[:name] => 'nick')
+ @update = Update.new(@relation, @relation[:name] => 'nick')
+ @delete = Deletion.new(@relation)
+ @read = @relation
+ end
+
+ describe '#create' do
+ it "executes an insertion on the connection" do
+ mock(@insert).call
+ @session.create(@insert)
+ end
+ end
+
+ describe '#read' do
+ it "executes an selection on the connection" do
+ mock(@read).call
+ @session.read(@read)
+ end
+
+ it "is memoized" do
+ mock(@read).call.once
+ @session.read(@read)
+ @session.read(@read)
+ end
+ end
+
+ describe '#update' do
+ it "executes an update on the connection" do
+ mock(@update).call
+ @session.update(@update)
+ end
+ end
+
+ describe '#delete' do
+ it "executes a delete on the connection" do
+ mock(@delete).call
+ @session.delete(@delete)
+ end
+ end
+ end
+
+ describe 'Transactions' do
+ describe '#begin' do
+ end
+
+ describe '#end' do
+ end
+ end
+ end
+end \ No newline at end of file