ardb 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem 'rake'
6
- gem 'pry'
6
+ gem 'pry', "~> 0.9.0"
7
7
 
8
8
  platform :rbx do
9
9
  gem 'rubysl'
data/ardb.gemspec CHANGED
@@ -18,10 +18,12 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_development_dependency("assert", ["~> 2.0"])
21
+ gem.add_development_dependency("assert", ["~> 2.10"])
22
+ gem.add_development_dependency("assert-mocha", ["~> 1.1"])
22
23
 
23
24
  gem.add_dependency('activerecord', ["~> 3.2"])
24
25
  gem.add_dependency('activesupport', ["~> 3.2"])
25
26
  gem.add_dependency('ns-options', ["~> 1.1"])
27
+ gem.add_dependency('scmd', ["~> 2.2"])
26
28
 
27
29
  end
data/lib/ardb.rb CHANGED
@@ -51,7 +51,8 @@ module Ardb
51
51
  option :root_path, Pathname, :required => true
52
52
  option :logger, :required => true
53
53
  option :migrations_path, RootPath, :default => proc{ "db/migrations" }
54
- option :schema_path, RootPath, :default => proc{ "db/schema.rb" }
54
+ option :schema_path, RootPath, :default => proc{ "db/schema" }
55
+ option :schema_format, Symbol, :default => :ruby
55
56
 
56
57
  def self.db_settings
57
58
  db.to_hash.inject({}) do |settings, (k, v)|
@@ -3,10 +3,15 @@ class Ardb::Adapter; end
3
3
  class Ardb::Adapter::Base
4
4
 
5
5
  attr_reader :config_settings, :database
6
+ attr_reader :schema_format, :ruby_schema_path, :sql_schema_path
6
7
 
7
8
  def initialize
8
9
  @config_settings = Ardb.config.db_settings
9
10
  @database = Ardb.config.db.database
11
+ @schema_format = Ardb.config.schema_format
12
+ schema_path = Ardb.config.schema_path
13
+ @ruby_schema_path = "#{schema_path}.rb"
14
+ @sql_schema_path = "#{schema_path}.sql"
10
15
  end
11
16
 
12
17
  def foreign_key_add_sql(*args); raise NotImplementedError; end
@@ -21,10 +26,40 @@ class Ardb::Adapter::Base
21
26
  # silence STDOUT
22
27
  current_stdout = $stdout.dup
23
28
  $stdout = File.new('/dev/null', 'w')
24
- load Ardb.config.schema_path
29
+ load_ruby_schema if @schema_format == :ruby
30
+ load_sql_schema if @schema_format == :sql
25
31
  $stdout = current_stdout
26
32
  end
27
33
 
34
+ def load_ruby_schema
35
+ load @ruby_schema_path
36
+ end
37
+
38
+ def load_sql_schema
39
+ raise NotImplementedError
40
+ end
41
+
42
+ def dump_schema
43
+ # silence STDOUT
44
+ current_stdout = $stdout.dup
45
+ $stdout = File.new('/dev/null', 'w')
46
+ dump_ruby_schema
47
+ dump_sql_schema if @schema_format == :sql
48
+ $stdout = current_stdout
49
+ end
50
+
51
+ def dump_ruby_schema
52
+ require 'active_record/schema_dumper'
53
+ FileUtils.mkdir_p File.dirname(@ruby_schema_path)
54
+ File.open(@ruby_schema_path, 'w:utf-8') do |file|
55
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
56
+ end
57
+ end
58
+
59
+ def dump_sql_schema
60
+ raise NotImplementedError
61
+ end
62
+
28
63
  def ==(other_adapter)
29
64
  self.class == other_adapter.class
30
65
  end
@@ -56,6 +56,31 @@ class Ardb::Adapter
56
56
  " DROP CONSTRAINT :name"
57
57
  end
58
58
 
59
+ def load_sql_schema
60
+ require 'scmd'
61
+ cmd_str = "psql -f \"#{self.sql_schema_path}\" #{self.database}"
62
+ cmd = Scmd.new(cmd_str, env_var_hash).tap(&:run)
63
+ raise 'Error loading database' unless cmd.success?
64
+ end
65
+
66
+ def dump_sql_schema
67
+ require 'scmd'
68
+ cmd_str = "pg_dump -i -s -x -O -f \"#{self.sql_schema_path}\" #{self.database}"
69
+ cmd = Scmd.new(cmd_str, env_var_hash).tap(&:run)
70
+ raise 'Error dumping database' unless cmd.success?
71
+ end
72
+
73
+ private
74
+
75
+ def env_var_hash
76
+ @env_var_hash ||= {
77
+ 'PGHOST' => self.config_settings['host'],
78
+ 'PGPORT' => self.config_settings['port'],
79
+ 'PGUSER' => self.config_settings['username'],
80
+ 'PGPASSWORD' => self.config_settings['password']
81
+ }
82
+ end
83
+
59
84
  end
60
85
 
61
86
  end
@@ -5,11 +5,11 @@ require 'ardb/migration_helpers'
5
5
 
6
6
  class Ardb::Runner::MigrateCommand
7
7
 
8
- attr_reader :migrations_path, :schema_file_path, :version, :verbose
8
+ attr_reader :migrations_path, :version, :verbose
9
9
 
10
10
  def initialize
11
+ @adapter = Ardb::Adapter.send(Ardb.config.db.adapter)
11
12
  @migrations_path = Ardb.config.migrations_path
12
- @schema_file_path = Ardb.config.schema_path
13
13
  @version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
14
14
  @verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
15
15
  end
@@ -29,7 +29,9 @@ class Ardb::Runner::MigrateCommand
29
29
 
30
30
  def migrate_the_db
31
31
  if defined?(ActiveRecord::Migration::CommandRecorder)
32
- ActiveRecord::Migration::CommandRecorder.send(:include, Ardb::MigrationHelpers::RecorderMixin)
32
+ ActiveRecord::Migration::CommandRecorder.class_eval do
33
+ include Ardb::MigrationHelpers::RecorderMixin
34
+ end
33
35
  end
34
36
 
35
37
  ActiveRecord::Migrator.migrations_path = @migrations_path
@@ -38,11 +40,7 @@ class Ardb::Runner::MigrateCommand
38
40
  ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope)
39
41
  end
40
42
 
41
- require 'active_record/schema_dumper'
42
- FileUtils.mkdir_p File.dirname(@schema_file_path)
43
- File.open(@schema_file_path, "w:utf-8") do |file|
44
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
45
- end
43
+ @adapter.dump_schema
46
44
  end
47
45
 
48
46
  end
data/lib/ardb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ardb
2
- VERSION = "0.20.0"
2
+ VERSION = "0.21.0"
3
3
  end
data/test/helper.rb CHANGED
@@ -6,6 +6,7 @@ $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
6
6
 
7
7
  # require pry for debugging (`binding.pry`)
8
8
  require 'pry'
9
+ require 'assert-mocha' if defined?(Assert)
9
10
 
10
11
  ENV['ARDB_DB_FILE'] = 'tmp/testdb/config/db'
11
12
  require 'ardb'
@@ -3,67 +3,183 @@ require 'ardb/adapter/base'
3
3
 
4
4
  class Ardb::Adapter::Base
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb::Adapter::Base"
8
8
  setup do
9
9
  @adapter = Ardb::Adapter::Base.new
10
10
  end
11
- subject { @adapter }
11
+ subject{ @adapter }
12
12
 
13
- should have_reader :config_settings, :database
13
+ should have_readers :config_settings, :database
14
+ should have_readers :ruby_schema_path, :sql_schema_path
14
15
  should have_imeths :foreign_key_add_sql, :foreign_key_drop_sql
15
- should have_imeths :create_db, :drop_db, :load_schema
16
+ should have_imeths :create_db, :drop_db
17
+ should have_imeths :load_schema, :load_ruby_schema, :load_sql_schema
18
+ should have_imeths :dump_schema, :dump_ruby_schema, :dump_sql_schema
16
19
 
17
- should "use the config's db settings " do
20
+ should "know its config settings " do
18
21
  assert_equal Ardb.config.db_settings, subject.config_settings
19
22
  end
20
23
 
21
- should "use the config's database" do
24
+ should "know its database" do
22
25
  assert_equal Ardb.config.db.database, subject.database
23
26
  end
24
27
 
28
+ should "know its schema paths" do
29
+ assert_equal "#{Ardb.config.schema_path}.rb", subject.ruby_schema_path
30
+ assert_equal "#{Ardb.config.schema_path}.sql", subject.sql_schema_path
31
+ end
32
+
25
33
  should "not implement the foreign key sql meths" do
26
- assert_raises(NotImplementedError) { subject.foreign_key_add_sql }
27
- assert_raises(NotImplementedError) { subject.foreign_key_drop_sql }
34
+ assert_raises(NotImplementedError){ subject.foreign_key_add_sql }
35
+ assert_raises(NotImplementedError){ subject.foreign_key_drop_sql }
28
36
  end
29
37
 
30
38
  should "not implement the create and drop db methods" do
31
- assert_raises(NotImplementedError) { subject.create_db }
32
- assert_raises(NotImplementedError) { subject.drop_db }
39
+ assert_raises(NotImplementedError){ subject.create_db }
40
+ assert_raises(NotImplementedError){ subject.drop_db }
33
41
  end
34
42
 
35
43
  should "not implement the drop table methods" do
36
- assert_raises(NotImplementedError) { subject.drop_tables }
44
+ assert_raises(NotImplementedError){ subject.drop_tables }
45
+ end
46
+
47
+ should "not implement the load and dump sql schema methods" do
48
+ assert_raises(NotImplementedError){ subject.load_sql_schema }
49
+ assert_raises(NotImplementedError){ subject.dump_sql_schema }
37
50
  end
38
51
 
39
52
  end
40
53
 
41
- class LoadSchemaTests < BaseTests
42
- desc "given a schema"
54
+ class LoadAndDumpSchemaTests < UnitTests
43
55
  setup do
44
- ::FAKE_SCHEMA_LOAD = OpenStruct.new(:count => 0)
45
- @orig_schema_path = Ardb.config.schema_path
46
- Ardb.config.schema_path = 'fake_schema.rb'
56
+ @orig_stdout = $stdout.dup
57
+ @captured_stdout = ""
58
+ $stdout = StringIO.new(@captured_stdout)
59
+
60
+ @orig_schema_format = Ardb.config.schema_format
61
+
62
+ @adapter = SchemaSpyAdapter.new
47
63
  end
48
64
  teardown do
49
- Ardb.config.schema_path = @orig_schema_path
65
+ Ardb.config.schema_format = @orig_schema_format
66
+ $stdout = @orig_stdout
67
+ end
68
+
69
+ should "load a ruby schema using `load_schema` when the format is ruby" do
70
+ Ardb.config.schema_format = :ruby
71
+ adapter = SchemaSpyAdapter.new
72
+
73
+ assert_false adapter.load_ruby_schema_called
74
+ assert_false adapter.load_sql_schema_called
75
+ adapter.load_schema
76
+ assert_true adapter.load_ruby_schema_called
77
+ assert_false adapter.load_sql_schema_called
50
78
  end
51
79
 
52
- should "load the schema suppressing $stdout" do
53
- orig_stdout = $stdout.dup
54
- captured_stdout = ""
55
- $stdout = StringIO.new(captured_stdout)
80
+ should "load a SQL schema using `load_schema` when the format is sql" do
81
+ Ardb.config.schema_format = :sql
82
+ adapter = SchemaSpyAdapter.new
83
+
84
+ assert_false adapter.load_ruby_schema_called
85
+ assert_false adapter.load_sql_schema_called
86
+ adapter.load_schema
87
+ assert_false adapter.load_ruby_schema_called
88
+ assert_true adapter.load_sql_schema_called
89
+ end
56
90
 
57
- assert_equal 0, FAKE_SCHEMA_LOAD.count
91
+ should "suppress stdout when loading the schema" do
58
92
  subject.load_schema
59
- assert_equal 1, FAKE_SCHEMA_LOAD.count
93
+ assert_empty @captured_stdout
94
+ end
95
+
96
+ should "always dump a ruby schema using `dump_schema`" do
97
+ Ardb.config.schema_format = :ruby
98
+ adapter = SchemaSpyAdapter.new
99
+
100
+ assert_false adapter.dump_ruby_schema_called
101
+ assert_false adapter.dump_sql_schema_called
102
+ adapter.dump_schema
103
+ assert_true adapter.dump_ruby_schema_called
104
+ assert_false adapter.dump_sql_schema_called
105
+
106
+ Ardb.config.schema_format = :sql
107
+ adapter = SchemaSpyAdapter.new
108
+
109
+ assert_false adapter.dump_ruby_schema_called
110
+ adapter.dump_schema
111
+ assert_true adapter.dump_ruby_schema_called
112
+ end
113
+
114
+ should "dump a SQL schema using `dump_schema` when the format is sql" do
115
+ Ardb.config.schema_format = :sql
116
+ adapter = SchemaSpyAdapter.new
117
+
118
+ assert_false adapter.dump_ruby_schema_called
119
+ adapter.dump_schema
120
+ assert_true adapter.dump_ruby_schema_called
121
+ end
122
+
123
+ should "suppress stdout when dumping the schema" do
60
124
  subject.load_schema
61
- assert_equal 2, FAKE_SCHEMA_LOAD.count
62
- assert_empty captured_stdout
125
+ assert_empty @captured_stdout
126
+ end
63
127
 
64
- $stdout = orig_stdout
128
+ end
129
+
130
+ class LoadRubySchemaTests < UnitTests
131
+ setup do
132
+ @orig_schema_path = Ardb.config.schema_path
133
+ Ardb.config.schema_path = 'fake_schema'
134
+
135
+ @adapter = Ardb::Adapter::Base.new
136
+ end
137
+ teardown do
138
+ Ardb.config.schema_path = @orig_schema_path
65
139
  end
66
140
 
141
+ should "load a ruby schema file using `load_ruby_schema`" do
142
+ assert_nil defined?(FAKE_SCHEMA)
143
+ subject.load_ruby_schema
144
+ assert_not_nil defined?(FAKE_SCHEMA)
145
+ assert_equal 1, FAKE_SCHEMA.load_count
146
+ subject.load_ruby_schema
147
+ assert_equal 2, FAKE_SCHEMA.load_count
148
+ end
149
+
150
+ end
151
+
152
+ class SchemaSpyAdapter < Ardb::Adapter::Base
153
+ attr_reader :load_ruby_schema_called, :dump_ruby_schema_called
154
+ attr_reader :load_sql_schema_called, :dump_sql_schema_called
155
+
156
+ def initialize(*args)
157
+ super
158
+ @load_ruby_schema_called = false
159
+ @dump_ruby_schema_called = false
160
+ @load_sql_schema_called = false
161
+ @dump_sql_schema_called = false
162
+ end
163
+
164
+ def load_ruby_schema
165
+ puts "[load_ruby_schema] This should be suppressed!"
166
+ @load_ruby_schema_called = true
167
+ end
168
+
169
+ def dump_ruby_schema
170
+ puts "[dump_ruby_schema] This should be suppressed!"
171
+ @dump_ruby_schema_called = true
172
+ end
173
+
174
+ def load_sql_schema
175
+ puts "[load_sql_schema] This should be suppressed!"
176
+ @load_sql_schema_called = true
177
+ end
178
+
179
+ def dump_sql_schema
180
+ puts "[dump_sql_schema] This should be suppressed!"
181
+ @dump_sql_schema_called = true
182
+ end
67
183
  end
68
184
 
69
185
  end
@@ -3,7 +3,7 @@ require 'ardb/adapter/mysql'
3
3
 
4
4
  class Ardb::Adapter::Mysql
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb::Adapter::Mysql"
8
8
  setup do
9
9
  @adapter = Ardb::Adapter::Mysql.new
@@ -26,13 +26,13 @@ class Ardb::Adapter::Mysql
26
26
 
27
27
  # not currently implemented, see: https://github.com/redding/ardb/issues/13
28
28
  should "not implement the create and drop db methods" do
29
- assert_raises(NotImplementedError) { subject.create_db }
30
- assert_raises(NotImplementedError) { subject.drop_db }
29
+ assert_raises(NotImplementedError){ subject.create_db }
30
+ assert_raises(NotImplementedError){ subject.drop_db }
31
31
  end
32
32
 
33
33
  # not currently implemented, see: https://github.com/redding/ardb/issues/28
34
34
  should "not implement the drop tables method" do
35
- assert_raises(NotImplementedError) { subject.drop_tables }
35
+ assert_raises(NotImplementedError){ subject.drop_tables }
36
36
  end
37
37
 
38
38
  end
@@ -1,18 +1,20 @@
1
1
  require 'assert'
2
2
  require 'ardb/adapter/postgresql'
3
3
 
4
+ require 'scmd'
5
+
4
6
  class Ardb::Adapter::Postgresql
5
7
 
6
- class BaseTests < Assert::Context
8
+ class UnitTests < Assert::Context
7
9
  desc "Ardb::Adapter::Postgresql"
8
10
  setup do
9
11
  @adapter = Ardb::Adapter::Postgresql.new
10
12
  end
11
- subject { @adapter }
13
+ subject{ @adapter }
12
14
 
13
- should have_instance_method :public_schema_settings
15
+ should have_imeths :public_schema_settings
14
16
 
15
- should "know it's public schema connection settings" do
17
+ should "know its public schema connection settings" do
16
18
  exp_settings = subject.config_settings.merge({
17
19
  'database' => 'postgres',
18
20
  'schema_search_path' => 'public'
@@ -36,4 +38,71 @@ class Ardb::Adapter::Postgresql
36
38
 
37
39
  end
38
40
 
41
+ class SQLSchemaTests < UnitTests
42
+ setup do
43
+ @env = {
44
+ 'PGHOST' => @adapter.config_settings['host'],
45
+ 'PGPORT' => @adapter.config_settings['port'],
46
+ 'PGUSER' => @adapter.config_settings['username'],
47
+ 'PGPASSWORD' => @adapter.config_settings['password']
48
+ }
49
+ end
50
+
51
+ end
52
+
53
+ class LoadSQLSchemaTests < SQLSchemaTests
54
+ setup do
55
+ cmd_str = "psql -f \"#{@adapter.sql_schema_path}\" #{@adapter.database}"
56
+ @cmd_spy = CmdSpy.new
57
+ Scmd.stubs(:new).tap do |s|
58
+ s.with(cmd_str, @env)
59
+ s.returns(@cmd_spy)
60
+ end
61
+ end
62
+ teardown do
63
+ Scmd.unstub(:new)
64
+ end
65
+
66
+ should "run a command for loading a SQL schema using `load_sql_schema`" do
67
+ subject.load_sql_schema
68
+ assert_true @cmd_spy.run_called
69
+ end
70
+
71
+ end
72
+
73
+ class DumpSQLSchemaTests < SQLSchemaTests
74
+ setup do
75
+ cmd_str = "pg_dump -i -s -x -O -f " \
76
+ "\"#{@adapter.sql_schema_path}\" #{@adapter.database}"
77
+ @cmd_spy = CmdSpy.new
78
+ Scmd.stubs(:new).tap do |s|
79
+ s.with(cmd_str, @env)
80
+ s.returns(@cmd_spy)
81
+ end
82
+ end
83
+ teardown do
84
+ Scmd.unstub(:new)
85
+ end
86
+
87
+ should "run a command for dumping a SQL schema using `dump_sql_schema`" do
88
+ subject.dump_sql_schema
89
+ assert_true @cmd_spy.run_called
90
+ end
91
+
92
+ end
93
+
94
+ class CmdSpy
95
+ attr_reader :run_called
96
+
97
+ def initialize
98
+ @run_called = false
99
+ end
100
+
101
+ def run
102
+ @run_called = true
103
+ end
104
+
105
+ def success?; true; end
106
+ end
107
+
39
108
  end
@@ -3,7 +3,7 @@ require 'ardb/adapter/sqlite'
3
3
 
4
4
  class Ardb::Adapter::Sqlite
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb::Adapter::Sqlite"
8
8
  setup do
9
9
  @adapter = Ardb::Adapter::Sqlite.new
@@ -19,19 +19,19 @@ class Ardb::Adapter::Sqlite
19
19
  FileUtils.rm(subject.db_file_path)
20
20
  end
21
21
 
22
- should "know its db_file_path" do
22
+ should "know its db file path" do
23
23
  exp_path = Ardb.config.root_path.join(Ardb.config.db.database).to_s
24
24
  assert_equal exp_path, subject.db_file_path
25
25
  end
26
26
 
27
27
  should "not implement the foreign key sql meths" do
28
- assert_raises(NotImplementedError) { subject.foreign_key_add_sql }
29
- assert_raises(NotImplementedError) { subject.foreign_key_drop_sql }
28
+ assert_raises(NotImplementedError){ subject.foreign_key_add_sql }
29
+ assert_raises(NotImplementedError){ subject.foreign_key_drop_sql }
30
30
  end
31
31
 
32
32
  # not currently implemented, see: https://github.com/redding/ardb/issues/29
33
33
  should "not implement the drop tables method" do
34
- assert_raises(NotImplementedError) { subject.drop_tables }
34
+ assert_raises(NotImplementedError){ subject.drop_tables }
35
35
  end
36
36
 
37
37
  end
@@ -7,7 +7,7 @@ module Ardb::AdapterSpy
7
7
  include Ardb::AdapterSpy
8
8
  end
9
9
 
10
- class BaseTests < Assert::Context
10
+ class UnitTests < Assert::Context
11
11
  desc "Ardb::AdapterSpy"
12
12
  setup do
13
13
  @adapter = MyAdapter.new
@@ -19,7 +19,7 @@ module Ardb::AdapterSpy
19
19
  should have_imeths :drop_tables, :load_schema, :drop_db, :create_db
20
20
 
21
21
  should "included the record spy instance methods" do
22
- assert_includes Ardb::AdapterSpy::InstanceMethods, subject.class.included_modules
22
+ assert_includes Ardb::AdapterSpy::InstanceMethods, subject.class
23
23
  end
24
24
 
25
25
  should "default all call counts to zero" do
@@ -45,7 +45,7 @@ module Ardb::AdapterSpy
45
45
 
46
46
  end
47
47
 
48
- class NewMethTests < BaseTests
48
+ class NewMethTests < UnitTests
49
49
  desc "`new` method"
50
50
  setup do
51
51
  @adapter_spy_class = Ardb::AdapterSpy.new do
@@ -56,7 +56,7 @@ module Ardb::AdapterSpy
56
56
  subject{ @adapter }
57
57
 
58
58
  should "build a new spy class and use any custom definition" do
59
- assert_includes Ardb::AdapterSpy, subject.class.included_modules
59
+ assert_includes Ardb::AdapterSpy, subject.class
60
60
  assert subject.respond_to? :name
61
61
  assert subject.respond_to? :name=
62
62
  end
@@ -3,7 +3,7 @@ require 'ardb'
3
3
 
4
4
  module Ardb
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb"
8
8
  subject{ Ardb }
9
9
  setup do
@@ -1,11 +1,13 @@
1
1
  require 'assert'
2
- require 'ns-options/assert_macros'
3
2
  require 'ardb'
4
3
 
4
+ require 'ns-options/assert_macros'
5
+
5
6
  class Ardb::Config
6
7
 
7
- class BaseTests < Assert::Context
8
+ class UnitTests < Assert::Context
8
9
  include NsOptions::AssertMacros
10
+
9
11
  desc "Ardb::Config"
10
12
  subject{ Ardb::Config }
11
13
 
@@ -21,8 +23,8 @@ class Ardb::Config
21
23
  assert_equal exp_path, subject.migrations_path
22
24
  end
23
25
 
24
- should "should use `db/schema.rb` as the default schema path" do
25
- exp_path = Pathname.new(TESTDB_PATH).join("db/schema.rb").to_s
26
+ should "should use `db/schema` as the default schema path" do
27
+ exp_path = Pathname.new(TESTDB_PATH).join("db/schema").to_s
26
28
  assert_equal exp_path, subject.schema_path
27
29
  end
28
30
 
@@ -37,7 +39,7 @@ class Ardb::Config
37
39
 
38
40
  end
39
41
 
40
- class DbTests < BaseTests
42
+ class DbTests < UnitTests
41
43
  desc "db namespace"
42
44
  subject{ Ardb::Config.db }
43
45
 
@@ -3,15 +3,15 @@ require 'ardb/migration_helpers'
3
3
 
4
4
  module Ardb::MigrationHelpers
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb migration helpers"
8
8
  subject{ Ardb::MigrationHelpers }
9
9
 
10
- should have_instance_methods :foreign_key, :drop_foreign_key, :remove_column_with_fk
10
+ should have_imeths :foreign_key, :drop_foreign_key, :remove_column_with_fk
11
11
 
12
12
  end
13
13
 
14
- class ForeignKeyTests < BaseTests
14
+ class ForeignKeyTests < UnitTests
15
15
  desc "ForeignKey handler"
16
16
  setup do
17
17
  @fk = ForeignKey.new('fromtbl', 'fromcol', 'totbl')
@@ -20,7 +20,7 @@ module Ardb::MigrationHelpers
20
20
 
21
21
  should have_readers :from_table, :from_column, :to_table, :to_column
22
22
  should have_readers :name, :adapter
23
- should have_instance_methods :add_sql, :drop_sql
23
+ should have_imeths :add_sql, :drop_sql
24
24
 
25
25
  should "know its from table/column and to table" do
26
26
  assert_equal 'fromtbl', subject.from_table
@@ -3,14 +3,14 @@ require 'ardb/runner/connect_command'
3
3
 
4
4
  class Ardb::Runner::CreateCommand
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb::Runner::ConnectCommand"
8
8
  setup do
9
9
  @cmd = Ardb::Runner::ConnectCommand.new
10
10
  end
11
11
  subject{ @cmd }
12
12
 
13
- should have_instance_methods :run
13
+ should have_imeths :run
14
14
 
15
15
  end
16
16
 
@@ -3,14 +3,14 @@ require 'ardb/runner/create_command'
3
3
 
4
4
  class Ardb::Runner::CreateCommand
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb::Runner::CreateCommand"
8
8
  setup do
9
9
  @cmd = Ardb::Runner::CreateCommand.new
10
10
  end
11
11
  subject{ @cmd }
12
12
 
13
- should have_instance_methods :run
13
+ should have_imeths :run
14
14
 
15
15
  end
16
16
 
@@ -3,14 +3,14 @@ require 'ardb/runner/drop_command'
3
3
 
4
4
  class Ardb::Runner::DropCommand
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb::Runner::DropCommand"
8
8
  setup do
9
9
  @cmd = Ardb::Runner::DropCommand.new
10
10
  end
11
11
  subject{ @cmd }
12
12
 
13
- should have_instance_methods :run
13
+ should have_imeths :run
14
14
 
15
15
  end
16
16
 
@@ -3,18 +3,18 @@ require 'ardb/runner/generate_command'
3
3
 
4
4
  class Ardb::Runner::GenerateCommand
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb::Runner::GenerateCommand"
8
8
  setup do
9
9
  @cmd = Ardb::Runner::GenerateCommand.new(['something'])
10
10
  end
11
11
  subject{ @cmd }
12
12
 
13
- should have_instance_methods :run, :migration_cmd
13
+ should have_imeths :run, :migration_cmd
14
14
 
15
15
  end
16
16
 
17
- class MigrationTests < BaseTests
17
+ class MigrationTests < UnitTests
18
18
  desc "Ardb::Runner::GenerateCommand::MigrationCommand"
19
19
  setup do
20
20
  @cmd = Ardb::Runner::GenerateCommand::MigrationCommand.new('a_migration')
@@ -3,18 +3,17 @@ require 'ardb/runner/migrate_command'
3
3
 
4
4
  class Ardb::Runner::MigrateCommand
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb::Runner::MigrateCommand"
8
8
  setup do
9
9
  @cmd = Ardb::Runner::MigrateCommand.new
10
10
  end
11
11
  subject{ @cmd }
12
12
 
13
- should have_readers :migrations_path, :schema_file_path, :version, :verbose
13
+ should have_readers :migrations_path, :version, :verbose
14
14
 
15
- should "use the config's migrations and schema file paths" do
15
+ should "use the config's migrations path" do
16
16
  assert_equal Ardb.config.migrations_path, subject.migrations_path
17
- assert_equal Ardb.config.schema_path, subject.schema_file_path
18
17
  end
19
18
 
20
19
  should "not target a specific version by default" do
@@ -27,7 +26,7 @@ class Ardb::Runner::MigrateCommand
27
26
 
28
27
  end
29
28
 
30
- class VersionTests < BaseTests
29
+ class VersionTests < UnitTests
31
30
  desc "with a version ENV setting"
32
31
  setup do
33
32
  ENV["VERSION"] = '12345'
@@ -43,7 +42,7 @@ class Ardb::Runner::MigrateCommand
43
42
 
44
43
  end
45
44
 
46
- class VerboseTests < BaseTests
45
+ class VerboseTests < UnitTests
47
46
  desc "with a verbose ENV setting"
48
47
  setup do
49
48
  ENV["VERBOSE"] = 'no'
@@ -1,11 +1,12 @@
1
1
  require 'assert'
2
- require 'pathname'
3
- require 'active_record'
4
2
  require 'ardb/runner'
5
3
 
4
+ require 'active_record'
5
+ require 'pathname'
6
+
6
7
  class Ardb::Runner
7
8
 
8
- class BaseTests < Assert::Context
9
+ class UnitTests < Assert::Context
9
10
  desc "Ardb::Runner"
10
11
  setup do
11
12
  @runner = Ardb::Runner.new(['null', 1, 2], 'some' => 'opts')
@@ -22,7 +23,7 @@ class Ardb::Runner
22
23
 
23
24
  end
24
25
 
25
- class RunTests < BaseTests
26
+ class RunTests < UnitTests
26
27
  desc "when running a command"
27
28
  setup do
28
29
  Ardb::Adapter.reset
@@ -3,7 +3,7 @@ require 'ardb/test_helpers'
3
3
 
4
4
  module Ardb::TestHelpers
5
5
 
6
- class BaseTests < Assert::Context
6
+ class UnitTests < Assert::Context
7
7
  desc "Ardb test helpers"
8
8
  subject{ Ardb::TestHelpers }
9
9
 
@@ -11,7 +11,7 @@ module Ardb::TestHelpers
11
11
 
12
12
  end
13
13
 
14
- class UsageTests < BaseTests
14
+ class UsageTests < UnitTests
15
15
  setup do
16
16
  @adapter_spy_class = Ardb::AdapterSpy.new
17
17
  @orig_ardb_adapter = Ardb.adapter
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ardb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 79
4
+ hash: 75
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 20
8
+ - 21
9
9
  - 0
10
- version: 0.20.0
10
+ version: 0.21.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,25 +16,40 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-05-07 00:00:00 Z
19
+ date: 2014-06-13 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- hash: 3
27
+ hash: 23
28
28
  segments:
29
29
  - 2
30
- - 0
31
- version: "2.0"
30
+ - 10
31
+ version: "2.10"
32
+ version_requirements: *id001
32
33
  type: :development
33
- requirement: *id001
34
- prerelease: false
35
34
  name: assert
35
+ prerelease: false
36
+ - !ruby/object:Gem::Dependency
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 13
43
+ segments:
44
+ - 1
45
+ - 1
46
+ version: "1.1"
47
+ version_requirements: *id002
48
+ type: :development
49
+ name: assert-mocha
50
+ prerelease: false
36
51
  - !ruby/object:Gem::Dependency
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
52
+ requirement: &id003 !ruby/object:Gem::Requirement
38
53
  none: false
39
54
  requirements:
40
55
  - - ~>
@@ -44,12 +59,12 @@ dependencies:
44
59
  - 3
45
60
  - 2
46
61
  version: "3.2"
62
+ version_requirements: *id003
47
63
  type: :runtime
48
- requirement: *id002
49
- prerelease: false
50
64
  name: activerecord
65
+ prerelease: false
51
66
  - !ruby/object:Gem::Dependency
52
- version_requirements: &id003 !ruby/object:Gem::Requirement
67
+ requirement: &id004 !ruby/object:Gem::Requirement
53
68
  none: false
54
69
  requirements:
55
70
  - - ~>
@@ -59,12 +74,12 @@ dependencies:
59
74
  - 3
60
75
  - 2
61
76
  version: "3.2"
77
+ version_requirements: *id004
62
78
  type: :runtime
63
- requirement: *id003
64
- prerelease: false
65
79
  name: activesupport
80
+ prerelease: false
66
81
  - !ruby/object:Gem::Dependency
67
- version_requirements: &id004 !ruby/object:Gem::Requirement
82
+ requirement: &id005 !ruby/object:Gem::Requirement
68
83
  none: false
69
84
  requirements:
70
85
  - - ~>
@@ -74,10 +89,25 @@ dependencies:
74
89
  - 1
75
90
  - 1
76
91
  version: "1.1"
92
+ version_requirements: *id005
77
93
  type: :runtime
78
- requirement: *id004
79
- prerelease: false
80
94
  name: ns-options
95
+ prerelease: false
96
+ - !ruby/object:Gem::Dependency
97
+ requirement: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ hash: 7
103
+ segments:
104
+ - 2
105
+ - 2
106
+ version: "2.2"
107
+ version_requirements: *id006
108
+ type: :runtime
109
+ name: scmd
110
+ prerelease: false
81
111
  description: Activerecord database tools.
82
112
  email:
83
113
  - kelly@kellyredding.com
@@ -176,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
206
  requirements: []
177
207
 
178
208
  rubyforge_project:
179
- rubygems_version: 1.8.15
209
+ rubygems_version: 1.8.29
180
210
  signing_key:
181
211
  specification_version: 3
182
212
  summary: Activerecord database tools.