ardb 0.27.3 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +5 -1
- data/ardb.gemspec +3 -4
- data/lib/ardb.rb +135 -68
- data/lib/ardb/adapter/base.rb +39 -24
- data/lib/ardb/adapter/mysql.rb +1 -2
- data/lib/ardb/adapter/postgresql.rb +14 -12
- data/lib/ardb/adapter/sqlite.rb +3 -8
- data/lib/ardb/adapter_spy.rb +67 -87
- data/lib/ardb/cli.rb +11 -219
- data/lib/ardb/{clirb.rb → cli/clirb.rb} +2 -1
- data/lib/ardb/cli/commands.rb +275 -0
- data/lib/ardb/migration.rb +8 -6
- data/lib/ardb/migration_helpers.rb +1 -1
- data/lib/ardb/pg_json.rb +90 -0
- data/lib/ardb/version.rb +1 -1
- data/test/helper.rb +15 -3
- data/test/support/factory.rb +15 -0
- data/test/support/fake_schema.rb +5 -0
- data/test/support/postgresql/migrations/.gitkeep +0 -0
- data/test/support/postgresql/pg_json_migrations/20160519133432_create_pg_json_migrate_test.rb +13 -0
- data/test/support/postgresql/schema.rb +3 -0
- data/test/support/postgresql/setup_test_db.rb +51 -0
- data/test/support/relative_require_test_db_file.rb +2 -0
- data/test/support/require_test_db_file.rb +1 -0
- data/test/system/pg_json_tests.rb +85 -0
- data/test/unit/adapter/base_tests.rb +104 -39
- data/test/unit/adapter/mysql_tests.rb +2 -1
- data/test/unit/adapter/postgresql_tests.rb +10 -9
- data/test/unit/adapter/sqlite_tests.rb +8 -3
- data/test/unit/adapter_spy_tests.rb +57 -66
- data/test/unit/ardb_tests.rb +323 -36
- data/test/unit/cli_tests.rb +193 -146
- data/test/unit/has_slug_tests.rb +9 -9
- data/test/unit/migration_helpers_tests.rb +18 -12
- data/test/unit/migration_tests.rb +18 -11
- data/test/unit/pg_json_tests.rb +39 -0
- data/test/unit/record_spy_tests.rb +1 -1
- data/test/unit/test_helpers_tests.rb +2 -6
- data/test/unit/use_db_default_tests.rb +2 -2
- metadata +29 -34
- data/lib/ardb/root_path.rb +0 -15
- data/test/unit/config_tests.rb +0 -58
data/test/unit/has_slug_tests.rb
CHANGED
@@ -66,7 +66,7 @@ module Ardb::HasSlug
|
|
66
66
|
end
|
67
67
|
|
68
68
|
should "allow customizing the has slug config using `has_slug`" do
|
69
|
-
separator = NON_WORD_CHARS.
|
69
|
+
separator = NON_WORD_CHARS.sample
|
70
70
|
allow_underscore = Factory.boolean
|
71
71
|
subject.has_slug({
|
72
72
|
:attribute => @slug_attribute,
|
@@ -145,8 +145,8 @@ module Ardb::HasSlug
|
|
145
145
|
class InitTests < UnitTests
|
146
146
|
desc "when init"
|
147
147
|
setup do
|
148
|
-
@preprocessor = [:downcase, :upcase, :capitalize].
|
149
|
-
@separator = NON_WORD_CHARS.
|
148
|
+
@preprocessor = [:downcase, :upcase, :capitalize].sample
|
149
|
+
@separator = NON_WORD_CHARS.sample
|
150
150
|
@allow_underscores = Factory.boolean
|
151
151
|
|
152
152
|
@record_class.has_slug(:source => @source_attribute)
|
@@ -272,8 +272,8 @@ module Ardb::HasSlug
|
|
272
272
|
|
273
273
|
should "turn invalid chars into a separator" do
|
274
274
|
string = Factory.integer(3).times.map do
|
275
|
-
"#{Factory.string(3)}#{NON_WORD_CHARS.
|
276
|
-
end.join(NON_WORD_CHARS.
|
275
|
+
"#{Factory.string(3)}#{NON_WORD_CHARS.sample}#{Factory.string(3)}"
|
276
|
+
end.join(NON_WORD_CHARS.sample)
|
277
277
|
assert_equal string.gsub(/[^\w]+/, '-'), subject.new(string, @args)
|
278
278
|
end
|
279
279
|
|
@@ -288,9 +288,9 @@ module Ardb::HasSlug
|
|
288
288
|
end
|
289
289
|
|
290
290
|
should "allow passing a custom separator" do
|
291
|
-
separator = NON_WORD_CHARS.
|
291
|
+
separator = NON_WORD_CHARS.sample
|
292
292
|
|
293
|
-
invalid_char = (NON_WORD_CHARS - [separator]).
|
293
|
+
invalid_char = (NON_WORD_CHARS - [separator]).sample
|
294
294
|
string = "#{Factory.string}#{invalid_char}#{Factory.string}"
|
295
295
|
exp = string.gsub(/[^\w]+/, separator)
|
296
296
|
assert_equal exp, subject.new(string, @args.merge(:separator => separator))
|
@@ -321,7 +321,7 @@ module Ardb::HasSlug
|
|
321
321
|
assert_equal string.gsub(/-{2,}/, '-'), subject.new(string, @args)
|
322
322
|
|
323
323
|
# remove separators that were added from changing invalid chars
|
324
|
-
invalid_chars = (Factory.integer(3) + 1).times.map{ NON_WORD_CHARS.
|
324
|
+
invalid_chars = (Factory.integer(3) + 1).times.map{ NON_WORD_CHARS.sample }.join
|
325
325
|
string = "#{Factory.string}#{invalid_chars}#{Factory.string}"
|
326
326
|
assert_equal string.gsub(/[^\w]+/, '-'), subject.new(string, @args)
|
327
327
|
end
|
@@ -331,7 +331,7 @@ module Ardb::HasSlug
|
|
331
331
|
assert_equal string[1..-2], subject.new(string, @args)
|
332
332
|
|
333
333
|
# remove separators that were added from changing invalid chars
|
334
|
-
invalid_char = NON_WORD_CHARS.
|
334
|
+
invalid_char = NON_WORD_CHARS.sample
|
335
335
|
string = "#{invalid_char}#{Factory.string}-#{Factory.string}#{invalid_char}"
|
336
336
|
assert_equal string[1..-2], subject.new(string, @args)
|
337
337
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'assert'
|
2
2
|
require 'ardb/migration_helpers'
|
3
3
|
|
4
|
+
require 'ardb/adapter_spy'
|
5
|
+
|
4
6
|
module Ardb::MigrationHelpers
|
5
7
|
|
6
8
|
class UnitTests < Assert::Context
|
@@ -14,6 +16,11 @@ module Ardb::MigrationHelpers
|
|
14
16
|
class ForeignKeyTests < UnitTests
|
15
17
|
desc "ForeignKey handler"
|
16
18
|
setup do
|
19
|
+
@adapter_spy = nil
|
20
|
+
Assert.stub(Ardb::Adapter, :new) do |*args|
|
21
|
+
@adapter_spy = Ardb::AdapterSpy.new(*args)
|
22
|
+
end
|
23
|
+
|
17
24
|
@fk = ForeignKey.new('fromtbl', 'fromcol', 'totbl')
|
18
25
|
end
|
19
26
|
subject{ @fk }
|
@@ -37,21 +44,20 @@ module Ardb::MigrationHelpers
|
|
37
44
|
assert_equal exp_name, subject.name
|
38
45
|
end
|
39
46
|
|
40
|
-
should "
|
41
|
-
|
42
|
-
assert_equal
|
47
|
+
should "know its adapter" do
|
48
|
+
assert_not_nil @adapter_spy
|
49
|
+
assert_equal Ardb.config, @adapter_spy.config
|
50
|
+
assert_equal @adapter_spy, subject.adapter
|
43
51
|
end
|
44
52
|
|
45
53
|
should "generate appropriate foreign key sql" do
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
" DROP CONSTRAINT fk_fromtbl_fromcol"
|
54
|
-
assert_equal exp_drop_sql, subject.drop_sql
|
54
|
+
exp = "FAKE ADD FOREIGN KEY SQL fromtbl fromcol " \
|
55
|
+
"totbl id fk_fromtbl_fromcol"
|
56
|
+
assert_equal exp, subject.add_sql
|
57
|
+
|
58
|
+
exp = "FAKE DROP FOREIGN KEY SQL fromtbl fromcol " \
|
59
|
+
"totbl id fk_fromtbl_fromcol"
|
60
|
+
assert_equal exp, subject.drop_sql
|
55
61
|
end
|
56
62
|
|
57
63
|
end
|
@@ -1,5 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'assert'
|
2
|
+
require 'ardb/migration'
|
3
|
+
|
4
|
+
# This is needed to call `classify` on a string; if this isn't manually required
|
5
|
+
# these tests can fail if activesupport hasn't been loaded by activerecord; the
|
6
|
+
# `Migration` class will error saying `classify` is not a method on `String`
|
7
|
+
require 'active_support/core_ext/string/inflections'
|
3
8
|
|
4
9
|
class Ardb::Migration
|
5
10
|
|
@@ -27,16 +32,18 @@ class Ardb::Migration
|
|
27
32
|
block.call(@file_spy)
|
28
33
|
end
|
29
34
|
|
30
|
-
@
|
31
|
-
@
|
35
|
+
@ardb_config = Factory.ardb_config
|
36
|
+
@id = Factory.migration_id
|
37
|
+
@migration = @migration_class.new(@ardb_config, @id)
|
32
38
|
end
|
33
39
|
subject{ @migration }
|
34
40
|
|
35
|
-
should have_readers
|
36
|
-
should have_readers :source
|
41
|
+
should have_readers :migrations_path, :identifier
|
42
|
+
should have_readers :class_name, :file_name, :file_path, :source
|
37
43
|
should have_imeths :save!
|
38
44
|
|
39
45
|
should "know its attrs" do
|
46
|
+
assert_equal @ardb_config.migrations_path, subject.migrations_path
|
40
47
|
assert_equal @id, subject.identifier
|
41
48
|
|
42
49
|
exp = @id.classify.pluralize
|
@@ -45,7 +52,7 @@ class Ardb::Migration
|
|
45
52
|
exp = "#{@time_now.strftime("%Y%m%d%H%M%S")}_#{@id.underscore}"
|
46
53
|
assert_equal exp, subject.file_name
|
47
54
|
|
48
|
-
exp = File.join(
|
55
|
+
exp = File.join(subject.migrations_path, "#{subject.file_name}.rb")
|
49
56
|
assert_equal exp, subject.file_path
|
50
57
|
|
51
58
|
exp = "require 'ardb/migration_helpers'\n\n" \
|
@@ -59,16 +66,16 @@ class Ardb::Migration
|
|
59
66
|
|
60
67
|
should "complain if no identifier is provided" do
|
61
68
|
assert_raises(NoIdentifierError) do
|
62
|
-
@migration_class.new([nil, ''].
|
69
|
+
@migration_class.new(@ardb_config, [nil, ''].sample)
|
63
70
|
end
|
64
71
|
end
|
65
72
|
|
66
73
|
should "write the migration source to the migrations path on save" do
|
67
74
|
subject.save!
|
68
75
|
|
69
|
-
assert_equal [
|
70
|
-
assert_equal [subject.file_path, 'w'],
|
71
|
-
assert_equal [subject.source],
|
76
|
+
assert_equal [subject.migrations_path], @mkdir_called_with
|
77
|
+
assert_equal [subject.file_path, 'w'], @file_open_called_with
|
78
|
+
assert_equal [subject.source], @file_spy.write_called_with
|
72
79
|
end
|
73
80
|
|
74
81
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'ardb/pg_json'
|
3
|
+
|
4
|
+
module Ardb; end
|
5
|
+
module Ardb::PgJson
|
6
|
+
|
7
|
+
class UnitTests < Assert::Context
|
8
|
+
desc "Ardb postgresql json shim"
|
9
|
+
setup do
|
10
|
+
@connection_adapters = ActiveRecord::ConnectionAdapters
|
11
|
+
end
|
12
|
+
subject{ @connection_adapters }
|
13
|
+
|
14
|
+
should "update active record postgres adapter to support json columns" do
|
15
|
+
adapter_class = subject::PostgreSQLAdapter
|
16
|
+
exp = { :name => 'json' }
|
17
|
+
assert_equal exp, adapter_class::NATIVE_DATABASE_TYPES[:json]
|
18
|
+
exp = { :name => 'jsonb' }
|
19
|
+
assert_equal exp, adapter_class::NATIVE_DATABASE_TYPES[:jsonb]
|
20
|
+
end
|
21
|
+
|
22
|
+
should "update active record postgres column to support json columns" do
|
23
|
+
column_class = subject::PostgreSQLColumn
|
24
|
+
default = Factory.boolean ? "'{}'::json" : "'{}'::jsonb"
|
25
|
+
assert_equal '{}', column_class.extract_value_from_default(default)
|
26
|
+
default = Factory.boolean ? "'[]'::json" : "'[]'::jsonb"
|
27
|
+
assert_equal '[]', column_class.extract_value_from_default(default)
|
28
|
+
|
29
|
+
column = column_class.new(Factory.string, Factory.string)
|
30
|
+
assert_equal :json, column.send(:simplified_type, 'json')
|
31
|
+
assert_equal :jsonb, column.send(:simplified_type, 'jsonb')
|
32
|
+
end
|
33
|
+
|
34
|
+
# Note: The rest of the postgresql json shim logic is tested in the pg json
|
35
|
+
# system tests
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -177,7 +177,7 @@ module Ardb::RecordSpy
|
|
177
177
|
assert_respond_to "around_#{name}", subject
|
178
178
|
assert_respond_to "after_#{name}", subject
|
179
179
|
|
180
|
-
callback_name = ["before_#{name}", "around_#{name}", "after_#{name}"].
|
180
|
+
callback_name = ["before_#{name}", "around_#{name}", "after_#{name}"].sample
|
181
181
|
method_name = Factory.string
|
182
182
|
subject.send(callback_name, method_name)
|
183
183
|
callback = subject.callbacks.last
|
@@ -18,12 +18,8 @@ module Ardb::TestHelpers
|
|
18
18
|
|
19
19
|
class UsageTests < UnitTests
|
20
20
|
setup do
|
21
|
-
@
|
22
|
-
@
|
23
|
-
Ardb::Adapter.current = @adapter_spy = @adapter_spy_class.new
|
24
|
-
end
|
25
|
-
teardown do
|
26
|
-
Ardb::Adapter.current = @orig_ardb_adapter
|
21
|
+
@adapter_spy = Ardb::AdapterSpy.new
|
22
|
+
Assert.stub(Ardb, :adapter){ @adapter_spy }
|
27
23
|
end
|
28
24
|
|
29
25
|
end
|
@@ -71,13 +71,13 @@ module Ardb::UseDbDefault
|
|
71
71
|
|
72
72
|
# simulate activerecords `@attributes` hash
|
73
73
|
@original_attrs = @attr_names.inject({}) do |h, n|
|
74
|
-
h.merge!(n => [nil, Factory.string, Factory.integer].
|
74
|
+
h.merge!(n => [nil, Factory.string, Factory.integer].sample)
|
75
75
|
end
|
76
76
|
@original_attrs.merge!(Factory.string => Factory.string)
|
77
77
|
@record.attributes = @original_attrs.dup
|
78
78
|
|
79
79
|
# randomly pick a use-db-default attribute to be changed
|
80
|
-
@record.changed_use_db_default_attrs = [@attr_names.
|
80
|
+
@record.changed_use_db_default_attrs = [@attr_names.sample]
|
81
81
|
@unchanged_attr_names = @attr_names - @record.changed_use_db_default_attrs
|
82
82
|
|
83
83
|
# we should always get the record we just inserted back
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ardb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-06-02 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: assert
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 2.
|
22
|
+
version: 2.16.1
|
23
23
|
type: :development
|
24
24
|
version_requirements: *id001
|
25
25
|
- !ruby/object:Gem::Dependency
|
@@ -48,29 +48,19 @@ dependencies:
|
|
48
48
|
requirements:
|
49
49
|
- - ~>
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: 0.1.
|
51
|
+
version: 0.1.1
|
52
52
|
type: :runtime
|
53
53
|
version_requirements: *id005
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
|
-
name:
|
55
|
+
name: scmd
|
56
56
|
prerelease: false
|
57
57
|
requirement: &id006 !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.0.2
|
62
62
|
type: :runtime
|
63
63
|
version_requirements: *id006
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: scmd
|
66
|
-
prerelease: false
|
67
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
69
|
-
- - ~>
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: 3.0.1
|
72
|
-
type: :runtime
|
73
|
-
version_requirements: *id007
|
74
64
|
description: Activerecord database tools.
|
75
65
|
email:
|
76
66
|
- kelly@kellyredding.com
|
@@ -95,16 +85,17 @@ files:
|
|
95
85
|
- lib/ardb/adapter/sqlite.rb
|
96
86
|
- lib/ardb/adapter_spy.rb
|
97
87
|
- lib/ardb/cli.rb
|
98
|
-
- lib/ardb/clirb.rb
|
88
|
+
- lib/ardb/cli/clirb.rb
|
89
|
+
- lib/ardb/cli/commands.rb
|
99
90
|
- lib/ardb/db_tests.rb
|
100
91
|
- lib/ardb/default_order_by.rb
|
101
92
|
- lib/ardb/has_slug.rb
|
102
93
|
- lib/ardb/migration.rb
|
103
94
|
- lib/ardb/migration_helpers.rb
|
95
|
+
- lib/ardb/pg_json.rb
|
104
96
|
- lib/ardb/record_spy.rb
|
105
97
|
- lib/ardb/relation_spy.rb
|
106
98
|
- lib/ardb/require_autoloaded_active_record_files.rb
|
107
|
-
- lib/ardb/root_path.rb
|
108
99
|
- lib/ardb/test_helpers.rb
|
109
100
|
- lib/ardb/use_db_default.rb
|
110
101
|
- lib/ardb/version.rb
|
@@ -112,6 +103,14 @@ files:
|
|
112
103
|
- script/determine_autoloaded_active_record_files.rb
|
113
104
|
- test/helper.rb
|
114
105
|
- test/support/factory.rb
|
106
|
+
- test/support/fake_schema.rb
|
107
|
+
- test/support/postgresql/migrations/.gitkeep
|
108
|
+
- test/support/postgresql/pg_json_migrations/20160519133432_create_pg_json_migrate_test.rb
|
109
|
+
- test/support/postgresql/schema.rb
|
110
|
+
- test/support/postgresql/setup_test_db.rb
|
111
|
+
- test/support/relative_require_test_db_file.rb
|
112
|
+
- test/support/require_test_db_file.rb
|
113
|
+
- test/system/pg_json_tests.rb
|
115
114
|
- test/unit/adapter/base_tests.rb
|
116
115
|
- test/unit/adapter/mysql_tests.rb
|
117
116
|
- test/unit/adapter/postgresql_tests.rb
|
@@ -119,29 +118,17 @@ files:
|
|
119
118
|
- test/unit/adapter_spy_tests.rb
|
120
119
|
- test/unit/ardb_tests.rb
|
121
120
|
- test/unit/cli_tests.rb
|
122
|
-
- test/unit/config_tests.rb
|
123
121
|
- test/unit/db_tests_tests.rb
|
124
122
|
- test/unit/default_order_by_tests.rb
|
125
123
|
- test/unit/has_slug_tests.rb
|
126
124
|
- test/unit/migration_helpers_tests.rb
|
127
125
|
- test/unit/migration_tests.rb
|
126
|
+
- test/unit/pg_json_tests.rb
|
128
127
|
- test/unit/record_spy_tests.rb
|
129
128
|
- test/unit/relation_spy_tests.rb
|
130
129
|
- test/unit/test_helpers_tests.rb
|
131
130
|
- test/unit/use_db_default_tests.rb
|
132
131
|
- tmp/.gitkeep
|
133
|
-
- tmp/mysqltest/.gitkeep
|
134
|
-
- tmp/pgtest/.gitkeep
|
135
|
-
- tmp/pgtest/Gemfile
|
136
|
-
- tmp/pgtest/Gemfile.lock
|
137
|
-
- tmp/pgtest/config/.gitkeep
|
138
|
-
- tmp/sqlitetest/.gitkeep
|
139
|
-
- tmp/sqlitetest/Gemfile
|
140
|
-
- tmp/sqlitetest/Gemfile.lock
|
141
|
-
- tmp/sqlitetest/config/.gitkeep
|
142
|
-
- tmp/testdb/config/.gitkeep
|
143
|
-
- tmp/testdb/config/db.rb
|
144
|
-
- tmp/testdb/fake_schema.rb
|
145
132
|
homepage: http://github.com/redding/ardb
|
146
133
|
licenses:
|
147
134
|
- MIT
|
@@ -154,13 +141,13 @@ require_paths:
|
|
154
141
|
- lib
|
155
142
|
required_ruby_version: !ruby/object:Gem::Requirement
|
156
143
|
requirements:
|
157
|
-
- &
|
144
|
+
- &id007
|
158
145
|
- ">="
|
159
146
|
- !ruby/object:Gem::Version
|
160
147
|
version: "0"
|
161
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
149
|
requirements:
|
163
|
-
- *
|
150
|
+
- *id007
|
164
151
|
requirements: []
|
165
152
|
|
166
153
|
rubyforge_project:
|
@@ -171,6 +158,14 @@ summary: Activerecord database tools.
|
|
171
158
|
test_files:
|
172
159
|
- test/helper.rb
|
173
160
|
- test/support/factory.rb
|
161
|
+
- test/support/fake_schema.rb
|
162
|
+
- test/support/postgresql/migrations/.gitkeep
|
163
|
+
- test/support/postgresql/pg_json_migrations/20160519133432_create_pg_json_migrate_test.rb
|
164
|
+
- test/support/postgresql/schema.rb
|
165
|
+
- test/support/postgresql/setup_test_db.rb
|
166
|
+
- test/support/relative_require_test_db_file.rb
|
167
|
+
- test/support/require_test_db_file.rb
|
168
|
+
- test/system/pg_json_tests.rb
|
174
169
|
- test/unit/adapter/base_tests.rb
|
175
170
|
- test/unit/adapter/mysql_tests.rb
|
176
171
|
- test/unit/adapter/postgresql_tests.rb
|
@@ -178,12 +173,12 @@ test_files:
|
|
178
173
|
- test/unit/adapter_spy_tests.rb
|
179
174
|
- test/unit/ardb_tests.rb
|
180
175
|
- test/unit/cli_tests.rb
|
181
|
-
- test/unit/config_tests.rb
|
182
176
|
- test/unit/db_tests_tests.rb
|
183
177
|
- test/unit/default_order_by_tests.rb
|
184
178
|
- test/unit/has_slug_tests.rb
|
185
179
|
- test/unit/migration_helpers_tests.rb
|
186
180
|
- test/unit/migration_tests.rb
|
181
|
+
- test/unit/pg_json_tests.rb
|
187
182
|
- test/unit/record_spy_tests.rb
|
188
183
|
- test/unit/relation_spy_tests.rb
|
189
184
|
- test/unit/test_helpers_tests.rb
|
data/lib/ardb/root_path.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# This takes a path string relative to the configured root path and tranforms
|
2
|
-
# to the full qualifed root path. The goal here is to specify path options
|
3
|
-
# with root-relative path strings.
|
4
|
-
|
5
|
-
module Ardb
|
6
|
-
|
7
|
-
class RootPath < String
|
8
|
-
|
9
|
-
def initialize(path_string)
|
10
|
-
super(Ardb.config.root_path.join(path_string).to_s)
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
data/test/unit/config_tests.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'assert'
|
2
|
-
require 'ardb'
|
3
|
-
|
4
|
-
require 'ns-options/assert_macros'
|
5
|
-
|
6
|
-
class Ardb::Config
|
7
|
-
|
8
|
-
class UnitTests < Assert::Context
|
9
|
-
include NsOptions::AssertMacros
|
10
|
-
|
11
|
-
desc "Ardb::Config"
|
12
|
-
subject{ Ardb::Config }
|
13
|
-
|
14
|
-
should have_namespace :db
|
15
|
-
should have_option :db_file, Pathname, :default => ENV['ARDB_DB_FILE']
|
16
|
-
should have_option :root_path, Pathname, :required => true
|
17
|
-
should have_option :logger, :required => true
|
18
|
-
should have_options :migrations_path, :schema_path
|
19
|
-
should have_imeth :db_settings
|
20
|
-
|
21
|
-
should "should use `db/migrations` as the default migrations path" do
|
22
|
-
exp_path = Pathname.new(TESTDB_PATH).join("db/migrations").to_s
|
23
|
-
assert_equal exp_path, subject.migrations_path
|
24
|
-
end
|
25
|
-
|
26
|
-
should "should use `db/schema` as the default schema path" do
|
27
|
-
exp_path = Pathname.new(TESTDB_PATH).join("db/schema").to_s
|
28
|
-
assert_equal exp_path, subject.schema_path
|
29
|
-
end
|
30
|
-
|
31
|
-
should "build the db connection settings from the db configs" do
|
32
|
-
# returns only non-nil values with string keys
|
33
|
-
exp = {
|
34
|
-
'adapter' => "postgresql",
|
35
|
-
'database' => "ardbtest"
|
36
|
-
}
|
37
|
-
assert_equal exp, subject.db_settings
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
class DbTests < UnitTests
|
43
|
-
desc "db namespace"
|
44
|
-
subject{ Ardb::Config.db }
|
45
|
-
|
46
|
-
should have_option :adapter, String, :required => true
|
47
|
-
should have_option :database, String, :required => true
|
48
|
-
should have_option :encoding, String, :required => false
|
49
|
-
should have_option :host, String, :required => false
|
50
|
-
should have_option :port, Integer, :required => false
|
51
|
-
should have_option :username, String, :required => false
|
52
|
-
should have_option :password, String, :required => false
|
53
|
-
should have_option :pool, Integer, :required => false
|
54
|
-
should have_option :checkout_timeout, Integer, :required => false
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|