sequel-rails 0.9.11 → 0.9.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +24 -41
  4. data/History.md +8 -0
  5. data/README.md +38 -3
  6. data/ci/rails-3.2.gemfile +3 -0
  7. data/ci/rails-5.0.gemfile +25 -0
  8. data/lib/action_dispatch/middleware/session/sequel_store.rb +1 -1
  9. data/lib/generators/sequel/migration/migration_generator.rb +32 -16
  10. data/lib/sequel_rails.rb +23 -0
  11. data/lib/sequel_rails/configuration.rb +5 -4
  12. data/lib/sequel_rails/db_config.rb +19 -19
  13. data/lib/sequel_rails/railtie.rb +19 -9
  14. data/lib/sequel_rails/railties/controller_runtime.rb +2 -1
  15. data/lib/sequel_rails/railties/database.rake +30 -30
  16. data/lib/sequel_rails/railties/log_subscriber.rb +4 -2
  17. data/lib/sequel_rails/railties/spring_support.rb +13 -0
  18. data/lib/sequel_rails/sequel/database/active_support_notification.rb +2 -2
  19. data/lib/sequel_rails/shellwords.rb +1 -1
  20. data/lib/sequel_rails/storage.rb +1 -1
  21. data/lib/sequel_rails/storage/abstract.rb +3 -4
  22. data/lib/sequel_rails/storage/postgres.rb +0 -1
  23. data/lib/sequel_rails/version.rb +1 -1
  24. data/rubocop-todo.yml +9 -0
  25. data/sequel-rails.gemspec +3 -3
  26. data/spec/internal/config/database.yml +6 -0
  27. data/spec/internal/db/migrate/1273253849_add_twitter_handle_to_users.rb +0 -2
  28. data/spec/lib/generators/sequel/migration_spec.rb +0 -1
  29. data/spec/lib/generators/sequel/session_migration_spec.rb +0 -1
  30. data/spec/lib/sequel_rails/configuration_spec.rb +12 -27
  31. data/spec/lib/sequel_rails/db_config_spec.rb +26 -20
  32. data/spec/lib/sequel_rails/railtie_spec.rb +4 -4
  33. data/spec/lib/sequel_rails/railties/database_rake_spec.rb +18 -19
  34. data/spec/lib/sequel_rails/storage/postgres_spec.rb +1 -1
  35. metadata +15 -7
@@ -15,6 +15,7 @@ require 'sequel_rails/configuration'
15
15
  require 'sequel_rails/migrations'
16
16
  require 'sequel_rails/railties/log_subscriber'
17
17
  require 'sequel_rails/railties/i18n_support'
18
+ require 'sequel_rails/railties/spring_support'
18
19
  require 'sequel_rails/railties/controller_runtime'
19
20
  require 'sequel_rails/sequel/database/active_support_notification'
20
21
  require 'action_dispatch/middleware/session/sequel_store'
@@ -36,10 +37,16 @@ module SequelRails
36
37
  config.sequel = ::SequelRails::Configuration.new
37
38
 
38
39
  rake_tasks do |app|
39
- load 'sequel_rails/railties/database.rake' if app.config.sequel.load_database_tasks
40
+ load_tasks_config = app.config.sequel.load_database_tasks
41
+ SequelRails::TASK_NAMESPACE =
42
+ case load_tasks_config
43
+ when Symbol, String then load_tasks_config.to_sym
44
+ else :db
45
+ end
46
+ load 'sequel_rails/railties/database.rake' if load_tasks_config
40
47
  end
41
48
 
42
- initializer 'sequel.load_hooks' do |app|
49
+ initializer 'sequel.load_hooks' do
43
50
  ::ActiveSupport.run_load_hooks(:sequel, ::Sequel::Model)
44
51
  end
45
52
 
@@ -48,7 +55,7 @@ module SequelRails
48
55
  end
49
56
 
50
57
  initializer 'sequel.logger' do |app|
51
- setup_logger app, ::Rails.logger
58
+ app.config.sequel.logger ||= ::Rails.logger
52
59
  end
53
60
 
54
61
  initializer 'sequel.i18n_support' do |_app|
@@ -61,8 +68,15 @@ module SequelRails
61
68
  end
62
69
 
63
70
  initializer 'sequel.connect' do |app|
64
- unless app.config.sequel[:skip_connect]
65
- ::SequelRails.setup ::Rails.env
71
+ ::SequelRails.setup ::Rails.env unless app.config.sequel[:skip_connect]
72
+ end
73
+
74
+ initializer 'sequel.spring' do |app|
75
+ if defined?(::Spring::Application)
76
+ class ::Spring::Application
77
+ include ::SequelRails::SpringSupport
78
+ alias_method_chain :disconnect_database, :sequel
79
+ end
66
80
  end
67
81
  end
68
82
 
@@ -90,9 +104,5 @@ module SequelRails
90
104
  require 'sequel_rails/railties/controller_runtime'
91
105
  ActionController::Base.send :include, SequelRails::Railties::ControllerRuntime
92
106
  end
93
-
94
- def setup_logger(app, logger)
95
- app.config.sequel.logger = logger
96
- end
97
107
  end
98
108
  end
@@ -35,7 +35,8 @@ module SequelRails
35
35
 
36
36
  module ClassMethods
37
37
  def log_process_action(payload)
38
- messages, db_runtime = super, payload[:db_runtime]
38
+ messages = super
39
+ db_runtime = payload[:db_runtime]
39
40
  messages << format('Models: %.1fms', db_runtime.to_f) if db_runtime
40
41
  messages
41
42
  end
@@ -1,17 +1,19 @@
1
1
  require 'sequel_rails/storage'
2
2
 
3
+ sequel_rails_namespace = SequelRails::TASK_NAMESPACE
4
+
3
5
  # TODO: DRY these up
4
- namespace :db do
6
+ namespace sequel_rails_namespace do
5
7
  def db_for_current_env
6
8
  @db_for_current_env ||= {}
7
9
  @db_for_current_env[Rails.env] ||= ::SequelRails.setup(Rails.env)
8
10
  end
9
11
 
10
12
  # desc "Raises an error if there are pending migrations"
11
- task :abort_if_pending_migrations => [:environment, 'db:migrate:load'] do
13
+ task :abort_if_pending_migrations => [:environment, "#{sequel_rails_namespace}:migrate:load"] do
12
14
  if SequelRails::Migrations.pending_migrations?
13
15
  warn 'You have pending migrations:'
14
- abort 'Run `rake db:migrate` to update your database then try again.'
16
+ abort "Run `rake #{sequel_rails_namespace}:migrate` to update your database then try again."
15
17
  end
16
18
  end
17
19
 
@@ -24,7 +26,7 @@ namespace :db do
24
26
  file << db_for_current_env.dump_schema_migration(:same_db => true)
25
27
  file << SequelRails::Migrations.dump_schema_information(:sql => false)
26
28
  end
27
- Rake::Task['db:schema:dump'].reenable
29
+ Rake::Task["#{sequel_rails_namespace}:schema:dump"].reenable
28
30
  end
29
31
 
30
32
  desc 'Load a schema.rb file into the database'
@@ -35,7 +37,7 @@ namespace :db do
35
37
  load(file)
36
38
  ::Sequel::Migration.descendants.each { |m| m.apply(db_for_current_env, :up) }
37
39
  else
38
- abort "#{file} doesn't exist yet. Run 'rake db:migrate' to create it, then try again."
40
+ abort '#{file} doesn\'t exist yet. Run \'rake #{sequel_rails_namespace}:migrate\' to create it, then try again.'
39
41
  end
40
42
  end
41
43
  end
@@ -54,7 +56,7 @@ namespace :db do
54
56
  abort "Could not dump structure for #{args.env}."
55
57
  end
56
58
 
57
- Rake::Task['db:structure:dump'].reenable
59
+ Rake::Task["#{sequel_rails_namespace}:structure:dump"].reenable
58
60
  end
59
61
 
60
62
  task :load, [:env] => :environment do |_t, args|
@@ -70,9 +72,9 @@ namespace :db do
70
72
  task :dump => :environment do
71
73
  case (SequelRails.configuration.schema_format ||= :ruby)
72
74
  when :ruby
73
- Rake::Task['db:schema:dump'].invoke
75
+ Rake::Task["#{sequel_rails_namespace}:schema:dump"].invoke
74
76
  when :sql
75
- Rake::Task['db:structure:dump'].invoke
77
+ Rake::Task["#{sequel_rails_namespace}:structure:dump"].invoke
76
78
  else
77
79
  abort "unknown schema format #{SequelRails.configuration.schema_format}"
78
80
  end
@@ -81,9 +83,9 @@ namespace :db do
81
83
  task :load => :environment do
82
84
  case (SequelRails.configuration.schema_format ||= :ruby)
83
85
  when :ruby
84
- Rake::Task['db:schema:load'].invoke
86
+ Rake::Task["#{sequel_rails_namespace}:schema:load"].invoke
85
87
  when :sql
86
- Rake::Task['db:structure:load'].invoke
88
+ Rake::Task["#{sequel_rails_namespace}:structure:load"].invoke
87
89
  else
88
90
  abort "unknown schema format #{SequelRails.configuration.schema_format}"
89
91
  end
@@ -129,23 +131,23 @@ namespace :db do
129
131
  desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.'
130
132
  task :redo => :load do
131
133
  if ENV['VERSION']
132
- Rake::Task['db:migrate:down'].invoke
133
- Rake::Task['db:migrate:up'].invoke
134
+ Rake::Task["#{sequel_rails_namespace}:migrate:down"].invoke
135
+ Rake::Task["#{sequel_rails_namespace}:migrate:up"].invoke
134
136
  else
135
- Rake::Task['db:rollback'].invoke
136
- Rake::Task['db:migrate'].invoke
137
+ Rake::Task["#{sequel_rails_namespace}:rollback"].invoke
138
+ Rake::Task["#{sequel_rails_namespace}:migrate"].invoke
137
139
  end
138
140
  end
139
141
 
140
142
  desc 'Resets your database using your migrations for the current environment'
141
- task :reset => %w(db:drop db:create db:migrate)
143
+ task :reset => %W(#{sequel_rails_namespace}:drop #{sequel_rails_namespace}:create #{sequel_rails_namespace}:migrate)
142
144
 
143
145
  desc 'Runs the "up" for a given migration VERSION.'
144
146
  task :up => :load do
145
147
  version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
146
148
  fail 'VERSION is required' unless version
147
149
  SequelRails::Migrations.migrate_up!(version)
148
- Rake::Task['db:dump'].invoke if SequelRails.configuration.schema_dump
150
+ Rake::Task["#{sequel_rails_namespace}:dump"].invoke if SequelRails.configuration.schema_dump
149
151
  end
150
152
 
151
153
  desc 'Runs the "down" for a given migration VERSION.'
@@ -153,14 +155,14 @@ namespace :db do
153
155
  version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
154
156
  fail 'VERSION is required' unless version
155
157
  SequelRails::Migrations.migrate_down!(version)
156
- Rake::Task['db:dump'].invoke if SequelRails.configuration.schema_dump
158
+ Rake::Task["#{sequel_rails_namespace}:dump"].invoke if SequelRails.configuration.schema_dump
157
159
  end
158
160
  end
159
161
 
160
162
  desc 'Migrate the database to the latest version'
161
163
  task :migrate => 'migrate:load' do
162
164
  SequelRails::Migrations.migrate_up!(ENV['VERSION'] ? ENV['VERSION'].to_i : nil)
163
- Rake::Task['db:dump'].invoke if SequelRails.configuration.schema_dump
165
+ Rake::Task["#{sequel_rails_namespace}:dump"].invoke if SequelRails.configuration.schema_dump
164
166
  end
165
167
 
166
168
  desc 'Rollback the latest migration file or down to specified VERSION=x'
@@ -171,7 +173,7 @@ namespace :db do
171
173
  SequelRails::Migrations.previous_migration
172
174
  end
173
175
  SequelRails::Migrations.migrate_down! version
174
- Rake::Task['db:dump'].invoke if SequelRails.configuration.schema_dump
176
+ Rake::Task["#{sequel_rails_namespace}:dump"].invoke if SequelRails.configuration.schema_dump
175
177
  end
176
178
 
177
179
  desc 'Load the seed data from db/seeds.rb'
@@ -181,10 +183,10 @@ namespace :db do
181
183
  end
182
184
 
183
185
  desc 'Create the database, load the schema, and initialize with the seed data'
184
- task :setup => %w(db:create db:load db:seed)
186
+ task :setup => %W(#{sequel_rails_namespace}:create #{sequel_rails_namespace}:load #{sequel_rails_namespace}:seed)
185
187
 
186
188
  desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.'
187
- task :reset => %w(db:drop db:setup)
189
+ task :reset => %W(#{sequel_rails_namespace}:drop #{sequel_rails_namespace}:setup)
188
190
 
189
191
  desc 'Forcibly close any open connections to the current env database (PostgreSQL specific)'
190
192
  task :force_close_open_connections, [:env] => :environment do |_t, args|
@@ -193,18 +195,16 @@ namespace :db do
193
195
  end
194
196
 
195
197
  namespace :test do
196
- desc 'Prepare test database (ensure all migrations ran, drop and re-create database then load schema). This task can be run in the same invocation as other task (eg: rake db:migrate db:test:prepare).'
197
- task :prepare => 'db:abort_if_pending_migrations' do
198
+ desc "Prepare test database (ensure all migrations ran, drop and re-create database then load schema). This task can be run in the same invocation as other task (eg: rake #{sequel_rails_namespace}:migrate #{sequel_rails_namespace}:test:prepare)."
199
+ task :prepare => "#{sequel_rails_namespace}:abort_if_pending_migrations" do
198
200
  previous_env, Rails.env = Rails.env, 'test'
199
- Rake::Task['db:drop'].execute
200
- Rake::Task['db:create'].execute
201
- Rake::Task['db:load'].execute
202
- Sequel::DATABASES.each do |db|
203
- db.disconnect
204
- end
201
+ Rake::Task["#{sequel_rails_namespace}:drop"].execute
202
+ Rake::Task["#{sequel_rails_namespace}:create"].execute
203
+ Rake::Task["#{sequel_rails_namespace}:load"].execute
204
+ Sequel::DATABASES.each(&:disconnect)
205
205
  Rails.env = previous_env
206
206
  end
207
207
  end
208
208
  end
209
209
 
210
- task 'test:prepare' => 'db:test:prepare'
210
+ task 'test:prepare' => "#{sequel_rails_namespace}:test:prepare"
@@ -18,12 +18,14 @@ module SequelRails
18
18
  end
19
19
 
20
20
  def self.reset_runtime
21
- previous, self.runtime = runtime, 0
21
+ previous = runtime
22
+ self.runtime = 0
22
23
  previous
23
24
  end
24
25
 
25
26
  def self.reset_count
26
- previous, self.count = count, 0
27
+ previous = count
28
+ self.count = 0
27
29
  previous
28
30
  end
29
31
 
@@ -0,0 +1,13 @@
1
+ module SequelRails
2
+ module SpringSupport
3
+ def disconnect_database_with_sequel
4
+ Sequel::DATABASES.each { |db| db.disconnect } if sequel_configured?
5
+ disconnect_database_without_sequel
6
+ end
7
+
8
+ private
9
+ def sequel_configured?
10
+ defined?(Sequel::DATABASES)
11
+ end
12
+ end
13
+ end
@@ -5,7 +5,7 @@ module Sequel
5
5
  class Database
6
6
  def log_yield(sql, args = nil)
7
7
  sql_for_log = args ? "#{sql}; #{args.inspect}" : sql
8
- start = Time.now
8
+ start = Time.now.to_f
9
9
  begin
10
10
  ::ActiveSupport::Notifications.instrument(
11
11
  'sql.sequel',
@@ -19,7 +19,7 @@ module Sequel
19
19
  log_exception(e, sql_for_log) unless @loggers.empty?
20
20
  raise
21
21
  ensure
22
- log_duration(Time.now - start, sql_for_log) unless e || @loggers.empty?
22
+ log_duration(Time.now.to_f - start, sql_for_log) unless e || @loggers.empty?
23
23
  end
24
24
  end
25
25
  end
@@ -16,7 +16,7 @@ module SequelRails
16
16
  # Treat multibyte characters as is. It is caller's responsibility
17
17
  # to encode the string in the right encoding for the shell
18
18
  # environment.
19
- str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/, '\\\\\\1')
19
+ str.gsub!(%r{([^A-Za-z0-9_\-.,:/@\n])}, '\\\\\\1')
20
20
 
21
21
  # A LF cannot be escaped with a backslash because a backslash + LF
22
22
  # combo is regarded as line continuation and simply ignored.
@@ -43,7 +43,7 @@ module SequelRails
43
43
  end
44
44
 
45
45
  def self.adapter_for(config_or_env)
46
- config = if config_or_env.kind_of? Hash
46
+ config = if config_or_env.is_a? Hash
47
47
  config_or_env
48
48
  else
49
49
  ::SequelRails.configuration.environments[config_or_env.to_s]
@@ -94,10 +94,9 @@ module SequelRails
94
94
  private
95
95
 
96
96
  def add_option(commands, name, value)
97
- if value.present?
98
- separator = name[0, 2] == '--' ? '=' : ' '
99
- commands << "#{name}#{separator}#{value}"
100
- end
97
+ return unless value.present?
98
+ separator = name[0, 2] == '--' ? '=' : ' '
99
+ commands << "#{name}#{separator}#{value}"
101
100
  end
102
101
 
103
102
  def add_flag(commands, flag)
@@ -31,7 +31,6 @@ module SequelRails
31
31
  with_pgpassword do
32
32
  commands = ['pg_dump']
33
33
  add_connection_settings commands
34
- add_flag commands, '-i'
35
34
  add_flag commands, '-s'
36
35
  add_flag commands, '-x'
37
36
  add_flag commands, '-O'
@@ -1,3 +1,3 @@
1
1
  module SequelRails
2
- VERSION = '0.9.11'
2
+ VERSION = '0.9.12'
3
3
  end
@@ -25,3 +25,12 @@ MethodLength:
25
25
 
26
26
  TrailingComma:
27
27
  Enabled: false
28
+
29
+ Metrics/AbcSize:
30
+ Enabled: false
31
+
32
+ Metrics/ClassLength:
33
+ Enabled: false
34
+
35
+ Style/EachWithObject:
36
+ Enabled: false
@@ -41,8 +41,8 @@ Gem::Specification.new do |s|
41
41
  s.add_development_dependency 'generator_spec'
42
42
  s.add_development_dependency 'rake', '>= 0.8.7'
43
43
  s.add_development_dependency 'rspec', '~> 3.1'
44
- s.add_development_dependency 'rspec-rails', '~> 3.1'
45
- s.add_development_dependency 'rubocop', '~> 0.28.0' unless RUBY_VERSION < '1.9.2'
46
- s.add_development_dependency 'ammeter', '1.1.2'
44
+ s.add_development_dependency 'rspec-rails', '~> 3.1', '< 3.3'
45
+ s.add_development_dependency 'rubocop', '~> 0.33.0' unless RUBY_VERSION < '1.9.2'
46
+ s.add_development_dependency 'ammeter', '1.1.3'
47
47
  s.add_development_dependency 'test-unit' if RUBY_VERSION >= '2.2.0'
48
48
  end
@@ -1,7 +1,13 @@
1
1
  test:
2
2
  adapter: "<%= ENV["TEST_ADAPTER"] || "postgresql" %>"
3
3
  database: "<%= ENV["TEST_DATABASE"] || "sequel_rails_test" %>"
4
+ <% if ENV['TEST_ADAPTER'] != 'sqlite3' %>
4
5
  owner: "<%= ENV["TEST_OWNER"] || ENV["USER"] %>"
5
6
  user: "<%= ENV["TEST_USERNAME"] || ENV["USER"] %>"
6
7
  password: "<%= ENV["TEST_PASSWORD"] %>"
8
+ <% end %>
9
+ <% if ENV['TEST_ADAPTER'] =~ /mysql/ %>
10
+ encoding: "<%= ENV["TEST_ENCODING"] || "utf8" %>"
11
+ <% elsif ENV['TEST_ADAPTER'] =~ /postgres/ %>
7
12
  encoding: "<%= ENV["TEST_ENCODING"] || "unicode" %>"
13
+ <% end %>
@@ -1,9 +1,7 @@
1
1
  Sequel.migration do
2
-
3
2
  change do
4
3
  alter_table :users do
5
4
  add_column :twitter_handle, String, :text => true
6
5
  end
7
6
  end
8
-
9
7
  end
@@ -252,5 +252,4 @@ describe Sequel::Generators::MigrationGenerator do
252
252
  end
253
253
  end
254
254
  end
255
-
256
255
  end
@@ -37,5 +37,4 @@ describe Sequel::Generators::SessionMigrationGenerator do
37
37
  end
38
38
  }
39
39
  end
40
-
41
40
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SequelRails do
4
-
5
4
  describe '.setup' do
6
5
  let(:environment) { 'development' }
7
6
  let(:configuration) { SequelRails::Configuration.new }
@@ -12,11 +11,9 @@ describe SequelRails do
12
11
  SequelRails.setup environment
13
12
  end
14
13
  end
15
-
16
14
  end
17
15
 
18
16
  describe SequelRails::Configuration do
19
-
20
17
  describe '#schema_dump' do
21
18
  before { allow(Rails).to receive(:env).and_return(environment) }
22
19
  subject { described_class.new }
@@ -136,11 +133,10 @@ describe SequelRails::Configuration do
136
133
  subject { described_class.new.tap { |config| config.raw = environments } }
137
134
 
138
135
  context 'when stubbing SequelRails.jruby?' do
139
-
140
136
  before { allow(SequelRails).to receive(:jruby?).and_return(is_jruby) }
141
137
 
142
138
  shared_examples 'max_connections' do
143
- context 'with max_connections config option' do
139
+ context 'with max_connections=7 config option' do
144
140
  let(:max_connections) { 31_337 }
145
141
  before do
146
142
  environments[environment]['max_connections'] = 7
@@ -150,7 +146,7 @@ describe SequelRails::Configuration do
150
146
  it 'overrides the option from the configuration' do
151
147
  expect(::Sequel).to receive(:connect) do |hash_or_url, *_|
152
148
  if hash_or_url.is_a? Hash
153
- expect(hash_or_url['max_connections']).to eq(max_connections)
149
+ expect(hash_or_url[:max_connections]).to eq(max_connections)
154
150
  else
155
151
  expect(hash_or_url).to include("max_connections=#{max_connections}")
156
152
  end
@@ -166,7 +162,7 @@ describe SequelRails::Configuration do
166
162
  it 'uses the value' do
167
163
  expect(::Sequel).to receive(:connect) do |hash_or_url, *_|
168
164
  if hash_or_url.is_a? Hash
169
- expect(hash_or_url['max_connections']).to eq(7)
165
+ expect(hash_or_url[:max_connections]).to eq(7)
170
166
  else
171
167
  expect(hash_or_url).to include('max_connections=7')
172
168
  end
@@ -228,7 +224,6 @@ describe SequelRails::Configuration do
228
224
  end
229
225
 
230
226
  context 'for a postgres connection' do
231
-
232
227
  shared_examples 'search_path' do
233
228
  context 'with search_path config option' do
234
229
  let(:search_path) { %w(secret private public) }
@@ -240,7 +235,7 @@ describe SequelRails::Configuration do
240
235
  it 'overrides the option from the configuration' do
241
236
  expect(::Sequel).to receive(:connect) do |hash_or_url, *_|
242
237
  if hash_or_url.is_a? Hash
243
- expect(hash_or_url['search_path']).to eq(search_path)
238
+ expect(hash_or_url[:search_path]).to eq(search_path)
244
239
  else
245
240
  expect(hash_or_url).to include('search_path=secret%2Cprivate%2Cpublic')
246
241
  end
@@ -253,7 +248,6 @@ describe SequelRails::Configuration do
253
248
  let(:environment) { 'development' }
254
249
 
255
250
  context 'in C-Ruby' do
256
-
257
251
  include_examples 'max_connections'
258
252
  include_examples 'search_path'
259
253
  include_examples 'with DATABASE_URL in ENV'
@@ -262,15 +256,13 @@ describe SequelRails::Configuration do
262
256
 
263
257
  it 'produces a sane config without url' do
264
258
  expect(::Sequel).to receive(:connect) do |hash|
265
- expect(hash['adapter']).to eq('postgres')
259
+ expect(hash[:adapter]).to eq('postgres')
266
260
  end
267
261
  subject.connect environment
268
262
  end
269
-
270
263
  end
271
264
 
272
265
  context 'in JRuby' do
273
-
274
266
  include_examples 'max_connections'
275
267
  include_examples 'search_path'
276
268
  include_examples 'with DATABASE_URL in ENV'
@@ -280,34 +272,30 @@ describe SequelRails::Configuration do
280
272
  it 'produces an adapter config with a url' do
281
273
  expect(::Sequel).to receive(:connect) do |url, hash|
282
274
  expect(url).to start_with('jdbc:postgresql://')
283
- expect(hash['adapter']).to eq('jdbc:postgresql')
284
- expect(hash['host']).to eq('127.0.0.1')
275
+ expect(hash[:adapter]).to eq('jdbc:postgresql')
276
+ expect(hash[:host]).to eq('127.0.0.1')
285
277
  end
286
278
  subject.connect environment
287
279
  end
288
280
 
289
281
  context 'when url is already given' do
290
-
291
282
  let(:environment) { 'url_already_constructed' }
292
283
 
293
284
  it 'does not change the url' do
294
285
  expect(::Sequel).to receive(:connect) do |url, hash|
295
286
  expect(url).to eq('jdbc:adaptername://HOST/DB?user=U&password=P&ssl=true&sslfactory=sslFactoryOption')
296
- expect(hash['adapter']).to eq('jdbc:adaptername')
287
+ expect(hash[:adapter]).to eq('jdbc:adaptername')
297
288
  end
298
289
  subject.connect environment
299
290
  end
300
-
301
291
  end
302
292
  end
303
293
  end
304
294
 
305
295
  context 'for a mysql connection' do
306
-
307
296
  let(:environment) { 'remote' }
308
297
 
309
298
  context 'in C-Ruby' do
310
-
311
299
  include_examples 'max_connections'
312
300
  include_examples 'with DATABASE_URL in ENV'
313
301
 
@@ -315,14 +303,13 @@ describe SequelRails::Configuration do
315
303
 
316
304
  it 'produces a config without url' do
317
305
  expect(::Sequel).to receive(:connect) do |hash|
318
- expect(hash['adapter']).to eq('mysql')
306
+ expect(hash[:adapter]).to eq('mysql')
319
307
  end
320
308
  subject.connect environment
321
309
  end
322
310
  end
323
311
 
324
312
  context 'in JRuby' do
325
-
326
313
  include_examples 'max_connections'
327
314
  include_examples 'with DATABASE_URL in ENV'
328
315
 
@@ -331,20 +318,19 @@ describe SequelRails::Configuration do
331
318
  it 'produces a jdbc mysql config' do
332
319
  expect(::Sequel).to receive(:connect) do |url, hash|
333
320
  expect(url).to start_with('jdbc:mysql://')
334
- expect(hash['adapter']).to eq('jdbc:mysql')
335
- expect(hash['database']).to eq('sequel_rails_test_storage_remote')
321
+ expect(hash[:adapter]).to eq('jdbc:mysql')
322
+ expect(hash[:database]).to eq('sequel_rails_test_storage_remote')
336
323
  end
337
324
  subject.connect environment
338
325
  end
339
326
 
340
327
  context 'when url is already given' do
341
-
342
328
  let(:environment) { 'url_already_constructed' }
343
329
 
344
330
  it 'does not change the url' do
345
331
  expect(::Sequel).to receive(:connect) do |url, hash|
346
332
  expect(url).to eq('jdbc:adaptername://HOST/DB?user=U&password=P&ssl=true&sslfactory=sslFactoryOption')
347
- expect(hash['adapter']).to eq('jdbc:adaptername')
333
+ expect(hash[:adapter]).to eq('jdbc:adaptername')
348
334
  end
349
335
  subject.connect environment
350
336
  end
@@ -363,6 +349,5 @@ describe SequelRails::Configuration do
363
349
  subject.connect environment
364
350
  end
365
351
  end
366
-
367
352
  end
368
353
  end