Sha256: 14c068ddbcbaf5fb67dda45df21745290f93e6d462240488cdfbff73db1f8dbb

Contents?: true

Size: 1.95 KB

Versions: 9

Compression:

Stored size: 1.95 KB

Contents

require '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
          @insert.should_receive(:call)
          @session.create(@insert)
        end
      end

      describe '#read' do
        it "executes an selection on the connection" do
          @read.should_receive(:call)
          @session.read(@read)
        end

        it "is memoized" do
          @read.should_receive(:call).once
          @session.read(@read)
          @session.read(@read)
        end
      end

      describe '#update' do
        it "executes an update on the connection" do
          @update.should_receive(:call)
          @session.update(@update)
        end
      end

      describe '#delete' do
        it "executes a delete on the connection" do
          @delete.should_receive(:call)
          @session.delete(@delete)
        end
      end
    end

    describe 'Transactions' do
      describe '#begin' do
      end

      describe '#end' do
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
arel-compat-0.4.0 spec/algebra/unit/session/session_spec.rb
arel-0.4.0 spec/algebra/unit/session/session_spec.rb
arel-0.3.3 spec/algebra/unit/session/session_spec.rb
arel-0.3.2 spec/algebra/unit/session/session_spec.rb
arel-0.3.1 spec/arel/algebra/unit/session/session_spec.rb
arel-0.3.0 spec/arel/algebra/unit/session/session_spec.rb
arel-0.2.1 spec/arel/algebra/unit/session/session_spec.rb
arel-0.2.0 spec/arel/algebra/unit/session/session_spec.rb
arel-0.2.pre spec/arel/algebra/unit/session/session_spec.rb