amalgalite 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +7 -0
- data/lib/amalgalite/boolean.rb +1 -1
- data/lib/amalgalite/database.rb +1 -4
- data/lib/amalgalite/paths.rb +18 -18
- data/lib/amalgalite/sqlite3/constants.rb +2 -2
- data/lib/amalgalite/type_maps/default_map.rb +1 -1
- data/lib/amalgalite/version.rb +1 -1
- data/spec/aggregate_spec.rb +14 -14
- data/spec/blob_spec.rb +9 -9
- data/spec/database_spec.rb +57 -57
- data/spec/integeration_spec.rb +5 -5
- data/spec/packer_spec.rb +5 -5
- data/spec/progress_handler_spec.rb +2 -2
- data/spec/schema_spec.rb +19 -19
- data/spec/sqlite3/database_status_spec.rb +2 -2
- data/spec/sqlite3/status_spec.rb +1 -1
- data/spec/sqlite3/version_spec.rb +4 -4
- data/spec/sqlite3_spec.rb +16 -16
- data/spec/statement_spec.rb +22 -22
- data/spec/tap_spec.rb +5 -5
- data/tasks/config.rb +2 -4
- data/tasks/rspec.rake +3 -2
- metadata +2 -2
data/HISTORY
CHANGED
data/lib/amalgalite/boolean.rb
CHANGED
data/lib/amalgalite/database.rb
CHANGED
@@ -212,10 +212,7 @@ module Amalgalite
|
|
212
212
|
# return the encoding of the database
|
213
213
|
#
|
214
214
|
def encoding
|
215
|
-
|
216
|
-
@encoding = pragma( "encoding" ).first['encoding']
|
217
|
-
end
|
218
|
-
return @encoding
|
215
|
+
@encoding ||= pragma( "encoding" ).first['encoding']
|
219
216
|
end
|
220
217
|
|
221
218
|
##
|
data/lib/amalgalite/paths.rb
CHANGED
@@ -11,50 +11,50 @@ module Amalgalite
|
|
11
11
|
#
|
12
12
|
# The root directory of the project is considered to be the parent directory
|
13
13
|
# of the 'lib' directory.
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# returns:: [String] The full expanded path of the parent directory of 'lib'
|
16
16
|
# going up the path from the current file. Trailing
|
17
17
|
# File::SEPARATOR is guaranteed.
|
18
|
-
#
|
18
|
+
#
|
19
19
|
def self.root_dir
|
20
|
-
|
20
|
+
@root_dir ||= (
|
21
21
|
path_parts = ::File.expand_path(__FILE__).split(::File::SEPARATOR)
|
22
22
|
lib_index = path_parts.rindex("lib")
|
23
|
-
|
24
|
-
|
23
|
+
path_parts[0...lib_index].join(::File::SEPARATOR) + ::File::SEPARATOR
|
24
|
+
)
|
25
25
|
return @root_dir
|
26
|
-
end
|
26
|
+
end
|
27
27
|
|
28
28
|
# returns:: [String] The full expanded path of the +config+ directory
|
29
29
|
# below _root_dir_. All parameters passed in are joined onto the
|
30
30
|
# result. Trailing File::SEPARATOR is guaranteed if _args_ are
|
31
31
|
# *not* present.
|
32
|
-
#
|
32
|
+
#
|
33
33
|
def self.config_path(*args)
|
34
34
|
self.sub_path("config", *args)
|
35
|
-
end
|
35
|
+
end
|
36
36
|
|
37
37
|
# returns:: [String] The full expanded path of the +data+ directory below
|
38
|
-
# _root_dir_. All parameters passed in are joined onto the
|
39
|
-
# result. Trailing File::SEPARATOR is guaranteed if
|
38
|
+
# _root_dir_. All parameters passed in are joined onto the
|
39
|
+
# result. Trailing File::SEPARATOR is guaranteed if
|
40
40
|
# _*args_ are *not* present.
|
41
|
-
#
|
41
|
+
#
|
42
42
|
def self.data_path(*args)
|
43
43
|
self.sub_path("data", *args)
|
44
|
-
end
|
44
|
+
end
|
45
45
|
|
46
46
|
# returns:: [String] The full expanded path of the +lib+ directory below
|
47
|
-
# _root_dir_. All parameters passed in are joined onto the
|
48
|
-
# result. Trailing File::SEPARATOR is guaranteed if
|
47
|
+
# _root_dir_. All parameters passed in are joined onto the
|
48
|
+
# result. Trailing File::SEPARATOR is guaranteed if
|
49
49
|
# _*args_ are *not* present.
|
50
|
-
#
|
50
|
+
#
|
51
51
|
def self.lib_path(*args)
|
52
52
|
self.sub_path("lib", *args)
|
53
|
-
end
|
53
|
+
end
|
54
54
|
|
55
55
|
# returns:: [String] The full expanded path of the +ext+ directory below
|
56
|
-
# _root_dir_. All parameters passed in are joined onto the
|
57
|
-
# result. Trailing File::SEPARATOR is guaranteed if
|
56
|
+
# _root_dir_. All parameters passed in are joined onto the
|
57
|
+
# result. Trailing File::SEPARATOR is guaranteed if
|
58
58
|
# _*args_ are *not* present.
|
59
59
|
#
|
60
60
|
def self.ext_path(*args)
|
@@ -12,7 +12,7 @@ module Amalgalite::SQLite3
|
|
12
12
|
# constant. this is a helper method used by some of the other modules
|
13
13
|
#
|
14
14
|
def name_from_value( value )
|
15
|
-
unless @const_map_from_value
|
15
|
+
unless defined? @const_map_from_value
|
16
16
|
@const_map_from_value = {}
|
17
17
|
constants.each do |const_name|
|
18
18
|
c_int = const_get( const_name )
|
@@ -27,7 +27,7 @@ module Amalgalite::SQLite3
|
|
27
27
|
# some of the other modules
|
28
28
|
#
|
29
29
|
def value_from_name( name )
|
30
|
-
unless @const_map_from_name
|
30
|
+
unless defined? @const_map_from_name
|
31
31
|
@const_map_from_name = {}
|
32
32
|
constants.each do |const_name|
|
33
33
|
c_int = const_get( const_name )
|
@@ -34,7 +34,7 @@ module Amalgalite::TypeMaps
|
|
34
34
|
# say what method to call to convert an sql type to a ruby type
|
35
35
|
#
|
36
36
|
def sql_to_method( sql_type ) # :nodoc:
|
37
|
-
unless @sql_to_method
|
37
|
+
unless defined? @sql_to_method
|
38
38
|
@sql_to_method = {}
|
39
39
|
methods_handling_sql_types.each_pair do |method, sql_types|
|
40
40
|
sql_types.each { |t| @sql_to_method[t] = method }
|
data/lib/amalgalite/version.rb
CHANGED
data/spec/aggregate_spec.rb
CHANGED
@@ -43,29 +43,29 @@ describe "Aggregate SQL Functions" do
|
|
43
43
|
it "can define a custom SQL aggregate as a class with N params" do
|
44
44
|
@iso_db.define_aggregate("atest1", AggregateTest1 )
|
45
45
|
r = @iso_db.execute("SELECT atest1(id,name) as a, count(*) as c FROM country")
|
46
|
-
r.first['a'].should
|
47
|
-
r.first['a'].should
|
46
|
+
r.first['a'].should eql(r.first['c'])
|
47
|
+
r.first['a'].should eql(242)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "can remove a custom SQL aggregate by class" do
|
51
51
|
@iso_db.define_aggregate("atest1", AggregateTest1 )
|
52
|
-
@iso_db.aggregates.size.should
|
52
|
+
@iso_db.aggregates.size.should eql(1)
|
53
53
|
r = @iso_db.execute("SELECT atest1(id,name) as a, count(*) as c FROM country")
|
54
|
-
r.first['a'].should
|
55
|
-
r.first['a'].should
|
54
|
+
r.first['a'].should eql(r.first['c'])
|
55
|
+
r.first['a'].should eql(242)
|
56
56
|
@iso_db.remove_aggregate( "atest1", AggregateTest1 )
|
57
|
-
@iso_db.aggregates.size.should
|
57
|
+
@iso_db.aggregates.size.should eql(0)
|
58
58
|
lambda{ @iso_db.execute("SELECT atest1(id,name) as a, count(*) as c FROM country") }.should raise_error(::Amalgalite::SQLite3::Error, /no such function: atest1/ )
|
59
59
|
end
|
60
60
|
|
61
61
|
it "can remove a custom SQL aggregate by arity" do
|
62
62
|
@iso_db.define_aggregate("atest1", AggregateTest1 )
|
63
|
-
@iso_db.aggregates.size.should
|
63
|
+
@iso_db.aggregates.size.should eql(1)
|
64
64
|
r = @iso_db.execute("SELECT atest1(id,name) as a, count(*) as c FROM country")
|
65
|
-
r.first['a'].should
|
66
|
-
r.first['a'].should
|
65
|
+
r.first['a'].should eql(r.first['c'])
|
66
|
+
r.first['a'].should eql(242)
|
67
67
|
@iso_db.remove_aggregate( "atest1", -1)
|
68
|
-
@iso_db.aggregates.size.should
|
68
|
+
@iso_db.aggregates.size.should eql(0)
|
69
69
|
lambda{ @iso_db.execute("SELECT atest1(id,name) as a, count(*) as c FROM country") }.should raise_error(::Amalgalite::SQLite3::Error, /no such function: atest1/ )
|
70
70
|
end
|
71
71
|
|
@@ -75,12 +75,12 @@ describe "Aggregate SQL Functions" do
|
|
75
75
|
end
|
76
76
|
@iso_db.define_aggregate("atest1", AggregateTest1 )
|
77
77
|
@iso_db.define_aggregate("atest1", AT2)
|
78
|
-
@iso_db.aggregates.size.should
|
78
|
+
@iso_db.aggregates.size.should eql(2)
|
79
79
|
r = @iso_db.execute("SELECT atest1(id,name) as a, atest1(id), count(*) as c FROM country")
|
80
|
-
r.first['a'].should
|
81
|
-
r.first['a'].should
|
80
|
+
r.first['a'].should eql(r.first['c'])
|
81
|
+
r.first['a'].should eql(242)
|
82
82
|
@iso_db.remove_aggregate( "atest1" )
|
83
|
-
@iso_db.aggregates.size.should
|
83
|
+
@iso_db.aggregates.size.should eql(0)
|
84
84
|
lambda{ @iso_db.execute("SELECT atest1(id,name) as a, count(*) as c FROM country") }.should raise_error(::Amalgalite::SQLite3::Error, /no such function: atest1/ )
|
85
85
|
end
|
86
86
|
|
data/spec/blob_spec.rb
CHANGED
@@ -46,27 +46,27 @@ describe Amalgalite::Blob do
|
|
46
46
|
|
47
47
|
it "and retrieves the data as a single value" do
|
48
48
|
all_rows = @db.execute("SELECT name,data FROM blobs")
|
49
|
-
all_rows.size.should
|
50
|
-
all_rows.first['name'].should
|
49
|
+
all_rows.size.should eql(1)
|
50
|
+
all_rows.first['name'].should eql(DATA_FILE)
|
51
51
|
all_rows.first['data'].should_not be_incremental
|
52
|
-
all_rows.first['data'].to_string_io.string.should
|
52
|
+
all_rows.first['data'].to_string_io.string.should eql(IO.read( DATA_FILE ))
|
53
53
|
end
|
54
54
|
|
55
55
|
it "and retrieves the data using incremental IO" do
|
56
56
|
all_rows = @db.execute("SELECT * FROM blobs")
|
57
|
-
all_rows.size.should
|
58
|
-
all_rows.first['name'].should
|
57
|
+
all_rows.size.should eql(1)
|
58
|
+
all_rows.first['name'].should eql(DATA_FILE)
|
59
59
|
all_rows.first['data'].should be_incremental
|
60
|
-
all_rows.first['data'].to_string_io.string.should
|
60
|
+
all_rows.first['data'].to_string_io.string.should eql(IO.read( DATA_FILE ))
|
61
61
|
end
|
62
62
|
|
63
63
|
it "writes the data to a file " do
|
64
64
|
all_rows = @db.execute("SELECT * FROM blobs")
|
65
|
-
all_rows.size.should
|
66
|
-
all_rows.first['name'].should
|
65
|
+
all_rows.size.should eql(1)
|
66
|
+
all_rows.first['name'].should eql(DATA_FILE)
|
67
67
|
all_rows.first['data'].should be_incremental
|
68
68
|
all_rows.first['data'].write_to_file( @junk_file )
|
69
|
-
IO.read( @junk_file).should
|
69
|
+
IO.read( @junk_file).should eql(IO.read( DATA_FILE ))
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
data/spec/database_spec.rb
CHANGED
@@ -25,14 +25,14 @@ describe Amalgalite::Database do
|
|
25
25
|
db = Amalgalite::Database.new( SpecInfo.test_db )
|
26
26
|
db.instance_of?(Amalgalite::Database)
|
27
27
|
db.api.instance_of?(Amalgalite::SQLite3::Database)
|
28
|
-
File.exist?( SpecInfo.test_db ).should
|
28
|
+
File.exist?( SpecInfo.test_db ).should eql(true)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "creates a new UTF-8 database (need exec to check pragma encoding)" do
|
32
32
|
db = Amalgalite::Database.new( SpecInfo.test_db )
|
33
33
|
db.execute_batch( @schema );
|
34
34
|
db.should_not be_utf16
|
35
|
-
db.encoding.should
|
35
|
+
db.encoding.should eql("UTF-8")
|
36
36
|
end
|
37
37
|
|
38
38
|
it "creates a new UTF-16 database (need exec to check pragma encoding)"
|
@@ -47,15 +47,15 @@ describe Amalgalite::Database do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "can be in autocommit mode, and is by default" do
|
50
|
-
@iso_db.autocommit?.should
|
50
|
+
@iso_db.autocommit?.should eql(true)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "reports false for autocommit? when inside a transaction" do
|
54
54
|
@iso_db.execute(" BEGIN ")
|
55
|
-
@iso_db.autocommit?.should
|
56
|
-
@iso_db.in_transaction?.should
|
55
|
+
@iso_db.autocommit?.should eql(false)
|
56
|
+
@iso_db.in_transaction?.should eql(true)
|
57
57
|
@iso_db.execute(" COMMIT")
|
58
|
-
@iso_db.in_transaction?.should
|
58
|
+
@iso_db.in_transaction?.should eql(false)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "prepares a statment" do
|
@@ -77,7 +77,7 @@ describe Amalgalite::Database do
|
|
77
77
|
|
78
78
|
it "returns the id of the last inserted row" do
|
79
79
|
db = Amalgalite::Database.new( SpecInfo.test_db )
|
80
|
-
db.last_insert_rowid.should
|
80
|
+
db.last_insert_rowid.should eql(0)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "is in autocommit mode by default" do
|
@@ -94,8 +94,8 @@ describe Amalgalite::Database do
|
|
94
94
|
INSERT INTO t1( x ) values ( 3 );
|
95
95
|
sql
|
96
96
|
|
97
|
-
db.row_changes.should
|
98
|
-
db.total_changes.should
|
97
|
+
db.row_changes.should eql(1)
|
98
|
+
db.total_changes.should eql(3)
|
99
99
|
db.close
|
100
100
|
end
|
101
101
|
|
@@ -108,7 +108,7 @@ describe Amalgalite::Database do
|
|
108
108
|
INSERT INTO t1( x ) values ( 3 );
|
109
109
|
DELETE FROM t1 where x < 3;
|
110
110
|
sql
|
111
|
-
db.row_changes.should
|
111
|
+
db.row_changes.should eql(2)
|
112
112
|
db.close
|
113
113
|
end
|
114
114
|
|
@@ -119,7 +119,7 @@ describe Amalgalite::Database do
|
|
119
119
|
|
120
120
|
it "can execute a batch of commands" do
|
121
121
|
db = Amalgalite::Database.new( SpecInfo.test_db )
|
122
|
-
db.execute_batch( @schema ).should
|
122
|
+
db.execute_batch( @schema ).should eql(5)
|
123
123
|
end
|
124
124
|
|
125
125
|
it "returns an empty array when there are no results" do
|
@@ -132,9 +132,9 @@ describe Amalgalite::Database do
|
|
132
132
|
sql = "CREATE TABLE trace_test( x, y, z)"
|
133
133
|
s = db.trace_tap = ::Amalgalite::Taps::StringIO.new
|
134
134
|
db.execute( sql )
|
135
|
-
db.trace_tap.string.should
|
135
|
+
db.trace_tap.string.should eql("registered as trace tap\n#{sql}\n")
|
136
136
|
db.trace_tap = nil
|
137
|
-
s.string.should
|
137
|
+
s.string.should eql("registered as trace tap\n#{sql}\nunregistered as trace tap\n")
|
138
138
|
end
|
139
139
|
|
140
140
|
it "raises an exception if the wrong type of object is used for tracing" do
|
@@ -151,7 +151,7 @@ describe Amalgalite::Database do
|
|
151
151
|
db = Amalgalite::Database.new( SpecInfo.test_db )
|
152
152
|
s = db.profile_tap = ::Amalgalite::Taps::StringIO.new
|
153
153
|
db.execute_batch( @schema )
|
154
|
-
db.profile_tap.samplers.size.should
|
154
|
+
db.profile_tap.samplers.size.should eql(6)
|
155
155
|
db.profile_tap = nil
|
156
156
|
s.string.should =~ /unregistered as profile tap/m
|
157
157
|
end
|
@@ -161,7 +161,7 @@ describe Amalgalite::Database do
|
|
161
161
|
@iso_db.execute( "SELECT * FROM country LIMIT 10") do |row|
|
162
162
|
count += 1
|
163
163
|
end
|
164
|
-
count.should
|
164
|
+
count.should eql(10)
|
165
165
|
end
|
166
166
|
|
167
167
|
it "#pragma yields each row when called with a block" do
|
@@ -169,13 +169,13 @@ describe Amalgalite::Database do
|
|
169
169
|
@iso_db.pragma( "index_info( subcountry_country )" ) do |row|
|
170
170
|
count += 1
|
171
171
|
end
|
172
|
-
count.should
|
172
|
+
count.should eql(1)
|
173
173
|
end
|
174
174
|
|
175
175
|
it "can use something that responds to 'write' as a tap" do
|
176
176
|
db = Amalgalite::Database.new( SpecInfo.test_db )
|
177
177
|
s2 = db.trace_tap = StringIO.new
|
178
|
-
s2.string.should
|
178
|
+
s2.string.should eql("registered as trace tap")
|
179
179
|
end
|
180
180
|
|
181
181
|
it "can clear all registered taps" do
|
@@ -183,7 +183,7 @@ describe Amalgalite::Database do
|
|
183
183
|
s = db.profile_tap = ::Amalgalite::Taps::StringIO.new
|
184
184
|
db.trace_tap = s
|
185
185
|
db.execute_batch( @schema )
|
186
|
-
db.profile_tap.samplers.size.should
|
186
|
+
db.profile_tap.samplers.size.should eql(6)
|
187
187
|
db.clear_taps!
|
188
188
|
s.string.should =~ /unregistered as trace tap/m
|
189
189
|
s.string.should =~ /unregistered as profile tap/m
|
@@ -193,50 +193,50 @@ describe Amalgalite::Database do
|
|
193
193
|
db = Amalgalite::Database.new( SpecInfo.test_db )
|
194
194
|
r = db.transaction do |db2|
|
195
195
|
r2 = db.transaction { 42 }
|
196
|
-
r2.should
|
196
|
+
r2.should eql(42)
|
197
197
|
r2
|
198
198
|
end
|
199
|
-
r.should
|
199
|
+
r.should eql(42)
|
200
200
|
end
|
201
201
|
|
202
202
|
it "returns the result of the transaction when a block is yielded" do
|
203
203
|
db = Amalgalite::Database.new( SpecInfo.test_db )
|
204
|
-
(db.transaction { 42 }).should
|
204
|
+
(db.transaction { 42 }).should eql(42)
|
205
205
|
end
|
206
206
|
|
207
207
|
it "#reload_schema!" do
|
208
208
|
@iso_db = Amalgalite::Database.new( SpecInfo.make_iso_db )
|
209
209
|
schema = @iso_db.schema
|
210
|
-
schema.instance_of?( Amalgalite::Schema ).should
|
210
|
+
schema.instance_of?( Amalgalite::Schema ).should eql(true)
|
211
211
|
s2 = @iso_db.reload_schema!
|
212
|
-
s2.object_id.should_not
|
212
|
+
s2.object_id.should_not eql(schema.object_id)
|
213
213
|
end
|
214
214
|
|
215
215
|
it "can rollback a transaction" do
|
216
216
|
@iso_db.transaction
|
217
217
|
r = @iso_db.execute("SELECT count(1) as cnt FROM country");
|
218
|
-
r.first['cnt'].should
|
218
|
+
r.first['cnt'].should eql(242)
|
219
219
|
@iso_db.execute("DELETE FROM country")
|
220
220
|
r = @iso_db.execute("SELECT count(1) as cnt FROM country");
|
221
|
-
r.first['cnt'].should
|
221
|
+
r.first['cnt'].should eql(0)
|
222
222
|
@iso_db.rollback
|
223
223
|
|
224
224
|
r = @iso_db.execute("SELECT count(1) as cnt FROM country");
|
225
|
-
r.first['cnt'].should
|
225
|
+
r.first['cnt'].should eql(242)
|
226
226
|
end
|
227
227
|
|
228
228
|
it "rolls back if an exception happens during a transaction block" do
|
229
229
|
begin
|
230
230
|
@iso_db.transaction do |db|
|
231
231
|
r = db.execute("SELECT count(1) as cnt FROM country");
|
232
|
-
r.first['cnt'].should
|
232
|
+
r.first['cnt'].should eql(242)
|
233
233
|
db.execute("DELETE FROM country")
|
234
|
-
db.in_transaction?.should
|
234
|
+
db.in_transaction?.should eql(true)
|
235
235
|
raise "testing rollback"
|
236
236
|
end
|
237
237
|
rescue => e
|
238
|
-
@iso_db.in_transaction?.should
|
239
|
-
@iso_db.execute("SELECT count(1) as cnt FROM country").first['cnt'].should
|
238
|
+
@iso_db.in_transaction?.should eql(false)
|
239
|
+
@iso_db.execute("SELECT count(1) as cnt FROM country").first['cnt'].should eql(242)
|
240
240
|
end
|
241
241
|
end
|
242
242
|
|
@@ -268,13 +268,13 @@ describe Amalgalite::Database do
|
|
268
268
|
@iso_db.define_function( "rtest" ) do
|
269
269
|
"rtest called"
|
270
270
|
end
|
271
|
-
@iso_db.functions.size.should
|
271
|
+
@iso_db.functions.size.should eql(1 )
|
272
272
|
|
273
273
|
r = @iso_db.execute( "select rtest() AS r" )
|
274
|
-
r.first['r'].should
|
274
|
+
r.first['r'].should eql("rtest called")
|
275
275
|
@iso_db.remove_function("rtest", -1)
|
276
276
|
lambda { @iso_db.execute( "select rtest() as r" )}.should raise_error( ::Amalgalite::SQLite3::Error, /no such function: rtest/ )
|
277
|
-
@iso_db.functions.size.should
|
277
|
+
@iso_db.functions.size.should eql(0)
|
278
278
|
end
|
279
279
|
|
280
280
|
it "unregisters a function by instances" do
|
@@ -285,12 +285,12 @@ describe Amalgalite::Database do
|
|
285
285
|
def call( *args) "ftest5 called"; end
|
286
286
|
end
|
287
287
|
@iso_db.define_function("ftest5", FunctionTest5.new )
|
288
|
-
@iso_db.functions.size.should
|
288
|
+
@iso_db.functions.size.should eql(1)
|
289
289
|
r = @iso_db.execute( "select ftest5() AS r" )
|
290
|
-
r.first['r'].should
|
290
|
+
r.first['r'].should eql("ftest5 called")
|
291
291
|
@iso_db.remove_function("ftest5", FunctionTest5.new )
|
292
292
|
lambda { @iso_db.execute( "select ftest5() as r" )}.should raise_error( ::Amalgalite::SQLite3::Error, /no such function: ftest5/ )
|
293
|
-
@iso_db.functions.size.should
|
293
|
+
@iso_db.functions.size.should eql(0)
|
294
294
|
end
|
295
295
|
|
296
296
|
it "unregisters all functions with the same name" do
|
@@ -302,15 +302,15 @@ describe Amalgalite::Database do
|
|
302
302
|
"rtest/0 called"
|
303
303
|
end
|
304
304
|
|
305
|
-
@iso_db.functions.size.should
|
305
|
+
@iso_db.functions.size.should eql(2)
|
306
306
|
r = @iso_db.execute( "select rtest(1) AS r")
|
307
|
-
r.first['r'].should
|
307
|
+
r.first['r'].should eql("rtest 1 called")
|
308
308
|
r = @iso_db.execute( "select rtest() AS r")
|
309
|
-
r.first['r'].should
|
309
|
+
r.first['r'].should eql("rtest/0 called")
|
310
310
|
@iso_db.remove_function( 'rtest' )
|
311
311
|
lambda { @iso_db.execute( "select rtest(1) AS r") }.should raise_error( ::Amalgalite::SQLite3::Error )
|
312
312
|
lambda { @iso_db.execute( "select rtest() AS r") }.should raise_error( ::Amalgalite::SQLite3::Error )
|
313
|
-
@iso_db.functions.size.should
|
313
|
+
@iso_db.functions.size.should eql(0)
|
314
314
|
end
|
315
315
|
end
|
316
316
|
|
@@ -349,7 +349,7 @@ describe Amalgalite::Database do
|
|
349
349
|
|
350
350
|
it "releases a savepoint" do
|
351
351
|
us_sub = @iso_db.execute( "select count(1) as cnt from subcountry where country = 'US'" ).first['cnt']
|
352
|
-
us_sub.should
|
352
|
+
us_sub.should eql(57)
|
353
353
|
other_sub = @iso_db.execute( "select count(1) as cnt from subcountry where country != 'US'" ).first['cnt']
|
354
354
|
|
355
355
|
@iso_db.transaction
|
@@ -359,10 +359,10 @@ describe Amalgalite::Database do
|
|
359
359
|
|
360
360
|
all_sub = @iso_db.execute("SELECT count(*) as cnt from subcountry").first['cnt']
|
361
361
|
|
362
|
-
all_sub.should
|
362
|
+
all_sub.should eql(other_sub)
|
363
363
|
@iso_db.rollback
|
364
364
|
all_sub = @iso_db.execute("SELECT count(*) as cnt from subcountry").first['cnt']
|
365
|
-
all_sub.should
|
365
|
+
all_sub.should eql(( us_sub + other_sub ))
|
366
366
|
|
367
367
|
end
|
368
368
|
|
@@ -375,7 +375,7 @@ describe Amalgalite::Database do
|
|
375
375
|
end
|
376
376
|
}.should raise_error( StandardError, /sample error/ )
|
377
377
|
|
378
|
-
@iso_db.execute("SELECT count(*) as cnt from subcountry").first['cnt'].should
|
378
|
+
@iso_db.execute("SELECT count(*) as cnt from subcountry").first['cnt'].should eql(all_sub)
|
379
379
|
end
|
380
380
|
|
381
381
|
it "rolling back the outermost savepoint is still 'in_transaction'" do
|
@@ -388,19 +388,19 @@ describe Amalgalite::Database do
|
|
388
388
|
end
|
389
389
|
|
390
390
|
it "can escape quoted strings" do
|
391
|
-
@iso_db.escape( "It's a happy day!" ).should
|
391
|
+
@iso_db.escape( "It's a happy day!" ).should eql("It''s a happy day!")
|
392
392
|
end
|
393
393
|
|
394
394
|
it "can quote and escape single quoted strings" do
|
395
|
-
@iso_db.quote( "It's a happy day!" ).should
|
395
|
+
@iso_db.quote( "It's a happy day!" ).should eql("'It''s a happy day!'")
|
396
396
|
end
|
397
397
|
|
398
398
|
it "can escape a symbol" do
|
399
|
-
@iso_db.escape( :stuff ).should
|
399
|
+
@iso_db.escape( :stuff ).should eql("stuff")
|
400
400
|
end
|
401
401
|
|
402
402
|
it "can quote a symbol" do
|
403
|
-
@iso_db.quote( :stuff ).should
|
403
|
+
@iso_db.quote( :stuff ).should eql("'stuff'")
|
404
404
|
end
|
405
405
|
|
406
406
|
it "returns the first row of results as a convenience" do
|
@@ -410,13 +410,13 @@ describe Amalgalite::Database do
|
|
410
410
|
ON c.two_letter = sc.country
|
411
411
|
GROUP BY c.name, c.two_letter
|
412
412
|
ORDER BY count DESC")
|
413
|
-
row.length.should
|
414
|
-
row[0].should
|
415
|
-
row[1].should
|
416
|
-
row[2].should
|
417
|
-
row['name'].should
|
418
|
-
row['two_letter'].should
|
419
|
-
row['count'].should
|
413
|
+
row.length.should eql(3)
|
414
|
+
row[0].should eql("United Kingdom")
|
415
|
+
row[1].should eql("GB")
|
416
|
+
row[2].should eql(232)
|
417
|
+
row['name'].should eql("United Kingdom")
|
418
|
+
row['two_letter'].should eql("GB")
|
419
|
+
row['count'].should eql(232)
|
420
420
|
end
|
421
421
|
|
422
422
|
it "returns and empty row if there are no results for the first row" do
|
@@ -426,12 +426,12 @@ describe Amalgalite::Database do
|
|
426
426
|
|
427
427
|
it "returns nil if there is no value in the first value" do
|
428
428
|
val = @iso_db.first_value_from("select * from subcountry where country = 'Antarctica'" )
|
429
|
-
val.should
|
429
|
+
val.should eql(nil)
|
430
430
|
end
|
431
431
|
|
432
432
|
it "returns the first value of results as a conveinience" do
|
433
433
|
val = @iso_db.first_value_from("SELECT count(*) from subcountry ")
|
434
|
-
val.should
|
434
|
+
val.should eql(3995)
|
435
435
|
end
|
436
436
|
|
437
437
|
end
|
data/spec/integeration_spec.rb
CHANGED
@@ -50,12 +50,12 @@ describe "Integration specifications" do
|
|
50
50
|
db.execute "CREATE TABLE t( c #{sql_type} )"
|
51
51
|
db.execute "insert into t (c) values ( ? )", ruby_info[:value]
|
52
52
|
rows = db.execute "select * from t"
|
53
|
-
rows.first['c'].class.should
|
53
|
+
rows.first['c'].class.should eql(ruby_info[:klass])
|
54
54
|
|
55
55
|
if [ DateTime, Time ].include?( ruby_info[:klass] ) then
|
56
|
-
rows.first['c'].strftime("%Y-%m-%d %H:%M:%S").should
|
56
|
+
rows.first['c'].strftime("%Y-%m-%d %H:%M:%S").should eql(ruby_info[:value].strftime("%Y-%m-%d %H:%M:%S"))
|
57
57
|
else
|
58
|
-
rows.first['c'].should
|
58
|
+
rows.first['c'].should eql(ruby_info[:value])
|
59
59
|
end
|
60
60
|
db.close
|
61
61
|
end
|
@@ -79,7 +79,7 @@ describe "Integration specifications" do
|
|
79
79
|
db.execute "CREATE TABLE t( c #{sql_type} )"
|
80
80
|
db.execute "insert into t (c) values ( ? )", ruby_info[:value]
|
81
81
|
rows = db.execute "select * from t"
|
82
|
-
rows.first['c'].should
|
82
|
+
rows.first['c'].should eql(ruby_info[:result])
|
83
83
|
db.close
|
84
84
|
end
|
85
85
|
end
|
@@ -102,7 +102,7 @@ describe "Integration specifications" do
|
|
102
102
|
db.execute "CREATE TABLE t( c #{sql_type} )"
|
103
103
|
db.execute "insert into t (c) values ( ? )", ruby_info[:value]
|
104
104
|
rows = db.execute "select * from t"
|
105
|
-
rows.first['c'].should
|
105
|
+
rows.first['c'].should eql(ruby_info[:result])
|
106
106
|
db.close
|
107
107
|
end
|
108
108
|
end
|
data/spec/packer_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe "Amalgalite::Packer" do
|
|
21
21
|
db = Amalgalite::Database.new( @packer.dbfile )
|
22
22
|
db.schema.tables[ @table ].should_not be_nil
|
23
23
|
count = db.execute("SELECT count(1) FROM #{@table}").first
|
24
|
-
count.first.should
|
24
|
+
count.first.should eql(Amalgalite::Packer.amalgalite_require_order.size)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "recreates the table if :drop_table option is given " do
|
@@ -29,13 +29,13 @@ describe "Amalgalite::Packer" do
|
|
29
29
|
db = Amalgalite::Database.new( @packer.dbfile )
|
30
30
|
db.schema.tables[ @table ].should_not be_nil
|
31
31
|
count = db.execute("SELECT count(1) FROM #{@table}").first
|
32
|
-
count.first.should
|
32
|
+
count.first.should eql(Amalgalite::Packer.amalgalite_require_order.size)
|
33
33
|
|
34
34
|
np = Amalgalite::Packer.new( :drop_table => true, :table_name => @table )
|
35
|
-
np.options[ :drop_table ].should
|
35
|
+
np.options[ :drop_table ].should eql(true)
|
36
36
|
np.check_db( db )
|
37
37
|
count = db.execute("SELECT count(1) FROM #{@table}").first
|
38
|
-
count.first.should
|
38
|
+
count.first.should eql(0)
|
39
39
|
|
40
40
|
end
|
41
41
|
|
@@ -46,7 +46,7 @@ describe "Amalgalite::Packer" do
|
|
46
46
|
orig = IO.read( File.join( File.dirname( __FILE__ ), "..", "lib", "amalgalite.rb" ) )
|
47
47
|
zipped = db.execute("SELECT contents FROM #{@table} WHERE filename = 'amalgalite'")
|
48
48
|
expanded = Amalgalite::Packer.gunzip( zipped.first['contents'].to_s )
|
49
|
-
expanded.should
|
49
|
+
expanded.should eql(orig)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "has all the lib files in the amalgalite gem" do
|
@@ -80,7 +80,7 @@ describe "Progress Handlers" do
|
|
80
80
|
@iso_db.progress_handler( 5, ph )
|
81
81
|
qt = query_thread( @iso_db )
|
82
82
|
qt.join
|
83
|
-
ph.call_count.should
|
83
|
+
ph.call_count.should eql(25)
|
84
84
|
qt[:exception].should be_instance_of( ::Amalgalite::SQLite3::Error )
|
85
85
|
qt[:exception].message.should =~ /interrupted/
|
86
86
|
end
|
@@ -97,7 +97,7 @@ describe "Progress Handlers" do
|
|
97
97
|
@iso_db.remove_progress_handler
|
98
98
|
qt = query_thread( @iso_db )
|
99
99
|
qt.join
|
100
|
-
ph.call_count.should
|
100
|
+
ph.call_count.should eql(0)
|
101
101
|
qt[:exception].should be_nil
|
102
102
|
end
|
103
103
|
end
|
data/spec/schema_spec.rb
CHANGED
@@ -21,38 +21,38 @@ describe Amalgalite::Schema do
|
|
21
21
|
it "loads the schema of a database" do
|
22
22
|
schema = @iso_db.schema
|
23
23
|
schema.load_tables
|
24
|
-
schema.tables.size.should
|
24
|
+
schema.tables.size.should eql(2)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "lazily loads new table schema" do
|
28
|
-
@iso_db.schema.tables.size.should
|
28
|
+
@iso_db.schema.tables.size.should eql(2)
|
29
29
|
sql = "CREATE TABLE t1 ( a, b, c )"
|
30
30
|
@iso_db.execute( sql )
|
31
|
-
@iso_db.schema.tables.size.should
|
31
|
+
@iso_db.schema.tables.size.should eql(2)
|
32
32
|
@iso_db.schema.dirty!
|
33
|
-
@iso_db.schema.tables['t1'].column_names.should
|
34
|
-
@iso_db.schema.tables.size.should
|
33
|
+
@iso_db.schema.tables['t1'].column_names.should eql(%w[ a b c ])
|
34
|
+
@iso_db.schema.tables.size.should eql(3)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "loads the views in the database" do
|
38
38
|
sql = "CREATE VIEW v1 AS SELECT c.name, c.two_letter, s.name, s.subdivision FROM country AS c JOIN subcountry AS s ON c.two_letter = s.country"
|
39
39
|
@iso_db.execute( sql )
|
40
40
|
@iso_db.schema.load_views
|
41
|
-
@iso_db.schema.views.size.should
|
42
|
-
@iso_db.schema.views["v1"].sql.should
|
41
|
+
@iso_db.schema.views.size.should eql(1)
|
42
|
+
@iso_db.schema.views["v1"].sql.should eql(sql)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "loads the tables and columns" do
|
46
46
|
ct = @iso_db.schema.tables['country']
|
47
|
-
ct.name.should
|
48
|
-
ct.columns.size.should
|
49
|
-
ct.indexes.size.should
|
50
|
-
ct.column_names.should
|
51
|
-
@iso_db.schema.tables.size.should
|
47
|
+
ct.name.should eql("country")
|
48
|
+
ct.columns.size.should eql(3)
|
49
|
+
ct.indexes.size.should eql(2)
|
50
|
+
ct.column_names.should eql(%w[ name two_letter id ])
|
51
|
+
@iso_db.schema.tables.size.should eql(2)
|
52
52
|
|
53
53
|
|
54
54
|
ct.columns['two_letter'].should be_primary_key
|
55
|
-
ct.columns['two_letter'].declared_data_type.should
|
55
|
+
ct.columns['two_letter'].declared_data_type.should eql("TEXT")
|
56
56
|
ct.columns['name'].should_not be_nullable
|
57
57
|
ct.columns['name'].should be_not_null_constraint
|
58
58
|
ct.columns['name'].should_not be_has_default_value
|
@@ -61,15 +61,15 @@ describe Amalgalite::Schema do
|
|
61
61
|
|
62
62
|
it "loads the indexes" do
|
63
63
|
c = @iso_db.schema.tables['country']
|
64
|
-
c.indexes.size.should
|
65
|
-
c.indexes['country_name'].columns.size.should
|
64
|
+
c.indexes.size.should eql(2)
|
65
|
+
c.indexes['country_name'].columns.size.should eql(1)
|
66
66
|
c.indexes['country_name'].should_not be_unique
|
67
|
-
c.indexes['country_name'].sequence_number.should
|
68
|
-
c.indexes['country_name'].columns.first.should
|
67
|
+
c.indexes['country_name'].sequence_number.should eql(0)
|
68
|
+
c.indexes['country_name'].columns.first.should eql(@iso_db.schema.tables['country'].columns['name'])
|
69
69
|
c.indexes['sqlite_autoindex_country_1'].should be_unique
|
70
70
|
|
71
71
|
subc = @iso_db.schema.tables['subcountry']
|
72
|
-
subc.indexes.size.should
|
73
|
-
subc.indexes['subcountry_country'].columns.first.should
|
72
|
+
subc.indexes.size.should eql(3)
|
73
|
+
subc.indexes['subcountry_country'].columns.first.should eql(@iso_db.schema.tables['subcountry'].columns['country'])
|
74
74
|
end
|
75
75
|
end
|
data/spec/sqlite3/status_spec.rb
CHANGED
@@ -13,6 +13,6 @@ describe "Amalgalite::SQLite3::Status" do
|
|
13
13
|
Amalgalite::SQLite3.status.memory_used.reset!
|
14
14
|
Amalgalite::SQLite3.status.memory_used.highwater.should > 0
|
15
15
|
after = Amalgalite::SQLite3.status.memory_used.highwater
|
16
|
-
after.should_not
|
16
|
+
after.should_not eql(before)
|
17
17
|
end
|
18
18
|
end
|
@@ -5,10 +5,10 @@ describe "Amalgalite::SQLite3::Version" do
|
|
5
5
|
it "should have the sqlite3 version" do
|
6
6
|
Amalgalite::SQLite3::VERSION.should =~ /\d\.\d\.\d/
|
7
7
|
Amalgalite::SQLite3::Version.to_s.should =~ /\d\.\d\.\d/
|
8
|
-
Amalgalite::SQLite3::Version.to_i.should
|
9
|
-
Amalgalite::SQLite3::Version::MAJOR.should
|
10
|
-
Amalgalite::SQLite3::Version::MINOR.should
|
11
|
-
Amalgalite::SQLite3::Version::RELEASE.should
|
8
|
+
Amalgalite::SQLite3::Version.to_i.should eql(3006010)
|
9
|
+
Amalgalite::SQLite3::Version::MAJOR.should eql(3)
|
10
|
+
Amalgalite::SQLite3::Version::MINOR.should eql(6)
|
11
|
+
Amalgalite::SQLite3::Version::RELEASE.should eql(10)
|
12
12
|
Amalgalite::SQLite3::Version.to_a.should have(3).items
|
13
13
|
end
|
14
14
|
end
|
data/spec/sqlite3_spec.rb
CHANGED
@@ -4,50 +4,50 @@ require 'rbconfig'
|
|
4
4
|
|
5
5
|
describe "Amalgalite::SQLite3" do
|
6
6
|
it "is threadsafe is ruby is compiled with pthread support, in this case that is (#{Config::CONFIG['configure_args'].include?( "--enable-pthread" )})" do
|
7
|
-
Amalgalite::SQLite3.threadsafe?.should
|
7
|
+
Amalgalite::SQLite3.threadsafe?.should eql(Config::CONFIG['configure_args'].include?( "--enable-pthread" ))
|
8
8
|
end
|
9
9
|
|
10
10
|
it "knows if an SQL statement is complete" do
|
11
|
-
Amalgalite::SQLite3.complete?("SELECT * FROM sometable;").should
|
12
|
-
Amalgalite::SQLite3.complete?("SELECT * FROM sometable;", :utf16 => true).should
|
11
|
+
Amalgalite::SQLite3.complete?("SELECT * FROM sometable;").should eql(true)
|
12
|
+
Amalgalite::SQLite3.complete?("SELECT * FROM sometable;", :utf16 => true).should eql(true)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "knows if an SQL statement is not complete" do
|
16
|
-
Amalgalite::SQLite3.complete?("SELECT * FROM sometable ").should
|
17
|
-
Amalgalite::SQLite3.complete?("SELECT * FROM sometable WHERE ", :utf16 => true).should
|
16
|
+
Amalgalite::SQLite3.complete?("SELECT * FROM sometable ").should eql(false)
|
17
|
+
Amalgalite::SQLite3.complete?("SELECT * FROM sometable WHERE ", :utf16 => true).should eql(false)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "can produce random data" do
|
21
|
-
Amalgalite::SQLite3.randomness( 42 ).size.should
|
21
|
+
Amalgalite::SQLite3.randomness( 42 ).size.should eql(42)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "has nil for the default sqlite temporary directory" do
|
25
|
-
Amalgalite::SQLite3.temp_directory.should
|
25
|
+
Amalgalite::SQLite3.temp_directory.should eql(nil)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "can set the temporary directory" do
|
29
|
-
Amalgalite::SQLite3.temp_directory.should
|
29
|
+
Amalgalite::SQLite3.temp_directory.should eql(nil)
|
30
30
|
Amalgalite::SQLite3.temp_directory = "/tmp/testing"
|
31
|
-
Amalgalite::SQLite3.temp_directory.should
|
31
|
+
Amalgalite::SQLite3.temp_directory.should eql("/tmp/testing")
|
32
32
|
Amalgalite::SQLite3.temp_directory = nil
|
33
|
-
Amalgalite::SQLite3.temp_directory.should
|
33
|
+
Amalgalite::SQLite3.temp_directory.should eql(nil)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "can escape quoted strings" do
|
37
|
-
Amalgalite::SQLite3.escape( "It's a happy day!" ).should
|
37
|
+
Amalgalite::SQLite3.escape( "It's a happy day!" ).should eql("It''s a happy day!")
|
38
38
|
end
|
39
39
|
|
40
40
|
it "can escape a symble into a string" do
|
41
|
-
Amalgalite::SQLite3.escape( :stuff ).should
|
42
|
-
Amalgalite::SQLite3.escape( :"stuff'n" ).should
|
41
|
+
Amalgalite::SQLite3.escape( :stuff ).should eql("stuff")
|
42
|
+
Amalgalite::SQLite3.escape( :"stuff'n" ).should eql("stuff''n")
|
43
43
|
end
|
44
44
|
|
45
45
|
it "can quote and escape single quoted strings" do
|
46
|
-
Amalgalite::SQLite3.quote( "It's a happy day!" ).should
|
46
|
+
Amalgalite::SQLite3.quote( "It's a happy day!" ).should eql("'It''s a happy day!'")
|
47
47
|
end
|
48
48
|
|
49
49
|
it "can quote and escape symbols" do
|
50
|
-
Amalgalite::SQLite3.quote( :stuff ).should
|
51
|
-
Amalgalite::SQLite3.quote( :"stuff'n" ).should
|
50
|
+
Amalgalite::SQLite3.quote( :stuff ).should eql("'stuff'")
|
51
|
+
Amalgalite::SQLite3.quote( :"stuff'n" ).should eql("'stuff''n'")
|
52
52
|
end
|
53
53
|
end
|
data/spec/statement_spec.rb
CHANGED
@@ -22,16 +22,16 @@ describe Amalgalite::Statement do
|
|
22
22
|
|
23
23
|
it "a statement has a copy of the sql it was prepared with" do
|
24
24
|
stmt = @db.prepare( "SELECT strftime('%Y-%m-%d %H:%M:%S', 'now')")
|
25
|
-
stmt.sql.should
|
25
|
+
stmt.sql.should eql("SELECT strftime('%Y-%m-%d %H:%M:%S', 'now')")
|
26
26
|
stmt.close
|
27
27
|
end
|
28
28
|
|
29
29
|
it "steps through results" do
|
30
30
|
now = Time.new.utc.strftime("%Y-%m-%d %H:%M")
|
31
31
|
@db.prepare( "SELECT strftime('%Y-%m-%d %H:%M', 'now') as now") do |stmt|
|
32
|
-
stmt.should_not
|
32
|
+
stmt.should_not eql(nil)
|
33
33
|
stmt.each do |row|
|
34
|
-
row['now'].should
|
34
|
+
row['now'].should eql(now)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -39,13 +39,13 @@ describe Amalgalite::Statement do
|
|
39
39
|
it "can prepare a statement without a block" do
|
40
40
|
stmt = @iso_db.prepare("SELECT * FROM country WHERE two_letter = :two")
|
41
41
|
rs = stmt.execute( ":two" => "JP" )
|
42
|
-
rs.size.should
|
42
|
+
rs.size.should eql(1)
|
43
43
|
stmt.close
|
44
44
|
end
|
45
45
|
|
46
46
|
it "knows how many parameters are in the statement" do
|
47
47
|
@iso_db.prepare("SELECT * FROM country WHERE two_letter = :two") do |stmt|
|
48
|
-
stmt.check_parameter_count!( 1 ).should
|
48
|
+
stmt.check_parameter_count!( 1 ).should eql(1)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -59,8 +59,8 @@ describe Amalgalite::Statement do
|
|
59
59
|
it "can run a query with a named parameter" do
|
60
60
|
@iso_db.prepare("SELECT * FROM country WHERE two_letter = :two") do |stmt|
|
61
61
|
all_rows = stmt.execute( ":two" => "JP" )
|
62
|
-
all_rows.size.should
|
63
|
-
all_rows.first['name'].should
|
62
|
+
all_rows.size.should eql(1)
|
63
|
+
all_rows.first['name'].should eql("Japan")
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -70,9 +70,9 @@ describe Amalgalite::Statement do
|
|
70
70
|
stmt.execute( "@id" => 891 ) do |row|
|
71
71
|
rows << row
|
72
72
|
end
|
73
|
-
rows.size.should
|
74
|
-
rows.last['name'].should
|
75
|
-
rows.first['two_letter'].should
|
73
|
+
rows.size.should eql(2)
|
74
|
+
rows.last['name'].should eql("Yugoslavia")
|
75
|
+
rows.first['two_letter'].should eql("CS")
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -89,17 +89,17 @@ describe Amalgalite::Statement do
|
|
89
89
|
c = 0
|
90
90
|
@db.execute("SELECT * from t") do |row|
|
91
91
|
c += 1
|
92
|
-
values[ row['x'] ].should
|
92
|
+
values[ row['x'] ].should eql(row['y'])
|
93
93
|
end
|
94
|
-
c.should
|
94
|
+
c.should eql(20)
|
95
95
|
end
|
96
96
|
|
97
97
|
it "binds a integer variable correctly" do
|
98
98
|
@iso_db.prepare("SELECT * FROM country WHERE id = ? ORDER BY name ") do |stmt|
|
99
99
|
all_rows = stmt.execute( 891 )
|
100
|
-
all_rows.size.should
|
101
|
-
all_rows.last['name'].should
|
102
|
-
all_rows.first['two_letter'].should
|
100
|
+
all_rows.size.should eql(2)
|
101
|
+
all_rows.last['name'].should eql("Yugoslavia")
|
102
|
+
all_rows.first['two_letter'].should eql("CS")
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -128,10 +128,10 @@ describe Amalgalite::Statement do
|
|
128
128
|
db.execute( "create table t1(c1,c2,c3)" )
|
129
129
|
db.execute("insert into t1(c1,c2,c3) values (1,2,'abc')")
|
130
130
|
rows = db.execute( "select rowid,* from t1")
|
131
|
-
rows.size.should
|
132
|
-
rows.first['rowid'].should
|
133
|
-
rows.first['c1'].should
|
134
|
-
rows.first['c3'].should
|
131
|
+
rows.size.should eql(1)
|
132
|
+
rows.first['rowid'].should eql(1)
|
133
|
+
rows.first['c1'].should eql(1 )
|
134
|
+
rows.first['c3'].should eql('abc')
|
135
135
|
end
|
136
136
|
|
137
137
|
it "shows that the rowid column is rowid column" do
|
@@ -152,9 +152,9 @@ describe Amalgalite::Statement do
|
|
152
152
|
it "has index based access to the result set" do
|
153
153
|
@iso_db.prepare("SELECT * FROM country WHERE id = ? ORDER BY name ") do |stmt|
|
154
154
|
all_rows = stmt.execute( 891 )
|
155
|
-
all_rows.size.should
|
156
|
-
all_rows.last.first.should
|
157
|
-
all_rows.first[1].should
|
155
|
+
all_rows.size.should eql(2)
|
156
|
+
all_rows.last.first.should eql("Yugoslavia")
|
157
|
+
all_rows.first[1].should eql("CS")
|
158
158
|
end
|
159
159
|
end
|
160
160
|
end
|
data/spec/tap_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe Amalgalite::TraceTap do
|
|
13
13
|
s = StringIO.new
|
14
14
|
tt = ::Amalgalite::TraceTap.new( s, 'puts' )
|
15
15
|
tt.trace('test trace')
|
16
|
-
s.string.should
|
16
|
+
s.string.should eql("test trace\n")
|
17
17
|
end
|
18
18
|
|
19
19
|
it "raises an error if an the wrapped object does not respond to the indicated method" do
|
@@ -51,9 +51,9 @@ describe Amalgalite::ProfileSampler do
|
|
51
51
|
s.sample( 84 )
|
52
52
|
s.sample( 21 )
|
53
53
|
h = s.to_h
|
54
|
-
h['min'].should
|
55
|
-
h['max'].should
|
56
|
-
h['mean'].should
|
57
|
-
h['n'].should
|
54
|
+
h['min'].should eql(21)
|
55
|
+
h['max'].should eql(84)
|
56
|
+
h['mean'].should eql(49.0)
|
57
|
+
h['n'].should eql(3)
|
58
58
|
end
|
59
59
|
end
|
data/tasks/config.rb
CHANGED
@@ -38,8 +38,6 @@ Configuration.for('packaging') {
|
|
38
38
|
all bin + ext + examples + lib + test + data + rdoc + tasks
|
39
39
|
}
|
40
40
|
|
41
|
-
puts "ext files = #{files.ext}"
|
42
|
-
|
43
41
|
# ways to package the results
|
44
42
|
formats {
|
45
43
|
tgz true
|
@@ -64,7 +62,7 @@ Configuration.for('test') {
|
|
64
62
|
mode "spec"
|
65
63
|
files Configuration.for("packaging").files.test
|
66
64
|
options %w[ --format progress --color ]
|
67
|
-
ruby_opts %w[ ]
|
65
|
+
ruby_opts %w[ -w ]
|
68
66
|
}
|
69
67
|
|
70
68
|
#-----------------------------------------------------------------------
|
@@ -74,7 +72,7 @@ Configuration.for('rcov') {
|
|
74
72
|
output_dir "coverage"
|
75
73
|
libs %w[ lib ]
|
76
74
|
rcov_opts %w[ --html ]
|
77
|
-
ruby_opts %w[ ]
|
75
|
+
ruby_opts %w[ -w ]
|
78
76
|
test_files Configuration.for('packaging').files.test
|
79
77
|
}
|
80
78
|
#
|
data/tasks/rspec.rake
CHANGED
@@ -11,13 +11,14 @@ if spec_config = Configuration.for_if_exist?("test") then
|
|
11
11
|
task :default => :spec
|
12
12
|
|
13
13
|
require 'spec/rake/spectask'
|
14
|
-
Spec::Rake::SpecTask.new do |r|
|
15
|
-
r.ruby_opts = spec_config.ruby_opts
|
14
|
+
rs = Spec::Rake::SpecTask.new do |r|
|
15
|
+
r.ruby_opts = spec_config.ruby_opts
|
16
16
|
r.libs = [ Amalgalite::Paths.lib_path,
|
17
17
|
Amalgalite::Paths.ext_path,
|
18
18
|
Amalgalite::Paths.root_dir ]
|
19
19
|
r.spec_files = spec_config.files
|
20
20
|
r.spec_opts = spec_config.options
|
21
|
+
r.warning = true
|
21
22
|
|
22
23
|
if rcov_config = Configuration.for_if_exist?('rcov') then
|
23
24
|
r.rcov = true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amalgalite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Hinegardner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-12 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|