diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-18 12:59:29 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-18 12:59:29 -0700 |
commit | d51139751eae2be6ee32b44edec39fcf09ed2333 (patch) | |
tree | c87d1bbb97cc5ba9f496f7c76fcf2fe7eaeee9f4 /spec/arel/unit/session/session_spec.rb | |
parent | d27ab7bb8ba0d8f136af2ed955d9e489ba45daec (diff) | |
download | rails-d51139751eae2be6ee32b44edec39fcf09ed2333.tar.gz rails-d51139751eae2be6ee32b44edec39fcf09ed2333.tar.bz2 rails-d51139751eae2be6ee32b44edec39fcf09ed2333.zip |
officially renamed active_relation to arel
Diffstat (limited to 'spec/arel/unit/session/session_spec.rb')
-rw-r--r-- | spec/arel/unit/session/session_spec.rb | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/spec/arel/unit/session/session_spec.rb b/spec/arel/unit/session/session_spec.rb new file mode 100644 index 0000000000..c2eb9a4555 --- /dev/null +++ b/spec/arel/unit/session/session_spec.rb @@ -0,0 +1,92 @@ +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 = Insertion.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(@insert.engine.connection) + @session.create(@insert) + end + end + + describe '#read' do + it "executes an selection on the connection" do + mock(@read).call(@read.engine.connection) + @session.read(@read) + end + + it "is memoized" do + mock(@read).call(@read.engine.connection).once + @session.read(@read) + @session.read(@read) + end + end + + describe '#update' do + it "executes an update on the connection" do + mock(@update).call(@update.engine.connection) + @session.update(@update) + end + end + + describe '#delete' do + it "executes a delete on the connection" do + mock(@delete).call(@delete.engine.connection) + @session.delete(@delete) + end + end + end + + describe Session::Transactions do + describe '#begin' do + end + + describe '#end' do + end + end + + describe Session::UnitOfWork do + describe '#flush' do + end + + describe '#clear' do + end + end + end +end
\ No newline at end of file |