blob: 0aaa031794c29d97afb42fdd8304071533467384 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
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|
Session.instance.should == session
end
end
it "is a singleton across nested sessions" do
Session.start do |s1|
outside = Session.instance
Session.start do |s2|
Session.instance.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
|