ardb 0.28.3 → 0.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.l.yml +9 -0
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -0
- data/.t.yml +6 -0
- data/Gemfile +24 -8
- data/README.md +252 -3
- data/ardb.gemspec +14 -10
- data/bin/ardb +3 -1
- data/lib/ardb/adapter/base.rb +72 -47
- data/lib/ardb/adapter/mysql.rb +4 -17
- data/lib/ardb/adapter/postgresql.rb +51 -46
- data/lib/ardb/adapter/sqlite.rb +11 -15
- data/lib/ardb/adapter_spy.rb +18 -30
- data/lib/ardb/cli/clirb.rb +16 -18
- data/lib/ardb/cli/commands.rb +308 -129
- data/lib/ardb/cli.rb +29 -24
- data/lib/ardb/db_tests.rb +4 -4
- data/lib/ardb/default_order_by.rb +13 -21
- data/lib/ardb/migration.rb +15 -16
- data/lib/ardb/record_spy.rb +46 -61
- data/lib/ardb/relation_spy.rb +28 -32
- data/lib/ardb/require_autoloaded_active_record_files.rb +258 -57
- data/lib/ardb/test_helpers.rb +33 -29
- data/lib/ardb/use_db_default.rb +13 -21
- data/lib/ardb/version.rb +3 -1
- data/lib/ardb.rb +105 -86
- data/script/determine_autoloaded_active_record_files.rb +31 -24
- data/test/helper.rb +6 -13
- data/test/support/factory.rb +4 -3
- data/test/support/fake_schema.rb +3 -1
- data/test/support/postgresql/migrations/{.gitkeep → .keep} +0 -0
- data/test/support/postgresql/schema.rb +2 -1
- data/test/support/postgresql/setup_test_db.rb +23 -21
- data/test/support/relative_require_test_db_file.rb +1 -0
- data/test/support/require_test_db_file.rb +1 -0
- data/test/system/.keep +0 -0
- data/test/unit/adapter/base_tests.rb +80 -55
- data/test/unit/adapter/mysql_tests.rb +4 -19
- data/test/unit/adapter/postgresql_tests.rb +21 -30
- data/test/unit/adapter/sqlite_tests.rb +5 -11
- data/test/unit/adapter_spy_tests.rb +6 -17
- data/test/unit/ardb_tests.rb +75 -53
- data/test/unit/cli_tests.rb +234 -158
- data/test/unit/db_tests_tests.rb +7 -7
- data/test/unit/default_order_by_tests.rb +26 -24
- data/test/unit/migration_tests.rb +17 -18
- data/test/unit/record_spy_tests.rb +45 -41
- data/test/unit/relation_spy_tests.rb +40 -63
- data/test/unit/test_helpers_tests.rb +7 -15
- data/test/unit/use_db_default_tests.rb +35 -27
- metadata +109 -87
- data/lib/ardb/has_slug.rb +0 -107
- data/lib/ardb/migration_helpers.rb +0 -77
- data/lib/ardb/pg_json.rb +0 -90
- data/test/support/postgresql/pg_json_migrations/20160519133432_create_pg_json_migrate_test.rb +0 -13
- data/test/system/pg_json_tests.rb +0 -85
- data/test/unit/has_slug_tests.rb +0 -341
- data/test/unit/migration_helpers_tests.rb +0 -65
- data/test/unit/pg_json_tests.rb +0 -39
@@ -1,14 +1,16 @@
|
|
1
|
-
|
2
|
-
require 'ardb/adapter/base'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require
|
3
|
+
require "assert"
|
4
|
+
require "ardb/adapter/base"
|
5
|
+
|
6
|
+
require "active_record/migration"
|
7
|
+
require "ardb"
|
5
8
|
# This is needed by the schema dumper but it doesn't handle requiring it so we
|
6
9
|
# have to manually, otherwise this errors when you try to run the adapter base
|
7
10
|
# tests by themselves
|
8
|
-
require
|
11
|
+
require "active_support/core_ext/class/attribute_accessors"
|
9
12
|
|
10
13
|
class Ardb::Adapter::Base
|
11
|
-
|
12
14
|
class UnitTests < Assert::Context
|
13
15
|
desc "Ardb::Adapter::Base"
|
14
16
|
setup do
|
@@ -21,7 +23,6 @@ class Ardb::Adapter::Base
|
|
21
23
|
should have_imeths :connect_hash, :database, :migrations_path
|
22
24
|
should have_imeths :schema_format, :ruby_schema_path, :sql_schema_path
|
23
25
|
should have_imeths :escape_like_pattern
|
24
|
-
should have_imeths :foreign_key_add_sql, :foreign_key_drop_sql
|
25
26
|
should have_imeths :create_db, :drop_db, :drop_tables
|
26
27
|
should have_imeths :connect_db, :migrate_db
|
27
28
|
should have_imeths :load_schema, :load_ruby_schema, :load_sql_schema
|
@@ -49,7 +50,7 @@ class Ardb::Adapter::Base
|
|
49
50
|
"#{Factory.string}\\" \
|
50
51
|
"#{Factory.string} " \
|
51
52
|
"#{Factory.string}"
|
52
|
-
exp = pattern.gsub("\\"){ "\\\\" }.gsub(
|
53
|
+
exp = pattern.gsub("\\"){ "\\\\" }.gsub("%", "\\%").gsub("_", "\\_")
|
53
54
|
assert_equal exp, subject.escape_like_pattern(pattern)
|
54
55
|
|
55
56
|
pattern = Factory.string
|
@@ -57,7 +58,7 @@ class Ardb::Adapter::Base
|
|
57
58
|
end
|
58
59
|
|
59
60
|
should "allow using a custom escape char when escaping like patterns" do
|
60
|
-
escape_char =
|
61
|
+
escape_char = "#"
|
61
62
|
pattern = "#{Factory.string}%" \
|
62
63
|
"#{Factory.string}_" \
|
63
64
|
"#{Factory.string}\\" \
|
@@ -65,15 +66,10 @@ class Ardb::Adapter::Base
|
|
65
66
|
"#{Factory.string} " \
|
66
67
|
"#{Factory.string}"
|
67
68
|
exp = pattern.gsub(escape_char, "#{escape_char}#{escape_char}")
|
68
|
-
exp = exp.gsub(
|
69
|
+
exp = exp.gsub("%", "#{escape_char}%").gsub("_", "#{escape_char}_")
|
69
70
|
assert_equal exp, subject.escape_like_pattern(pattern, escape_char)
|
70
71
|
end
|
71
72
|
|
72
|
-
should "not implement the foreign key sql meths" do
|
73
|
-
assert_raises(NotImplementedError){ subject.foreign_key_add_sql }
|
74
|
-
assert_raises(NotImplementedError){ subject.foreign_key_drop_sql }
|
75
|
-
end
|
76
|
-
|
77
73
|
should "not implement the create and drop db methods" do
|
78
74
|
assert_raises(NotImplementedError){ subject.create_db }
|
79
75
|
assert_raises(NotImplementedError){ subject.drop_db }
|
@@ -95,7 +91,6 @@ class Ardb::Adapter::Base
|
|
95
91
|
non_matching_adapter = Ardb::Adapter::Base.new(Factory.ardb_config)
|
96
92
|
assert_not_equal non_matching_adapter, subject
|
97
93
|
end
|
98
|
-
|
99
94
|
end
|
100
95
|
|
101
96
|
class ConnectDbTests < UnitTests
|
@@ -114,58 +109,64 @@ class Ardb::Adapter::Base
|
|
114
109
|
@ar_with_connection_called = true
|
115
110
|
end
|
116
111
|
|
117
|
-
|
112
|
+
subject.connect_db
|
118
113
|
end
|
119
114
|
|
120
115
|
should "use activerecord to establish and then checkout a connection" do
|
121
116
|
assert_equal subject.connect_hash, @ar_establish_connection_called_with
|
122
117
|
assert_true @ar_with_connection_called
|
123
118
|
end
|
124
|
-
|
125
119
|
end
|
126
120
|
|
127
|
-
class
|
128
|
-
desc "`migrate_db`"
|
121
|
+
class MigrateTests < UnitTests
|
129
122
|
setup do
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
ENV["MIGRATE_VERSION"] = Factory.integer.to_s if Factory.boolean
|
134
|
-
ENV["MIGRATE_QUIET"] = Factory.boolean.to_s if Factory.boolean
|
135
|
-
|
136
|
-
@migrator_called_with = []
|
137
|
-
Assert.stub(ActiveRecord::Migrator, :migrate) do |*args|
|
138
|
-
@migrator_called_with = args
|
123
|
+
Assert.stub(ActiveRecord::MigrationContext, :new) do |*args|
|
124
|
+
@fake_migration_context ||= FakeMigrationContext.new(*args)
|
139
125
|
end
|
140
|
-
|
141
|
-
@adapter.migrate_db
|
142
|
-
end
|
143
|
-
teardown do
|
144
|
-
ENV['MIGRATE_VERSION'] = @orig_migrate_version_env_var
|
145
|
-
ENV['MIGRATE_QUIET'] = @orig_migrate_query_env_var
|
146
126
|
end
|
147
127
|
|
148
|
-
should "
|
149
|
-
|
150
|
-
|
128
|
+
should "migrate the db with `migrate_db`" do
|
129
|
+
subject.migrate_db
|
130
|
+
|
131
|
+
assert_equal [subject.migrations_path], @fake_migration_context.init_with
|
132
|
+
assert_equal [nil], @fake_migration_context.up_called_with
|
151
133
|
end
|
152
134
|
|
153
|
-
should "
|
154
|
-
|
155
|
-
assert_equal
|
135
|
+
should "migrate the db with `migrate_db_up`" do
|
136
|
+
subject.migrate_db_up
|
137
|
+
assert_equal [nil], @fake_migration_context.up_called_with
|
138
|
+
|
139
|
+
target = Factory.string
|
140
|
+
subject.migrate_db_up(target)
|
141
|
+
assert_equal [target], @fake_migration_context.up_called_with
|
156
142
|
end
|
157
143
|
|
158
|
-
should "
|
159
|
-
|
160
|
-
assert_equal
|
144
|
+
should "migrate the db with `migrate_db_down`" do
|
145
|
+
subject.migrate_db_down
|
146
|
+
assert_equal [nil], @fake_migration_context.down_called_with
|
147
|
+
|
148
|
+
target = Factory.string
|
149
|
+
subject.migrate_db_down(target)
|
150
|
+
assert_equal [target], @fake_migration_context.down_called_with
|
161
151
|
end
|
162
152
|
|
163
|
-
should "
|
164
|
-
|
165
|
-
|
166
|
-
|
153
|
+
should "migrate the db with `migrate_db_forward`" do
|
154
|
+
subject.migrate_db_forward
|
155
|
+
assert_equal [1], @fake_migration_context.forward_called_with
|
156
|
+
|
157
|
+
steps = Factory.integer(3)
|
158
|
+
subject.migrate_db_forward(steps)
|
159
|
+
assert_equal [steps], @fake_migration_context.forward_called_with
|
167
160
|
end
|
168
161
|
|
162
|
+
should "migrate the db with `migrate_db_backward`" do
|
163
|
+
subject.migrate_db_backward
|
164
|
+
assert_equal [1], @fake_migration_context.rollback_called_with
|
165
|
+
|
166
|
+
steps = Factory.integer(3)
|
167
|
+
subject.migrate_db_backward(steps)
|
168
|
+
assert_equal [steps], @fake_migration_context.rollback_called_with
|
169
|
+
end
|
169
170
|
end
|
170
171
|
|
171
172
|
class LoadAndDumpSchemaTests < UnitTests
|
@@ -238,12 +239,11 @@ class Ardb::Adapter::Base
|
|
238
239
|
subject.load_schema
|
239
240
|
assert_empty @captured_stdout
|
240
241
|
end
|
241
|
-
|
242
242
|
end
|
243
243
|
|
244
244
|
class LoadRubySchemaTests < UnitTests
|
245
245
|
setup do
|
246
|
-
@config.schema_path = File.join(TEST_SUPPORT_PATH,
|
246
|
+
@config.schema_path = File.join(TEST_SUPPORT_PATH, "fake_schema")
|
247
247
|
@adapter = Ardb::Adapter::Base.new(@config)
|
248
248
|
end
|
249
249
|
|
@@ -255,12 +255,12 @@ class Ardb::Adapter::Base
|
|
255
255
|
subject.load_ruby_schema
|
256
256
|
assert_equal 2, FAKE_SCHEMA.load_count
|
257
257
|
end
|
258
|
-
|
259
258
|
end
|
260
259
|
|
261
260
|
class DumpRubySchemaTests < UnitTests
|
262
261
|
setup do
|
263
|
-
@config.schema_path =
|
262
|
+
@config.schema_path =
|
263
|
+
File.join(TMP_PATH, "testdb", "test_dump_ruby_schema")
|
264
264
|
FileUtils.rm_rf(File.dirname(@config.schema_path))
|
265
265
|
|
266
266
|
@schema_dumper_connection, @schema_dumper_file = [nil, nil]
|
@@ -279,14 +279,13 @@ class Ardb::Adapter::Base
|
|
279
279
|
end
|
280
280
|
|
281
281
|
should "dump a ruby schema file using `dump_ruby_schema`" do
|
282
|
-
assert_false File.
|
282
|
+
assert_false File.exist?(subject.ruby_schema_path)
|
283
283
|
subject.dump_ruby_schema
|
284
|
-
assert_true File.
|
284
|
+
assert_true File.exist?(subject.ruby_schema_path)
|
285
285
|
assert_equal @fake_connection, @schema_dumper_connection
|
286
286
|
assert_instance_of File, @schema_dumper_file
|
287
287
|
assert_equal subject.ruby_schema_path, @schema_dumper_file.path
|
288
288
|
end
|
289
|
-
|
290
289
|
end
|
291
290
|
|
292
291
|
class FakeConnection; end
|
@@ -325,7 +324,33 @@ class Ardb::Adapter::Base
|
|
325
324
|
end
|
326
325
|
|
327
326
|
class FakeConnectionPool
|
328
|
-
def with_connection(&block)
|
327
|
+
def with_connection(&block)
|
328
|
+
end
|
329
329
|
end
|
330
330
|
|
331
|
+
class FakeMigrationContext
|
332
|
+
attr_reader :init_with
|
333
|
+
attr_reader :up_called_with, :down_called_with
|
334
|
+
attr_reader :forward_called_with, :rollback_called_with
|
335
|
+
|
336
|
+
def initialize(*args)
|
337
|
+
@init_with = args
|
338
|
+
end
|
339
|
+
|
340
|
+
def up(*args)
|
341
|
+
@up_called_with = args
|
342
|
+
end
|
343
|
+
|
344
|
+
def down(*args)
|
345
|
+
@down_called_with = args
|
346
|
+
end
|
347
|
+
|
348
|
+
def forward(*args)
|
349
|
+
@forward_called_with = args
|
350
|
+
end
|
351
|
+
|
352
|
+
def rollback(*args)
|
353
|
+
@rollback_called_with = args
|
354
|
+
end
|
355
|
+
end
|
331
356
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'ardb/adapter/mysql'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
require "assert"
|
4
|
+
require "ardb/adapter/mysql"
|
5
5
|
|
6
|
+
class Ardb::Adapter::Mysql
|
6
7
|
class UnitTests < Assert::Context
|
7
8
|
desc "Ardb::Adapter::Mysql"
|
8
9
|
setup do
|
@@ -11,20 +12,6 @@ class Ardb::Adapter::Mysql
|
|
11
12
|
end
|
12
13
|
subject{ @adapter }
|
13
14
|
|
14
|
-
should "know its foreign key add sql" do
|
15
|
-
exp_add_sql = "ALTER TABLE :from_table"\
|
16
|
-
" ADD CONSTRAINT :name"\
|
17
|
-
" FOREIGN KEY (:from_column)"\
|
18
|
-
" REFERENCES :to_table (:to_column)"
|
19
|
-
assert_equal exp_add_sql, subject.foreign_key_add_sql
|
20
|
-
end
|
21
|
-
|
22
|
-
should "know its foreign key drop sql" do
|
23
|
-
exp_drop_sql = "ALTER TABLE :from_table"\
|
24
|
-
" DROP FOREIGN KEY :name"
|
25
|
-
assert_equal exp_drop_sql, subject.foreign_key_drop_sql
|
26
|
-
end
|
27
|
-
|
28
15
|
# not currently implemented, see: https://github.com/redding/ardb/issues/13
|
29
16
|
should "not implement the create and drop db methods" do
|
30
17
|
assert_raises(NotImplementedError){ subject.create_db }
|
@@ -35,7 +22,5 @@ class Ardb::Adapter::Mysql
|
|
35
22
|
should "not implement the drop tables method" do
|
36
23
|
assert_raises(NotImplementedError){ subject.drop_tables }
|
37
24
|
end
|
38
|
-
|
39
25
|
end
|
40
|
-
|
41
26
|
end
|
@@ -1,10 +1,11 @@
|
|
1
|
-
|
2
|
-
require 'ardb/adapter/postgresql'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require
|
3
|
+
require "assert"
|
4
|
+
require "ardb/adapter/postgresql"
|
5
5
|
|
6
|
-
|
6
|
+
require "scmd"
|
7
7
|
|
8
|
+
class Ardb::Adapter::Postgresql
|
8
9
|
class UnitTests < Assert::Context
|
9
10
|
desc "Ardb::Adapter::Postgresql"
|
10
11
|
setup do
|
@@ -17,52 +18,42 @@ class Ardb::Adapter::Postgresql
|
|
17
18
|
|
18
19
|
should "know its public connect hash" do
|
19
20
|
exp = subject.connect_hash.merge({
|
20
|
-
|
21
|
-
|
21
|
+
"database" => "postgres",
|
22
|
+
"schema_search_path" => "public",
|
22
23
|
})
|
23
24
|
assert_equal exp, subject.public_connect_hash
|
24
25
|
end
|
25
26
|
|
26
|
-
should "
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
assert_equal exp_add_sql, subject.foreign_key_add_sql
|
27
|
+
should "complain if given a database name with non-word characters" do
|
28
|
+
@config.database = "#{Factory.string}-#{Factory.string}"
|
29
|
+
assert_raises(Ardb::ConfigurationError) do
|
30
|
+
Ardb::Adapter::Postgresql.new(@config)
|
31
|
+
end
|
32
32
|
end
|
33
|
-
|
34
|
-
should "know its foreign key drop sql" do
|
35
|
-
exp_drop_sql = "ALTER TABLE :from_table"\
|
36
|
-
" DROP CONSTRAINT :name"
|
37
|
-
assert_equal exp_drop_sql, subject.foreign_key_drop_sql
|
38
|
-
end
|
39
|
-
|
40
33
|
end
|
41
34
|
|
42
35
|
class SQLSchemaTests < UnitTests
|
43
36
|
setup do
|
44
37
|
@env = {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
38
|
+
"PGHOST" => @adapter.connect_hash["host"],
|
39
|
+
"PGPORT" => @adapter.connect_hash["port"],
|
40
|
+
"PGUSER" => @adapter.connect_hash["username"],
|
41
|
+
"PGPASSWORD" => @adapter.connect_hash["password"],
|
49
42
|
}
|
50
43
|
end
|
51
|
-
|
52
44
|
end
|
53
45
|
|
54
46
|
class LoadSQLSchemaTests < SQLSchemaTests
|
55
47
|
setup do
|
56
48
|
cmd_str = "psql -f \"#{@adapter.sql_schema_path}\" #{@adapter.database}"
|
57
49
|
@cmd_spy = CmdSpy.new
|
58
|
-
Assert.stub(Scmd, :new).with(cmd_str, :
|
50
|
+
Assert.stub(Scmd, :new).with(cmd_str, env: @env){ @cmd_spy }
|
59
51
|
end
|
60
52
|
|
61
53
|
should "run a command for loading a SQL schema using `load_sql_schema`" do
|
62
54
|
subject.load_sql_schema
|
63
55
|
assert_true @cmd_spy.run_called
|
64
56
|
end
|
65
|
-
|
66
57
|
end
|
67
58
|
|
68
59
|
class DumpSQLSchemaTests < SQLSchemaTests
|
@@ -70,14 +61,13 @@ class Ardb::Adapter::Postgresql
|
|
70
61
|
cmd_str = "pg_dump -i -s -x -O -f " \
|
71
62
|
"\"#{@adapter.sql_schema_path}\" #{@adapter.database}"
|
72
63
|
@cmd_spy = CmdSpy.new
|
73
|
-
Assert.stub(Scmd, :new).with(cmd_str, :
|
64
|
+
Assert.stub(Scmd, :new).with(cmd_str, env: @env){ @cmd_spy }
|
74
65
|
end
|
75
66
|
|
76
67
|
should "run a command for dumping a SQL schema using `dump_sql_schema`" do
|
77
68
|
subject.dump_sql_schema
|
78
69
|
assert_true @cmd_spy.run_called
|
79
70
|
end
|
80
|
-
|
81
71
|
end
|
82
72
|
|
83
73
|
class CmdSpy
|
@@ -91,7 +81,8 @@ class Ardb::Adapter::Postgresql
|
|
91
81
|
@run_called = true
|
92
82
|
end
|
93
83
|
|
94
|
-
def success
|
84
|
+
def success?
|
85
|
+
true
|
86
|
+
end
|
95
87
|
end
|
96
|
-
|
97
88
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'ardb/adapter/sqlite'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
require "assert"
|
4
|
+
require "ardb/adapter/sqlite"
|
5
5
|
|
6
|
+
class Ardb::Adapter::Sqlite
|
6
7
|
class UnitTests < Assert::Context
|
7
8
|
desc "Ardb::Adapter::Sqlite"
|
8
9
|
setup do
|
@@ -24,21 +25,14 @@ class Ardb::Adapter::Sqlite
|
|
24
25
|
exp = File.expand_path(@config.database, @config.root_path)
|
25
26
|
assert_equal exp, subject.db_file_path
|
26
27
|
|
27
|
-
@config.database = File.join(TMP_PATH,
|
28
|
+
@config.database = File.join(TMP_PATH, "abs_sqlite_db_test")
|
28
29
|
adapter = Ardb::Adapter::Sqlite.new(@config)
|
29
30
|
assert_equal @config.database, adapter.db_file_path
|
30
31
|
end
|
31
32
|
|
32
|
-
should "not implement the foreign key sql meths" do
|
33
|
-
assert_raises(NotImplementedError){ subject.foreign_key_add_sql }
|
34
|
-
assert_raises(NotImplementedError){ subject.foreign_key_drop_sql }
|
35
|
-
end
|
36
|
-
|
37
33
|
# not currently implemented, see: https://github.com/redding/ardb/issues/29
|
38
34
|
should "not implement the drop tables method" do
|
39
35
|
assert_raises(NotImplementedError){ subject.drop_tables }
|
40
36
|
end
|
41
|
-
|
42
37
|
end
|
43
|
-
|
44
38
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'ardb/adapter_spy'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
require "assert"
|
4
|
+
require "ardb/adapter_spy"
|
5
5
|
|
6
|
+
class Ardb::AdapterSpy
|
6
7
|
class UnitTests < Assert::Context
|
7
8
|
desc "Ardb::AdapterSpy"
|
8
9
|
setup do
|
@@ -13,7 +14,6 @@ class Ardb::AdapterSpy
|
|
13
14
|
should "be a kind of ardb adapter" do
|
14
15
|
assert subject < Ardb::Adapter::Base
|
15
16
|
end
|
16
|
-
|
17
17
|
end
|
18
18
|
|
19
19
|
class InitTests < UnitTests
|
@@ -28,8 +28,8 @@ class Ardb::AdapterSpy
|
|
28
28
|
should have_accessors :dump_schema_called_count, :load_schema_called_count
|
29
29
|
should have_accessors :drop_db_called_count, :create_db_called_count
|
30
30
|
should have_accessors :connect_db_called_count, :migrate_db_called_count
|
31
|
-
should have_imeths :
|
32
|
-
should have_imeths :
|
31
|
+
should have_imeths :create_db_called?, :drop_db_called?
|
32
|
+
should have_imeths :drop_tables_called?
|
33
33
|
should have_imeths :connect_db_called?, :migrate_db_called?
|
34
34
|
should have_imeths :dump_schema_called?, :load_schema_called?
|
35
35
|
should have_imeths :create_db, :drop_db, :drop_tables
|
@@ -46,15 +46,6 @@ class Ardb::AdapterSpy
|
|
46
46
|
assert_equal 0, subject.dump_schema_called_count
|
47
47
|
end
|
48
48
|
|
49
|
-
should "know its add and drop foreign key sql" do
|
50
|
-
exp = "FAKE ADD FOREIGN KEY SQL :from_table :from_column " \
|
51
|
-
":to_table :to_column :name"
|
52
|
-
assert_equal exp, subject.foreign_key_add_sql
|
53
|
-
exp = "FAKE DROP FOREIGN KEY SQL :from_table :from_column " \
|
54
|
-
":to_table :to_column :name"
|
55
|
-
assert_equal exp, subject.foreign_key_drop_sql
|
56
|
-
end
|
57
|
-
|
58
49
|
should "know if and how many times a method is called" do
|
59
50
|
assert_equal false, subject.create_db_called?
|
60
51
|
subject.create_db
|
@@ -91,7 +82,5 @@ class Ardb::AdapterSpy
|
|
91
82
|
assert_equal 1, subject.load_schema_called_count
|
92
83
|
assert_equal true, subject.load_schema_called?
|
93
84
|
end
|
94
|
-
|
95
85
|
end
|
96
|
-
|
97
86
|
end
|