baza 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +157 -0
- data/Gemfile +11 -9
- data/Gemfile.lock +41 -9
- data/README.md +1 -1
- data/Rakefile +19 -16
- data/VERSION +1 -1
- data/baza.gemspec +31 -7
- data/config/best_project_practice_rubocop.yml +2 -0
- data/config/best_project_practice_rubocop_todo.yml +157 -0
- data/lib/baza/base_sql_driver.rb +79 -20
- data/lib/baza/cloner.rb +2 -2
- data/lib/baza/column.rb +6 -0
- data/lib/baza/database.rb +33 -0
- data/lib/baza/database_model.rb +26 -0
- data/lib/baza/database_model_functionality.rb +10 -0
- data/lib/baza/database_model_name.rb +16 -0
- data/lib/baza/db.rb +210 -413
- data/lib/baza/dbtime.rb +20 -20
- data/lib/baza/driver.rb +3 -3
- data/lib/baza/drivers/active_record/columns.rb +1 -1
- data/lib/baza/drivers/active_record/indexes.rb +1 -1
- data/lib/baza/drivers/active_record/result.rb +3 -5
- data/lib/baza/drivers/active_record/tables.rb +2 -2
- data/lib/baza/drivers/active_record.rb +30 -16
- data/lib/baza/drivers/mysql/column.rb +51 -48
- data/lib/baza/drivers/mysql/columns.rb +8 -8
- data/lib/baza/drivers/mysql/database.rb +28 -0
- data/lib/baza/drivers/mysql/databases.rb +35 -0
- data/lib/baza/drivers/mysql/index.rb +32 -22
- data/lib/baza/drivers/mysql/result.rb +24 -24
- data/lib/baza/drivers/mysql/sqlspecs.rb +1 -1
- data/lib/baza/drivers/mysql/table.rb +80 -91
- data/lib/baza/drivers/mysql/tables.rb +30 -32
- data/lib/baza/drivers/mysql/unbuffered_result.rb +5 -5
- data/lib/baza/drivers/mysql.rb +127 -220
- data/lib/baza/drivers/mysql2/database.rb +2 -0
- data/lib/baza/drivers/mysql2/databases.rb +2 -0
- data/lib/baza/drivers/mysql2/result.rb +3 -5
- data/lib/baza/drivers/mysql2.rb +21 -106
- data/lib/baza/drivers/mysql_java/database.rb +2 -0
- data/lib/baza/drivers/mysql_java/databases.rb +2 -0
- data/lib/baza/drivers/mysql_java.rb +16 -12
- data/lib/baza/drivers/sqlite3/column.rb +33 -33
- data/lib/baza/drivers/sqlite3/columns.rb +6 -6
- data/lib/baza/drivers/sqlite3/database.rb +2 -0
- data/lib/baza/drivers/sqlite3/databases.rb +25 -0
- data/lib/baza/drivers/sqlite3/index.rb +20 -6
- data/lib/baza/drivers/sqlite3/result.rb +16 -17
- data/lib/baza/drivers/sqlite3/sqlspecs.rb +1 -1
- data/lib/baza/drivers/sqlite3/table.rb +99 -100
- data/lib/baza/drivers/sqlite3/tables.rb +30 -23
- data/lib/baza/drivers/sqlite3/unbuffered_result.rb +2 -2
- data/lib/baza/drivers/sqlite3.rb +27 -14
- data/lib/baza/drivers/sqlite3_java/database.rb +2 -0
- data/lib/baza/drivers/sqlite3_java/unbuffered_result.rb +2 -2
- data/lib/baza/drivers/sqlite3_java.rb +12 -10
- data/lib/baza/drivers/sqlite3_rhodes.rb +9 -7
- data/lib/baza/dump.rb +55 -55
- data/lib/baza/errors.rb +5 -0
- data/lib/baza/idquery.rb +25 -25
- data/lib/baza/index.rb +6 -0
- data/lib/baza/jdbc_driver.rb +6 -8
- data/lib/baza/jdbc_result.rb +1 -1
- data/lib/baza/model.rb +299 -309
- data/lib/baza/model_custom.rb +74 -72
- data/lib/baza/model_handler.rb +244 -255
- data/lib/baza/model_handler_sqlhelper.rb +122 -132
- data/lib/baza/mysql_base_driver.rb +112 -0
- data/lib/baza/query_buffer.rb +23 -23
- data/lib/baza/result_base.rb +2 -2
- data/lib/baza/revision.rb +67 -67
- data/lib/baza/row.rb +82 -84
- data/lib/baza/sqlspecs.rb +1 -1
- data/lib/baza/table.rb +31 -0
- data/lib/baza.rb +43 -10
- data/shippable.yml +1 -0
- data/spec/cloner_spec.rb +4 -4
- data/spec/drivers/active_record_mysql2_spec.rb +3 -3
- data/spec/drivers/active_record_mysql_spec.rb +2 -2
- data/spec/drivers/active_record_sqlite3_spec.rb +2 -2
- data/spec/drivers/mysql2_spec.rb +1 -0
- data/spec/drivers/mysql_spec.rb +1 -0
- data/spec/drivers/sqlite3_spec.rb +4 -5
- data/spec/info_active_record_example.rb +4 -6
- data/spec/info_active_record_mysql.rb +6 -7
- data/spec/info_active_record_mysql2.rb +2 -4
- data/spec/info_active_record_mysql2_shippable.rb +2 -4
- data/spec/info_active_record_mysql_shippable.rb +2 -4
- data/spec/info_active_record_sqlite3.rb +5 -6
- data/spec/info_mysql2_example.rb +1 -1
- data/spec/info_mysql2_shippable.rb +1 -1
- data/spec/info_mysql_example.rb +1 -1
- data/spec/info_mysql_shippable.rb +1 -1
- data/spec/info_sqlite3.rb +4 -3
- data/spec/model_handler_spec.rb +102 -115
- data/spec/spec_helper.rb +5 -5
- data/spec/support/driver_collection.rb +98 -95
- data/spec/support/driver_columns_collection.rb +18 -22
- data/spec/support/driver_databases_collection.rb +29 -0
- data/spec/support/driver_indexes_collection.rb +7 -6
- data/spec/support/driver_tables_collection.rb +38 -26
- metadata +49 -3
data/spec/info_sqlite3.rb
CHANGED
@@ -6,18 +6,19 @@ class Baza::InfoSqlite3
|
|
6
6
|
require "tmpdir"
|
7
7
|
|
8
8
|
@path = "#{Dir.tmpdir}/baza_sqlite3_test_#{Time.now.to_f.to_s.hash}_#{Random.rand}.sqlite3"
|
9
|
-
File.unlink(path) if File.
|
9
|
+
File.unlink(path) if File.exist?(@path)
|
10
10
|
|
11
11
|
@db = Baza::Db.new({
|
12
12
|
type: :sqlite3,
|
13
13
|
path: @path,
|
14
14
|
index_append_table_name: true,
|
15
|
-
sql_to_error: true
|
15
|
+
sql_to_error: true,
|
16
|
+
debug: false
|
16
17
|
}.merge(args))
|
17
18
|
end
|
18
19
|
|
19
20
|
def before
|
20
|
-
@db.tables.list
|
21
|
+
@db.tables.list do |table|
|
21
22
|
table.drop
|
22
23
|
end
|
23
24
|
end
|
data/spec/model_handler_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe "Objects" do
|
|
6
6
|
require "sqlite3" unless RUBY_ENGINE == "jruby"
|
7
7
|
require "tmpdir"
|
8
8
|
|
9
|
-
File.unlink(db_path) if File.
|
9
|
+
File.unlink(db_path) if File.exist?(db_path)
|
10
10
|
db = Baza::Db.new(type: :sqlite3, path: db_path, debug: false)
|
11
11
|
|
12
12
|
schema = {
|
@@ -79,8 +79,8 @@ describe "Objects" do
|
|
79
79
|
ob
|
80
80
|
end
|
81
81
|
|
82
|
-
let(:task) { ob.add(:Task, name:
|
83
|
-
let(:person) { ob.add(:Person, name:
|
82
|
+
let(:task) { ob.add(:Task, name: "Test task", person_id: person.id) }
|
83
|
+
let(:person) { ob.add(:Person, name: "Kasper") }
|
84
84
|
let(:project) { ob.add(:Project) }
|
85
85
|
|
86
86
|
before(:all) do
|
@@ -107,7 +107,7 @@ describe "Objects" do
|
|
107
107
|
]
|
108
108
|
|
109
109
|
def html
|
110
|
-
|
110
|
+
self[:name]
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -118,7 +118,7 @@ describe "Objects" do
|
|
118
118
|
expect(ob.ids_cache[:User].length).to eq 5
|
119
119
|
|
120
120
|
user = ob.get(:User, 4)
|
121
|
-
raise "No user returned."
|
121
|
+
raise "No user returned." unless user
|
122
122
|
ob.delete(user)
|
123
123
|
|
124
124
|
expect(ob.ids_cache[:User].length).to eq 4
|
@@ -141,26 +141,34 @@ describe "Objects" do
|
|
141
141
|
ob.adds(:User, userd)
|
142
142
|
users = ob.list(:User).to_a
|
143
143
|
|
144
|
-
#Stress it to test threadsafety...
|
144
|
+
# Stress it to test threadsafety...
|
145
145
|
threads = []
|
146
146
|
0.upto(5) do |tc|
|
147
147
|
threads << Thread.new do
|
148
148
|
0.upto(5) do |ic|
|
149
|
-
user = ob.add(:User,
|
150
|
-
raise "No user returned."
|
149
|
+
user = ob.add(:User, username: "User #{tc}-#{ic}")
|
150
|
+
raise "No user returned." unless user
|
151
151
|
ob.delete(user)
|
152
152
|
|
153
|
-
user1 = ob.add(:User,
|
154
|
-
user2 = ob.add(:User,
|
155
|
-
user3 = ob.add(:User,
|
153
|
+
user1 = ob.add(:User, username: "User #{tc}-#{ic}-1")
|
154
|
+
user2 = ob.add(:User, username: "User #{tc}-#{ic}-2")
|
155
|
+
user3 = ob.add(:User, username: "User #{tc}-#{ic}-3")
|
156
|
+
|
157
|
+
expect(user1).to_not eq nil
|
158
|
+
expect(user1.deleted?).to eq false
|
159
|
+
|
160
|
+
expect(user2).to_not eq nil
|
161
|
+
expect(user2.deleted?).to eq false
|
162
|
+
|
163
|
+
expect(user3).to_not eq nil
|
164
|
+
expect(user3.deleted?).to eq false
|
156
165
|
|
157
|
-
raise "Missing user?" if !user1 or !user2 or !user3 or user1.deleted? or user2.deleted? or user3.deleted?
|
158
166
|
ob.deletes([user1, user2, user3])
|
159
167
|
|
160
168
|
count = 0
|
161
|
-
users.each do |
|
169
|
+
users.each do |user_i|
|
162
170
|
count += 1
|
163
|
-
|
171
|
+
user_i[:username] = "#{user_i[:username]}." unless user_i.deleted?
|
164
172
|
end
|
165
173
|
|
166
174
|
expect(count).to eq 21
|
@@ -175,9 +183,9 @@ describe "Objects" do
|
|
175
183
|
class Group < Baza::Model; end
|
176
184
|
|
177
185
|
ob2 = Baza::ModelHandler.new(
|
178
|
-
:
|
179
|
-
:
|
180
|
-
:
|
186
|
+
db: db,
|
187
|
+
datarow: true,
|
188
|
+
require: false
|
181
189
|
)
|
182
190
|
|
183
191
|
threads = []
|
@@ -186,82 +194,82 @@ describe "Objects" do
|
|
186
194
|
Thread.current.abort_on_exception = true
|
187
195
|
|
188
196
|
0.upto(5) do
|
189
|
-
ret = ob2.add(:Group, {groupname: "User 1"},
|
197
|
+
ret = ob2.add(:Group, {groupname: "User 1"}, skip_ret: true)
|
190
198
|
raise "Expected empty return but got something: #{ret}" if ret
|
191
199
|
end
|
192
200
|
end
|
193
201
|
end
|
194
202
|
|
195
|
-
threads.each
|
196
|
-
thread.join
|
197
|
-
end
|
203
|
+
threads.each(&:join)
|
198
204
|
end
|
199
205
|
|
200
206
|
it "should delete the temporary database." do
|
201
|
-
File.unlink(db_path) if File.
|
207
|
+
File.unlink(db_path) if File.exist?(db_path)
|
202
208
|
end
|
203
209
|
|
204
|
-
#Moved from "knjrbfw_spec.rb"
|
210
|
+
# Moved from "knjrbfw_spec.rb"
|
205
211
|
it "should be able to generate a sample SQLite database and add a sample table, with sample columns and with a sample index to it" do
|
206
|
-
require
|
212
|
+
require "tmpdir"
|
207
213
|
|
208
214
|
db_path = "#{Dir.tmpdir}/knjrbfw_test_sqlite3.sqlite3"
|
209
215
|
db = Baza::Db.new(
|
210
|
-
:
|
211
|
-
:
|
212
|
-
:
|
216
|
+
type: :sqlite3,
|
217
|
+
path: db_path,
|
218
|
+
index_append_table_name: true
|
213
219
|
)
|
214
220
|
|
215
|
-
db.tables.create(
|
216
|
-
|
217
|
-
|
218
|
-
{:
|
219
|
-
{:
|
221
|
+
db.tables.create(
|
222
|
+
"Project",
|
223
|
+
columns: [
|
224
|
+
{name: :id, type: :int, autoincr: true, primarykey: true},
|
225
|
+
{name: :category_id, type: :int},
|
226
|
+
{name: :name, type: :varchar}
|
220
227
|
],
|
221
|
-
:
|
222
|
-
{:
|
228
|
+
indexes: [
|
229
|
+
{name: :category_id, columns: [:category_id]}
|
223
230
|
]
|
224
|
-
|
225
|
-
|
226
|
-
db.tables.create(
|
227
|
-
|
228
|
-
|
229
|
-
{:
|
230
|
-
{:
|
231
|
-
{:
|
231
|
+
)
|
232
|
+
|
233
|
+
db.tables.create(
|
234
|
+
"Task",
|
235
|
+
columns: [
|
236
|
+
{name: :id, type: :int, autoincr: true, primarykey: true},
|
237
|
+
{name: :project_id, type: :int},
|
238
|
+
{name: :person_id, type: :int},
|
239
|
+
{name: :name, type: :varchar}
|
232
240
|
],
|
233
|
-
:
|
234
|
-
{:
|
241
|
+
indexes: [
|
242
|
+
{name: :project_id, columns: [:project_id]}
|
235
243
|
]
|
236
|
-
|
244
|
+
)
|
237
245
|
|
238
|
-
db.tables.create(
|
239
|
-
|
240
|
-
|
241
|
-
{:
|
246
|
+
db.tables.create(
|
247
|
+
"Person",
|
248
|
+
columns: [
|
249
|
+
{name: :id, type: :int, autoincr: true, primarykey: true},
|
250
|
+
{name: :name, type: :varchar}
|
242
251
|
]
|
243
|
-
|
252
|
+
)
|
244
253
|
|
245
|
-
db.tables.create(
|
246
|
-
|
247
|
-
|
248
|
-
{:
|
254
|
+
db.tables.create(
|
255
|
+
"Timelog",
|
256
|
+
columns: [
|
257
|
+
{name: :id, type: :int, autoincr: true, primarykey: true},
|
258
|
+
{name: :person_id, type: :int}
|
249
259
|
],
|
250
|
-
:
|
260
|
+
indexes: [
|
251
261
|
:person_id
|
252
262
|
]
|
253
|
-
|
263
|
+
)
|
254
264
|
|
255
265
|
table = db.tables[:Project]
|
256
266
|
|
257
267
|
indexes = table.indexes
|
258
|
-
raise "Could not find the sample-index 'category_id' that should have been created." unless indexes
|
268
|
+
raise "Could not find the sample-index 'category_id' that should have been created." unless indexes.any? { |index| index.name == "Project__category_id" }
|
259
269
|
|
260
270
|
|
261
|
-
#If we insert a row the ID should increase and the name should be the same as inserted (or something is very very wrong)...
|
262
|
-
db.insert("Project",
|
263
|
-
"name" => "Test project"
|
264
|
-
})
|
271
|
+
# If we insert a row the ID should increase and the name should be the same as inserted (or something is very very wrong)...
|
272
|
+
db.insert("Project", name: "Test project")
|
265
273
|
|
266
274
|
count = 0
|
267
275
|
db.q("SELECT * FROM Project") do |d|
|
@@ -274,37 +282,31 @@ describe "Objects" do
|
|
274
282
|
end
|
275
283
|
|
276
284
|
it "should be able to automatic generate methods on datarow-classes (has_many, has_one)." do
|
277
|
-
ob = Baza::ModelHandler.new(:
|
285
|
+
ob = Baza::ModelHandler.new(db: db, datarow: true, require: false)
|
278
286
|
|
279
|
-
ob.add(:Person,
|
280
|
-
|
281
|
-
})
|
282
|
-
ob.add(:Task, {
|
283
|
-
:name => "Test task",
|
284
|
-
:person_id => person.id,
|
285
|
-
:project_id => project.id
|
286
|
-
})
|
287
|
+
ob.add(:Person, name: "Kasper")
|
288
|
+
ob.add(:Task, name: "Test task", person_id: person.id, project_id: project.id)
|
287
289
|
|
288
290
|
begin
|
289
|
-
obb.add(:Task,
|
291
|
+
obb.add(:Task, name: "Test task")
|
290
292
|
raise "Method should fail but didnt."
|
291
293
|
rescue
|
292
|
-
#
|
294
|
+
# Ignore.
|
293
295
|
end
|
294
296
|
|
295
297
|
|
296
|
-
#Test 'list_invalid_required'.
|
297
|
-
db.insert(:Task, :
|
298
|
+
# Test 'list_invalid_required'.
|
299
|
+
db.insert(:Task, name: "Invalid require")
|
298
300
|
id = db.last_id
|
299
301
|
found = false
|
300
302
|
|
301
|
-
ob.list_invalid_required(:
|
303
|
+
ob.list_invalid_required(class: :Task) do |d|
|
302
304
|
raise "Expected object ID to be #{id} but it wasnt: #{d[:obj].id}" if d[:obj].id.to_i != id.to_i
|
303
305
|
ob.delete(d[:obj])
|
304
306
|
found = true
|
305
307
|
end
|
306
308
|
|
307
|
-
raise "Expected to find a task but didnt."
|
309
|
+
raise "Expected to find a task but didnt." unless found
|
308
310
|
|
309
311
|
|
310
312
|
ret_proc = []
|
@@ -324,22 +326,22 @@ describe "Objects" do
|
|
324
326
|
ret_proc << task
|
325
327
|
end
|
326
328
|
|
327
|
-
raise "When given a block the return should be nil so it doesnt hold weak-ref-objects in memory but it didnt return nil."
|
329
|
+
raise "When given a block the return should be nil so it doesnt hold weak-ref-objects in memory but it didnt return nil." unless ret_test == nil
|
328
330
|
raise "list for project with proc should return one task but didnt (#{ret_proc.length})." if ret_proc.length != 1
|
329
331
|
|
330
332
|
person = tasks.first.person
|
331
333
|
project_second = tasks.first.project
|
332
334
|
|
333
|
-
raise "Returned object was not a person on task."
|
334
|
-
raise "Returned object was not a project on task."
|
335
|
+
raise "Returned object was not a person on task." unless person.is_a?(Person)
|
336
|
+
raise "Returned object was not a project on task." unless project_second.is_a?(Project)
|
335
337
|
|
336
338
|
|
337
|
-
#Check that has_many-depending is actually working.
|
339
|
+
# Check that has_many-depending is actually working.
|
338
340
|
begin
|
339
341
|
ob.delete(project)
|
340
342
|
raise "It was possible to delete project 1 even though task 1 depended on it!"
|
341
343
|
rescue
|
342
|
-
#
|
344
|
+
# This should happen - it should not possible to delete project 1 because task 1 depends on it."
|
343
345
|
end
|
344
346
|
end
|
345
347
|
|
@@ -347,24 +349,24 @@ describe "Objects" do
|
|
347
349
|
task
|
348
350
|
list = ob.list_optshash(:Task)
|
349
351
|
list.length.should eq 1
|
350
|
-
list[1].should eq
|
352
|
+
list[1].should eq "Test task"
|
351
353
|
end
|
352
354
|
|
353
355
|
it "should be able to connect to objects 'no-html' callback and test it." do
|
354
356
|
task
|
355
|
-
ob.events.connect(:no_html) do |
|
357
|
+
ob.events.connect(:no_html) do |_event, classname|
|
356
358
|
"[no #{classname.to_s.downcase}]"
|
357
359
|
end
|
358
360
|
|
359
361
|
expect(task.person_html).to eq "Kasper"
|
360
|
-
task.update(:
|
362
|
+
task.update(person_id: 0)
|
361
363
|
expect(task.person_html).to eq "[no person]"
|
362
364
|
end
|
363
365
|
|
364
366
|
it "should be able to to multiple additions and delete objects through a buffer" do
|
365
367
|
objs = []
|
366
368
|
0.upto(500) do
|
367
|
-
objs << {:
|
369
|
+
objs << {name: :Kasper}
|
368
370
|
end
|
369
371
|
|
370
372
|
ob.adds(:Person, objs)
|
@@ -374,7 +376,7 @@ describe "Objects" do
|
|
374
376
|
db.q_buffer do |buffer|
|
375
377
|
ob.list(:Person) do |person|
|
376
378
|
count += 1
|
377
|
-
ob.delete(person, :
|
379
|
+
ob.delete(person, db_buffer: buffer)
|
378
380
|
end
|
379
381
|
|
380
382
|
buffer.flush
|
@@ -383,23 +385,15 @@ describe "Objects" do
|
|
383
385
|
raise "Expected count to be #{pers_length} but it wasnt: #{count}" if count != pers_length
|
384
386
|
|
385
387
|
persons = ob.list(:Person).to_a
|
386
|
-
raise "Expected persons count to be 0 but it wasnt: #{persons.map
|
388
|
+
raise "Expected persons count to be 0 but it wasnt: #{persons.map(&:data)}" if persons.length > 0
|
387
389
|
end
|
388
390
|
|
389
391
|
it "should do autozero when deleting objects" do
|
390
|
-
person1 = ob.add(:Person,
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
})
|
396
|
-
|
397
|
-
timelog1 = ob.add(:Timelog, {
|
398
|
-
:person_id => person1.id
|
399
|
-
})
|
400
|
-
timelog2 = ob.add(:Timelog, {
|
401
|
-
:person_id => person2.id
|
402
|
-
})
|
392
|
+
person1 = ob.add(:Person, name: "Kasper")
|
393
|
+
person2 = ob.add(:Person, name: "Charlotte")
|
394
|
+
|
395
|
+
timelog1 = ob.add(:Timelog, person_id: person1.id)
|
396
|
+
timelog2 = ob.add(:Timelog, person_id: person2.id)
|
403
397
|
|
404
398
|
ob.delete(person1)
|
405
399
|
|
@@ -409,36 +403,29 @@ describe "Objects" do
|
|
409
403
|
|
410
404
|
it "should be able to do multiple deletes from ids" do
|
411
405
|
ids = []
|
412
|
-
1.upto(10) do |
|
406
|
+
1.upto(10) do |_count|
|
413
407
|
ids << ob.add(:Person).id
|
414
408
|
end
|
415
409
|
|
416
|
-
ob.delete_ids(:
|
410
|
+
ob.delete_ids(class: :Person, ids: ids)
|
417
411
|
end
|
418
412
|
|
419
413
|
it "get_or_add" do
|
420
|
-
person1 = ob.add(:Person,
|
421
|
-
|
422
|
-
})
|
423
|
-
|
424
|
-
person2 = ob.get_or_add(:Person, {
|
425
|
-
:name => "get_or_add"
|
426
|
-
})
|
414
|
+
person1 = ob.add(:Person, name: "get_or_add")
|
415
|
+
person2 = ob.get_or_add(:Person, name: "get_or_add")
|
427
416
|
|
428
417
|
person2.id.should eql(person1.id)
|
429
418
|
person2[:name].should eql("get_or_add")
|
430
419
|
|
431
|
-
person3 = ob.get_or_add(:Person,
|
432
|
-
:name => "get_or_add3"
|
433
|
-
})
|
420
|
+
person3 = ob.get_or_add(:Person, name: "get_or_add3")
|
434
421
|
|
435
422
|
raise "Failure ID was the same" if person3.id == person2.id
|
436
423
|
person3[:name].should eql("get_or_add3")
|
437
424
|
end
|
438
425
|
|
439
426
|
it "should delete the temp database again." do
|
440
|
-
require
|
427
|
+
require "tmpdir"
|
441
428
|
db_path = "#{Dir.tmpdir}/knjrbfw_test_sqlite3.sqlite3"
|
442
|
-
File.unlink(db_path) if File.
|
429
|
+
File.unlink(db_path) if File.exist?(db_path)
|
443
430
|
end
|
444
|
-
end
|
431
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require "codeclimate-test-reporter"
|
2
2
|
CodeClimate::TestReporter.start
|
3
3
|
|
4
|
-
require
|
4
|
+
require "baza"
|
5
5
|
|
6
|
-
if RUBY_PLATFORM ==
|
7
|
-
require
|
6
|
+
if RUBY_PLATFORM == "java"
|
7
|
+
require "jdbc/mysql"
|
8
8
|
::Jdbc::MySQL.load_driver
|
9
9
|
|
10
|
-
require
|
10
|
+
require "jdbc/sqlite3"
|
11
11
|
::Jdbc::SQLite3.load_driver
|
12
12
|
end
|
13
13
|
|
14
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
14
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
15
15
|
|
16
16
|
RSpec.configure do |config|
|
17
17
|
config.expect_with :rspec do |c|
|