arel-compat 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. data/History.txt +25 -0
  2. data/README.markdown +182 -0
  3. data/lib/arel.rb +13 -0
  4. data/lib/arel/algebra.rb +10 -0
  5. data/lib/arel/algebra/attributes.rb +7 -0
  6. data/lib/arel/algebra/attributes/attribute.rb +270 -0
  7. data/lib/arel/algebra/attributes/boolean.rb +21 -0
  8. data/lib/arel/algebra/attributes/decimal.rb +9 -0
  9. data/lib/arel/algebra/attributes/float.rb +9 -0
  10. data/lib/arel/algebra/attributes/integer.rb +10 -0
  11. data/lib/arel/algebra/attributes/string.rb +10 -0
  12. data/lib/arel/algebra/attributes/time.rb +6 -0
  13. data/lib/arel/algebra/core_extensions.rb +4 -0
  14. data/lib/arel/algebra/core_extensions/class.rb +32 -0
  15. data/lib/arel/algebra/core_extensions/hash.rb +11 -0
  16. data/lib/arel/algebra/core_extensions/object.rb +30 -0
  17. data/lib/arel/algebra/core_extensions/symbol.rb +9 -0
  18. data/lib/arel/algebra/expression.rb +43 -0
  19. data/lib/arel/algebra/header.rb +67 -0
  20. data/lib/arel/algebra/ordering.rb +23 -0
  21. data/lib/arel/algebra/predicates.rb +190 -0
  22. data/lib/arel/algebra/relations.rb +17 -0
  23. data/lib/arel/algebra/relations/operations/alias.rb +7 -0
  24. data/lib/arel/algebra/relations/operations/from.rb +6 -0
  25. data/lib/arel/algebra/relations/operations/group.rb +12 -0
  26. data/lib/arel/algebra/relations/operations/having.rb +17 -0
  27. data/lib/arel/algebra/relations/operations/join.rb +69 -0
  28. data/lib/arel/algebra/relations/operations/lock.rb +12 -0
  29. data/lib/arel/algebra/relations/operations/order.rb +19 -0
  30. data/lib/arel/algebra/relations/operations/project.rb +20 -0
  31. data/lib/arel/algebra/relations/operations/skip.rb +7 -0
  32. data/lib/arel/algebra/relations/operations/take.rb +11 -0
  33. data/lib/arel/algebra/relations/operations/where.rb +17 -0
  34. data/lib/arel/algebra/relations/relation.rb +136 -0
  35. data/lib/arel/algebra/relations/row.rb +26 -0
  36. data/lib/arel/algebra/relations/utilities/compound.rb +54 -0
  37. data/lib/arel/algebra/relations/utilities/externalization.rb +24 -0
  38. data/lib/arel/algebra/relations/utilities/nil.rb +7 -0
  39. data/lib/arel/algebra/relations/writes.rb +36 -0
  40. data/lib/arel/algebra/value.rb +14 -0
  41. data/lib/arel/engines.rb +2 -0
  42. data/lib/arel/engines/memory.rb +4 -0
  43. data/lib/arel/engines/memory/engine.rb +16 -0
  44. data/lib/arel/engines/memory/predicates.rb +99 -0
  45. data/lib/arel/engines/memory/primitives.rb +27 -0
  46. data/lib/arel/engines/memory/relations.rb +5 -0
  47. data/lib/arel/engines/memory/relations/array.rb +35 -0
  48. data/lib/arel/engines/memory/relations/compound.rb +9 -0
  49. data/lib/arel/engines/memory/relations/operations.rb +67 -0
  50. data/lib/arel/engines/memory/relations/writes.rb +7 -0
  51. data/lib/arel/engines/sql.rb +8 -0
  52. data/lib/arel/engines/sql/attributes.rb +40 -0
  53. data/lib/arel/engines/sql/christener.rb +14 -0
  54. data/lib/arel/engines/sql/compilers/ibm_db_compiler.rb +48 -0
  55. data/lib/arel/engines/sql/compilers/mysql_compiler.rb +11 -0
  56. data/lib/arel/engines/sql/compilers/oracle_compiler.rb +95 -0
  57. data/lib/arel/engines/sql/compilers/postgresql_compiler.rb +42 -0
  58. data/lib/arel/engines/sql/compilers/sqlite_compiler.rb +9 -0
  59. data/lib/arel/engines/sql/core_extensions.rb +4 -0
  60. data/lib/arel/engines/sql/core_extensions/array.rb +24 -0
  61. data/lib/arel/engines/sql/core_extensions/nil_class.rb +15 -0
  62. data/lib/arel/engines/sql/core_extensions/object.rb +19 -0
  63. data/lib/arel/engines/sql/core_extensions/range.rb +19 -0
  64. data/lib/arel/engines/sql/engine.rb +55 -0
  65. data/lib/arel/engines/sql/formatters.rb +122 -0
  66. data/lib/arel/engines/sql/predicates.rb +103 -0
  67. data/lib/arel/engines/sql/primitives.rb +97 -0
  68. data/lib/arel/engines/sql/relations.rb +10 -0
  69. data/lib/arel/engines/sql/relations/compiler.rb +118 -0
  70. data/lib/arel/engines/sql/relations/operations/alias.rb +5 -0
  71. data/lib/arel/engines/sql/relations/operations/join.rb +33 -0
  72. data/lib/arel/engines/sql/relations/relation.rb +65 -0
  73. data/lib/arel/engines/sql/relations/table.rb +88 -0
  74. data/lib/arel/engines/sql/relations/utilities/compound.rb +10 -0
  75. data/lib/arel/engines/sql/relations/utilities/externalization.rb +14 -0
  76. data/lib/arel/engines/sql/relations/utilities/nil.rb +6 -0
  77. data/lib/arel/engines/sql/relations/utilities/recursion.rb +13 -0
  78. data/lib/arel/engines/sql/relations/writes.rb +19 -0
  79. data/lib/arel/session.rb +51 -0
  80. data/lib/arel/version.rb +3 -0
  81. data/spec/algebra/unit/predicates/binary_spec.rb +35 -0
  82. data/spec/algebra/unit/predicates/equality_spec.rb +29 -0
  83. data/spec/algebra/unit/predicates/in_spec.rb +12 -0
  84. data/spec/algebra/unit/primitives/attribute_spec.rb +181 -0
  85. data/spec/algebra/unit/primitives/expression_spec.rb +45 -0
  86. data/spec/algebra/unit/primitives/value_spec.rb +15 -0
  87. data/spec/algebra/unit/relations/alias_spec.rb +16 -0
  88. data/spec/algebra/unit/relations/delete_spec.rb +9 -0
  89. data/spec/algebra/unit/relations/group_spec.rb +10 -0
  90. data/spec/algebra/unit/relations/insert_spec.rb +9 -0
  91. data/spec/algebra/unit/relations/join_spec.rb +25 -0
  92. data/spec/algebra/unit/relations/order_spec.rb +21 -0
  93. data/spec/algebra/unit/relations/project_spec.rb +34 -0
  94. data/spec/algebra/unit/relations/relation_spec.rb +187 -0
  95. data/spec/algebra/unit/relations/skip_spec.rb +10 -0
  96. data/spec/algebra/unit/relations/table_spec.rb +38 -0
  97. data/spec/algebra/unit/relations/take_spec.rb +10 -0
  98. data/spec/algebra/unit/relations/update_spec.rb +9 -0
  99. data/spec/algebra/unit/relations/where_spec.rb +19 -0
  100. data/spec/algebra/unit/session/session_spec.rb +84 -0
  101. data/spec/attributes/boolean_spec.rb +57 -0
  102. data/spec/attributes/float_spec.rb +119 -0
  103. data/spec/attributes/header_spec.rb +42 -0
  104. data/spec/attributes/integer_spec.rb +119 -0
  105. data/spec/attributes/string_spec.rb +43 -0
  106. data/spec/attributes/time_spec.rb +24 -0
  107. data/spec/engines/memory/integration/joins/cross_engine_spec.rb +51 -0
  108. data/spec/engines/memory/unit/relations/array_spec.rb +32 -0
  109. data/spec/engines/memory/unit/relations/insert_spec.rb +28 -0
  110. data/spec/engines/memory/unit/relations/join_spec.rb +31 -0
  111. data/spec/engines/memory/unit/relations/order_spec.rb +27 -0
  112. data/spec/engines/memory/unit/relations/project_spec.rb +27 -0
  113. data/spec/engines/memory/unit/relations/skip_spec.rb +26 -0
  114. data/spec/engines/memory/unit/relations/take_spec.rb +26 -0
  115. data/spec/engines/memory/unit/relations/where_spec.rb +39 -0
  116. data/spec/engines/sql/integration/joins/with_adjacency_spec.rb +258 -0
  117. data/spec/engines/sql/integration/joins/with_aggregations_spec.rb +221 -0
  118. data/spec/engines/sql/integration/joins/with_compounds_spec.rb +137 -0
  119. data/spec/engines/sql/unit/engine_spec.rb +45 -0
  120. data/spec/engines/sql/unit/predicates/binary_spec.rb +140 -0
  121. data/spec/engines/sql/unit/predicates/equality_spec.rb +75 -0
  122. data/spec/engines/sql/unit/predicates/in_spec.rb +179 -0
  123. data/spec/engines/sql/unit/predicates/noteq_spec.rb +75 -0
  124. data/spec/engines/sql/unit/predicates/predicates_spec.rb +79 -0
  125. data/spec/engines/sql/unit/primitives/attribute_spec.rb +36 -0
  126. data/spec/engines/sql/unit/primitives/expression_spec.rb +28 -0
  127. data/spec/engines/sql/unit/primitives/literal_spec.rb +43 -0
  128. data/spec/engines/sql/unit/primitives/value_spec.rb +29 -0
  129. data/spec/engines/sql/unit/relations/alias_spec.rb +53 -0
  130. data/spec/engines/sql/unit/relations/delete_spec.rb +83 -0
  131. data/spec/engines/sql/unit/relations/from_spec.rb +64 -0
  132. data/spec/engines/sql/unit/relations/group_spec.rb +72 -0
  133. data/spec/engines/sql/unit/relations/having_spec.rb +78 -0
  134. data/spec/engines/sql/unit/relations/insert_spec.rb +143 -0
  135. data/spec/engines/sql/unit/relations/join_spec.rb +180 -0
  136. data/spec/engines/sql/unit/relations/lock_spec.rb +86 -0
  137. data/spec/engines/sql/unit/relations/order_spec.rb +161 -0
  138. data/spec/engines/sql/unit/relations/project_spec.rb +143 -0
  139. data/spec/engines/sql/unit/relations/skip_spec.rb +41 -0
  140. data/spec/engines/sql/unit/relations/table_spec.rb +129 -0
  141. data/spec/engines/sql/unit/relations/take_spec.rb +49 -0
  142. data/spec/engines/sql/unit/relations/update_spec.rb +203 -0
  143. data/spec/engines/sql/unit/relations/where_spec.rb +72 -0
  144. data/spec/relations/join_spec.rb +42 -0
  145. data/spec/relations/relation_spec.rb +31 -0
  146. data/spec/shared/relation_spec.rb +255 -0
  147. data/spec/spec_helper.rb +36 -0
  148. data/spec/support/check.rb +6 -0
  149. data/spec/support/connections/mysql_connection.rb +14 -0
  150. data/spec/support/connections/oracle_connection.rb +17 -0
  151. data/spec/support/connections/postgresql_connection.rb +13 -0
  152. data/spec/support/connections/sqlite3_connection.rb +24 -0
  153. data/spec/support/guards.rb +28 -0
  154. data/spec/support/matchers.rb +4 -0
  155. data/spec/support/matchers/be_like.rb +24 -0
  156. data/spec/support/matchers/disambiguate_attributes.rb +28 -0
  157. data/spec/support/matchers/hash_the_same_as.rb +26 -0
  158. data/spec/support/matchers/have_rows.rb +18 -0
  159. data/spec/support/model.rb +62 -0
  160. data/spec/support/schemas/mysql_schema.rb +26 -0
  161. data/spec/support/schemas/oracle_schema.rb +20 -0
  162. data/spec/support/schemas/postgresql_schema.rb +26 -0
  163. data/spec/support/schemas/sqlite3_schema.rb +26 -0
  164. metadata +258 -0
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Group do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ @attribute = @relation[:id]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Insert do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Join do
5
+ before do
6
+ @relation1 = Table.new(:users)
7
+ @relation2 = Table.new(:photos)
8
+ @predicate = @relation1[:id].eq(@relation2[:user_id])
9
+ end
10
+
11
+ describe 'hashing' do
12
+ it 'implements hash equality' do
13
+ InnerJoin.new(@relation1, @relation2, @predicate) \
14
+ .should hash_the_same_as(InnerJoin.new(@relation1, @relation2, @predicate))
15
+ end
16
+ end
17
+
18
+ describe '#attributes' do
19
+ it 'combines the attributes of the two relations' do
20
+ join = InnerJoin.new(@relation1, @relation2, @predicate)
21
+ join.attributes.should == (@relation1.attributes | @relation2.attributes).bind(join)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Order do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ @attribute = @relation[:id]
8
+ end
9
+
10
+ describe "#==" do
11
+ it "returns true when the Orders are for the same attribute and direction" do
12
+ Ascending.new(@attribute).should == Ascending.new(@attribute)
13
+ end
14
+
15
+ it "returns false when the Orders are for a diferent direction" do
16
+ Ascending.new(@attribute).should_not == Descending.new(@attribute)
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Project do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ @attribute = @relation[:id]
8
+ end
9
+
10
+ describe '#attributes' do
11
+ before do
12
+ @projection = Project.new(@relation, @attribute)
13
+ end
14
+
15
+ it "manufactures attributes associated with the projection relation" do
16
+ @projection.attributes.should == [@attribute].collect { |a| a.bind(@projection) }
17
+ end
18
+ end
19
+
20
+ describe '#externalizable?' do
21
+ describe 'when the projections are attributes' do
22
+ it 'returns false' do
23
+ Project.new(@relation, @attribute).should_not be_externalizable
24
+ end
25
+ end
26
+
27
+ describe 'when the projections include an aggregation' do
28
+ it "obtains" do
29
+ Project.new(@relation, @attribute.sum).should be_externalizable
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,187 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Relation do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ @attribute1 = @relation[:id]
8
+ @attribute2 = @relation[:name]
9
+ end
10
+
11
+ describe '[]' do
12
+ describe 'when given an', Attribute do
13
+ it "return the attribute congruent to the provided attribute" do
14
+ @relation[@attribute1].should == @attribute1
15
+ end
16
+ end
17
+
18
+ describe 'when given a', Symbol, String do
19
+ it "returns the attribute with the same name" do
20
+ check @relation[:id].should == @attribute1
21
+ check @relation['id'].should == @attribute1
22
+ end
23
+ end
24
+ end
25
+
26
+ describe Relation::Operable do
27
+ describe 'joins' do
28
+ before do
29
+ @predicate = @relation[:id].eq(@relation[:id])
30
+ end
31
+
32
+ describe '#join' do
33
+ describe 'when given a relation' do
34
+ it "manufactures an inner join operation between those two relations" do
35
+ @relation.join(@relation).on(@predicate). \
36
+ should == InnerJoin.new(@relation, @relation, @predicate)
37
+ end
38
+ end
39
+
40
+ describe "when given a string" do
41
+ it "manufactures a join operation with the string passed through" do
42
+ @relation.join(arbitrary_string = "ASDF").should == StringJoin.new(@relation, arbitrary_string)
43
+ end
44
+ end
45
+
46
+ describe "when given something blank" do
47
+ it "returns self" do
48
+ @relation.join.should == @relation
49
+ end
50
+ end
51
+ end
52
+
53
+ describe '#outer_join' do
54
+ it "manufactures a left outer join operation between those two relations" do
55
+ @relation.outer_join(@relation).on(@predicate). \
56
+ should == OuterJoin.new(@relation, @relation, @predicate)
57
+ end
58
+ end
59
+ end
60
+
61
+ describe '#project' do
62
+ it "manufactures a projection relation" do
63
+ @relation.project(@attribute1, @attribute2). \
64
+ should == Project.new(@relation, @attribute1, @attribute2)
65
+ end
66
+
67
+ describe "when given blank attributes" do
68
+ it "returns self" do
69
+ @relation.project.should == @relation
70
+ end
71
+ end
72
+ end
73
+
74
+ describe '#alias' do
75
+ it "manufactures an alias relation" do
76
+ @relation.alias.relation.should == Alias.new(@relation).relation
77
+ end
78
+ end
79
+
80
+ describe '#where' do
81
+ before do
82
+ @predicate = Predicates::Equality.new(@attribute1, @attribute2)
83
+ end
84
+
85
+ it "manufactures a where relation" do
86
+ @relation.where(@predicate).should == Where.new(@relation, @predicate)
87
+ end
88
+
89
+ it "accepts arbitrary strings" do
90
+ @relation.where("arbitrary").should == Where.new(@relation, "arbitrary")
91
+ end
92
+
93
+ describe 'when given a blank predicate' do
94
+ it 'returns self' do
95
+ @relation.where.should == @relation
96
+ end
97
+ end
98
+ end
99
+
100
+ describe '#order' do
101
+ it "manufactures an order relation" do
102
+ @relation.order(@attribute1, @attribute2).should == Order.new(@relation, @attribute1, @attribute2)
103
+ end
104
+
105
+ describe 'when given a blank ordering' do
106
+ it 'returns self' do
107
+ @relation.order.should == @relation
108
+ end
109
+ end
110
+ end
111
+
112
+ describe '#take' do
113
+ it "manufactures a take relation" do
114
+ @relation.take(5).should == Take.new(@relation, 5)
115
+ end
116
+
117
+ describe 'when given a blank number of items' do
118
+ it 'returns self' do
119
+ @relation.take.should == @relation
120
+ end
121
+ end
122
+ end
123
+
124
+ describe '#skip' do
125
+ it "manufactures a skip relation" do
126
+ @relation.skip(4).should == Skip.new(@relation, 4)
127
+ end
128
+
129
+ describe 'when given a blank number of items' do
130
+ it 'returns self' do
131
+ @relation.skip.should == @relation
132
+ end
133
+ end
134
+ end
135
+
136
+ describe '#group' do
137
+ it 'manufactures a group relation' do
138
+ @relation.group(@attribute1, @attribute2).should == Group.new(@relation, @attribute1, @attribute2)
139
+ end
140
+
141
+ describe 'when given blank groupings' do
142
+ it 'returns self' do
143
+ @relation.group.should == @relation
144
+ end
145
+ end
146
+ end
147
+
148
+ describe Relation::Operable::Writable do
149
+ describe '#delete' do
150
+ it 'manufactures a deletion relation' do
151
+ Session.start do
152
+ Session.new.should_receive(:delete).with(Deletion.new(@relation))
153
+ @relation.delete
154
+ end
155
+ end
156
+ end
157
+
158
+ describe '#insert' do
159
+ it 'manufactures an insertion relation' do
160
+ Session.start do
161
+ record = { @relation[:name] => 'carl' }
162
+ Session.new.should_receive(:create).with(Insert.new(@relation, record))
163
+ @relation.insert(record)
164
+ end
165
+ end
166
+ end
167
+
168
+ describe '#update' do
169
+ it 'manufactures an update relation' do
170
+ Session.start do
171
+ assignments = { @relation[:name] => Value.new('bob', @relation) }
172
+ Session.new.should_receive(:update).with(Update.new(@relation, assignments))
173
+ @relation.update(assignments)
174
+ end
175
+ end
176
+ end
177
+ end
178
+ end
179
+
180
+ describe Relation::Enumerable do
181
+ it "implements enumerable" do
182
+ @relation.map { |value| value }.should ==
183
+ @relation.session.read(@relation).map { |value| value }
184
+ end
185
+ end
186
+ end
187
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Skip do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ @skipped = 4
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Table do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ end
8
+
9
+ describe '[]' do
10
+ describe 'when given a', Symbol do
11
+ it "manufactures an attribute if the symbol names an attribute within the relation" do
12
+ check @relation[:id].should == Attributes::Integer.new(@relation, :id)
13
+ end
14
+ end
15
+
16
+ describe 'when given an', Attribute do
17
+ it "returns the attribute if the attribute is within the relation" do
18
+ @relation[@relation[:id]].should == @relation[:id]
19
+ end
20
+
21
+ it "returns nil if the attribtue is not within the relation" do
22
+ another_relation = Table.new(:photos)
23
+ @relation[another_relation[:id]].should be_nil
24
+ end
25
+ end
26
+
27
+ describe 'when given an', Expression do
28
+ before do
29
+ @expression = @relation[:id].count
30
+ end
31
+
32
+ it "returns the Expression if the Expression is within the relation" do
33
+ @relation[@expression].should be_nil
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Take do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ @taken = 4
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Update do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Where do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ @predicate = @relation[:id].eq(1)
8
+ end
9
+
10
+ describe '#initialize' do
11
+ it "manufactures nested where relations if multiple predicates are provided" do
12
+ pending "This is not true anymore"
13
+ another_predicate = @relation[:name].lt(2)
14
+ Where.new(@relation, @predicate, another_predicate). \
15
+ should == Where.new(Where.new(@relation, another_predicate), @predicate)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ module Arel
4
+ describe Session do
5
+ before do
6
+ @relation = Table.new(:users)
7
+ @session = Session.new
8
+ end
9
+
10
+ describe '::start' do
11
+ describe '::instance' do
12
+ it "it is a singleton within the started session" do
13
+ Session.start do
14
+ Session.new.should == Session.new
15
+ end
16
+ end
17
+
18
+ it "is a singleton across nested sessions" do
19
+ Session.start do
20
+ outside = Session.new
21
+ Session.start do
22
+ Session.new.should == outside
23
+ end
24
+ end
25
+ end
26
+
27
+ it "manufactures new sessions outside of the started session" do
28
+ Session.new.should_not == Session.new
29
+ end
30
+ end
31
+ end
32
+
33
+ describe Session::CRUD do
34
+ before do
35
+ @insert = Insert.new(@relation, @relation[:name] => 'nick')
36
+ @update = Update.new(@relation, @relation[:name] => 'nick')
37
+ @delete = Deletion.new(@relation)
38
+ @read = @relation
39
+ end
40
+
41
+ describe '#create' do
42
+ it "executes an insertion on the connection" do
43
+ @insert.should_receive(:call)
44
+ @session.create(@insert)
45
+ end
46
+ end
47
+
48
+ describe '#read' do
49
+ it "executes an selection on the connection" do
50
+ @read.should_receive(:call)
51
+ @session.read(@read)
52
+ end
53
+
54
+ it "is memoized" do
55
+ @read.should_receive(:call).once
56
+ @session.read(@read)
57
+ @session.read(@read)
58
+ end
59
+ end
60
+
61
+ describe '#update' do
62
+ it "executes an update on the connection" do
63
+ @update.should_receive(:call)
64
+ @session.update(@update)
65
+ end
66
+ end
67
+
68
+ describe '#delete' do
69
+ it "executes a delete on the connection" do
70
+ @delete.should_receive(:call)
71
+ @session.delete(@delete)
72
+ end
73
+ end
74
+ end
75
+
76
+ describe 'Transactions' do
77
+ describe '#begin' do
78
+ end
79
+
80
+ describe '#end' do
81
+ end
82
+ end
83
+ end
84
+ end