sequel-rails 0.7.0 → 0.8.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +13 -0
  4. data/.travis.yml +15 -43
  5. data/Gemfile +10 -10
  6. data/History.md +8 -0
  7. data/README.md +36 -0
  8. data/Rakefile +70 -2
  9. data/ci/rails-3.2.gemfile +15 -12
  10. data/ci/rails-4.0.gemfile +12 -12
  11. data/config.ru +1 -1
  12. data/lib/generators/sequel/migration/migration_generator.rb +10 -13
  13. data/lib/generators/sequel/model/model_generator.rb +11 -9
  14. data/lib/generators/sequel/observer/observer_generator.rb +6 -7
  15. data/lib/generators/sequel/session_migration/session_migration_generator.rb +30 -0
  16. data/lib/generators/sequel/session_migration/templates/migration.rb.erb +10 -0
  17. data/lib/generators/sequel.rb +9 -13
  18. data/lib/sequel-rails.rb +1 -1
  19. data/lib/sequel_rails/configuration.rb +29 -35
  20. data/lib/sequel_rails/migrations.rb +4 -4
  21. data/lib/sequel_rails/railtie.rb +16 -20
  22. data/lib/sequel_rails/railties/controller_runtime.rb +2 -8
  23. data/lib/sequel_rails/railties/database.rake +42 -46
  24. data/lib/sequel_rails/railties/i18n_support.rb +0 -2
  25. data/lib/sequel_rails/railties/legacy_model_config.rb +1 -1
  26. data/lib/sequel_rails/railties/log_subscriber.rb +5 -9
  27. data/lib/sequel_rails/sequel/database/active_support_notification.rb +4 -6
  28. data/lib/sequel_rails/sequel/plugins/rails_extensions.rb +2 -3
  29. data/lib/sequel_rails/session_store.rb +6 -42
  30. data/lib/sequel_rails/shellwords.rb +3 -3
  31. data/lib/sequel_rails/storage/abstract.rb +14 -16
  32. data/lib/sequel_rails/storage/jdbc.rb +8 -10
  33. data/lib/sequel_rails/storage/mysql.rb +13 -15
  34. data/lib/sequel_rails/storage/postgres.rb +42 -45
  35. data/lib/sequel_rails/storage/sqlite.rb +0 -1
  36. data/lib/sequel_rails/storage.rb +10 -10
  37. data/lib/sequel_rails/version.rb +1 -1
  38. data/lib/sequel_rails.rb +3 -3
  39. data/rubocop-todo.yml +24 -0
  40. data/sequel-rails.gemspec +21 -19
  41. data/spec/internal/Rakefile +2 -2
  42. data/spec/internal/config/initializers/session.rb +1 -1
  43. data/spec/internal/db/schema.rb.init +6 -0
  44. data/spec/lib/generators/sequel/migration_spec.rb +77 -77
  45. data/spec/lib/generators/sequel/session_migration_spec.rb +41 -0
  46. data/spec/lib/sequel_rails/configuration_spec.rb +161 -161
  47. data/spec/lib/sequel_rails/jdbc_spec.rb +4 -4
  48. data/spec/lib/sequel_rails/migrations_spec.rb +29 -29
  49. data/spec/lib/sequel_rails/railtie_spec.rb +31 -29
  50. data/spec/lib/sequel_rails/railties/database_rake_spec.rb +16 -15
  51. data/spec/lib/sequel_rails/railties/log_subscriber_spec.rb +6 -6
  52. data/spec/lib/sequel_rails/storage/mysql_spec.rb +31 -31
  53. data/spec/lib/sequel_rails/storage/postgres_spec.rb +67 -67
  54. data/spec/lib/sequel_rails/storage/sqlite_spec.rb +40 -40
  55. data/spec/lib/sequel_rails/storage_spec.rb +77 -89
  56. data/spec/spec_helper.rb +16 -10
  57. metadata +61 -28
  58. data/tasks/spec.rake +0 -81
@@ -1,26 +1,28 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe SequelRails::Railtie do
4
4
  let(:app) { Combustion::Application }
5
5
 
6
- it "registers ::Sequel::Railtie::LogSubscriber to receive :sequel notification" do
7
- ActiveSupport::LogSubscriber.log_subscribers.select do |subscriber|
8
- subscriber.is_a?(SequelRails::Railties::LogSubscriber)
9
- end.should have(1).item
6
+ it 'registers ::Sequel::Railtie::LogSubscriber to receive :sequel notification' do
7
+ expect(
8
+ ActiveSupport::LogSubscriber.log_subscribers.select do |subscriber|
9
+ subscriber.is_a?(SequelRails::Railties::LogSubscriber)
10
+ end
11
+ ).to have(1).item
10
12
  end
11
13
 
12
- context "configures generator to use Sequel" do
13
- it "as orm" do
14
- app.config.generators.options[:rails][:orm].should == :sequel
14
+ context 'configures generator to use Sequel' do
15
+ it 'as orm' do
16
+ expect(app.config.generators.options[:rails][:orm]).to be(:sequel)
15
17
  end
16
18
 
17
- it "for migrations" do
18
- app.config.generators.options[:sequel][:migration].should be true
19
+ it 'for migrations' do
20
+ expect(app.config.generators.options[:sequel][:migration]).to be_true
19
21
  end
20
22
  end
21
23
 
22
- it "configures rails to use fancy pants logging" do
23
- app.config.rails_fancy_pants_logging.should be true
24
+ it 'configures rails to use fancy pants logging' do
25
+ expect(app.config.rails_fancy_pants_logging).to be_true
24
26
  end
25
27
 
26
28
  context "configures action dispatch's rescue responses" do
@@ -28,44 +30,44 @@ describe SequelRails::Railtie do
28
30
  app.config.action_dispatch.rescue_responses
29
31
  end
30
32
 
31
- it "to handle Sequel::Plugins::RailsExtensions::ModelNotFound with :not_found" do
32
- rescue_responses["Sequel::Plugins::RailsExtensions::ModelNotFound"].should == :not_found
33
+ it 'to handle Sequel::Plugins::RailsExtensions::ModelNotFound with :not_found' do
34
+ expect(rescue_responses['Sequel::Plugins::RailsExtensions::ModelNotFound']).to be(:not_found)
33
35
  end
34
36
 
35
- it "to handle Sequel::NoMatchingRow with :not_found" do
36
- rescue_responses["Sequel::NoMatchingRow"].should == :not_found
37
+ it 'to handle Sequel::NoMatchingRow with :not_found' do
38
+ expect(rescue_responses['Sequel::NoMatchingRow']).to be(:not_found)
37
39
  end
38
40
 
39
- it "to handle Sequel::ValidationFailed with :unprocessable_entity" do
40
- rescue_responses["Sequel::ValidationFailed"].should == :unprocessable_entity
41
+ it 'to handle Sequel::ValidationFailed with :unprocessable_entity' do
42
+ expect(rescue_responses['Sequel::ValidationFailed']).to be(:unprocessable_entity)
41
43
  end
42
44
 
43
- it "to handle Sequel::NoExistingObject with :unprocessable_entity" do
44
- rescue_responses["Sequel::NoExistingObject"].should == :unprocessable_entity
45
+ it 'to handle Sequel::NoExistingObject with :unprocessable_entity' do
46
+ expect(rescue_responses['Sequel::NoExistingObject']).to be(:unprocessable_entity)
45
47
  end
46
48
  end
47
49
 
48
50
  it "stores it's own config in app.config.sequel" do
49
- app.config.sequel.should be_instance_of SequelRails::Configuration
51
+ expect(app.config.sequel).to be_instance_of SequelRails::Configuration
50
52
  end
51
53
 
52
- it "sets Rails.logger as default logger for its configuration" do
53
- app.config.sequel.logger.should be Rails.logger
54
+ it 'sets Rails.logger as default logger for its configuration' do
55
+ expect(app.config.sequel.logger).to be Rails.logger
54
56
  end
55
57
 
56
- it "configures Sequel::Model instances for i18n" do
57
- User.new.i18n_scope.should == :sequel
58
+ it 'configures Sequel::Model instances for i18n' do
59
+ expect(User.new.i18n_scope).to be(:sequel)
58
60
  end
59
61
 
60
- it "adds Sequel runtime to controller for logging" do
61
- ActionController::Base.included_modules.should include(
62
+ it 'adds Sequel runtime to controller for logging' do
63
+ expect(ActionController::Base.included_modules).to include(
62
64
  SequelRails::Railties::ControllerRuntime
63
65
  )
64
66
  end
65
67
 
66
- it "configures database in Sequel" do
68
+ it 'configures database in Sequel' do
67
69
  expect do
68
70
  Sequel::Model.db.test_connection
69
- end.to_not raise_error Sequel::Error
71
+ end.to_not raise_error
70
72
  end
71
73
  end
@@ -1,6 +1,6 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
- describe "Database rake tasks" do
3
+ describe 'Database rake tasks' do
4
4
 
5
5
  let(:app) { Combustion::Application }
6
6
  let(:app_root) { app.root }
@@ -14,22 +14,23 @@ describe "Database rake tasks" do
14
14
  end
15
15
  end
16
16
 
17
- describe "db:schema:dump" do
17
+ describe 'db:schema:dump' do
18
18
  let(:schema) { "#{app_root}/db/schema.rb" }
19
19
 
20
20
  it "dumps the schema in 'db/schema.rb'" do
21
21
  Dir.chdir app_root do
22
22
  `rake db:schema:dump`
23
- File.exists?(schema).should be_true
23
+ expect(File.exists?(schema)).to be_true
24
24
  end
25
25
  end
26
26
 
27
- it "append the migration schema information if any" do
27
+ it 'append the migration schema information if any' do
28
28
  Dir.chdir app_root do
29
29
  `rake db:migrate db:schema:dump`
30
- sql = Sequel::Model.db.from(:schema_migrations).
31
- insert_sql(:filename => "1273253849_add_twitter_handle_to_users.rb")
32
- File.read(schema).should include <<-EOS
30
+ sql = Sequel::Model.db.from(
31
+ :schema_migrations
32
+ ).insert_sql(:filename => '1273253849_add_twitter_handle_to_users.rb')
33
+ expect(File.read(schema)).to include <<-EOS
33
34
  Sequel.migration do
34
35
  change do
35
36
  self << #{sql.inspect}
@@ -40,25 +41,25 @@ EOS
40
41
  end
41
42
  end
42
43
 
43
- describe "db:structure:dump", :skip_jdbc do
44
+ describe 'db:structure:dump', :skip_jdbc do
44
45
  let(:schema) { "#{app_root}/db/structure.sql" }
45
46
 
46
47
  it "dumps the schema in 'db/structure.sql'" do
47
48
  Dir.chdir app_root do
48
49
  `rake db:structure:dump`
49
- File.exists?(schema).should be_true
50
+ expect(File.exists?(schema)).to be_true
50
51
  end
51
52
  end
52
53
 
53
- it "append the migration schema information if any" do
54
+ it 'append the migration schema information if any' do
54
55
  Dir.chdir app_root do
55
56
  `rake db:migrate db:structure:dump`
56
57
 
57
- sql = Sequel::Model.db.from(:schema_migrations).
58
- insert_sql(:filename => "1273253849_add_twitter_handle_to_users.rb")
59
- File.read(schema).should include sql
58
+ sql = Sequel::Model.db.from(
59
+ :schema_migrations
60
+ ).insert_sql(:filename => '1273253849_add_twitter_handle_to_users.rb')
61
+ expect(File.read(schema)).to include sql
60
62
  end
61
63
  end
62
64
  end
63
-
64
65
  end
@@ -1,5 +1,5 @@
1
- require "spec_helper"
2
- require "active_support/log_subscriber/test_helper"
1
+ require 'spec_helper'
2
+ require 'active_support/log_subscriber/test_helper'
3
3
 
4
4
  describe SequelRails::Railties::LogSubscriber do
5
5
  include ActiveSupport::LogSubscriber::TestHelper
@@ -13,16 +13,16 @@ describe SequelRails::Railties::LogSubscriber do
13
13
  end
14
14
  after { teardown }
15
15
 
16
- it "logs queries" do
16
+ it 'logs queries' do
17
17
  User.all
18
18
  wait
19
- @logger.logged(:debug).last.should =~ /SELECT \* FROM ("|`)users("|`)/
19
+ expect(@logger.logged(:debug).last).to match(/SELECT \* FROM ("|`)users("|`)/)
20
20
  end
21
21
 
22
- it "does not log query when logger level is not debug" do
22
+ it 'does not log query when logger level is not debug' do
23
23
  @logger.level = :info
24
24
  User.all
25
25
  wait
26
- @logger.logged(:debug).should have(:no).line
26
+ expect(@logger.logged(:debug)).to have(:no).line
27
27
  end
28
28
  end
@@ -1,31 +1,31 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe SequelRails::Storage::Mysql, :mysql do
4
- let(:username) { "username" }
5
- let(:host) { "host" }
4
+ let(:username) { 'username' }
5
+ let(:host) { 'host' }
6
6
  let(:port) { 1234 }
7
- let(:password) { "password" }
8
- let(:charset) { "charset" }
9
- let(:collation) { "collation" }
10
- let(:database) { "database" }
7
+ let(:password) { 'password' }
8
+ let(:charset) { 'charset' }
9
+ let(:collation) { 'collation' }
10
+ let(:database) { 'database' }
11
11
  let(:config) do
12
12
  {
13
- "adapter" => "postgres",
14
- "username" => username,
15
- "password" => password,
16
- "host" => host,
17
- "port" => port,
18
- "database" => database,
19
- "charset" => charset,
20
- "collation" => collation,
13
+ 'adapter' => 'postgres',
14
+ 'username' => username,
15
+ 'password' => password,
16
+ 'host' => host,
17
+ 'port' => port,
18
+ 'database' => database,
19
+ 'charset' => charset,
20
+ 'collation' => collation,
21
21
  }
22
22
  end
23
23
  subject { described_class.new config }
24
24
 
25
- describe "#_create" do
26
- context "with all possible options" do
27
- it "uses the mysql command" do
28
- subject.should_receive(:`).with(
25
+ describe '#_create' do
26
+ context 'with all possible options' do
27
+ it 'uses the mysql command' do
28
+ expect(subject).to receive(:`).with(
29
29
  "mysql --user\\=#{username} --password\\=#{password} --host\\=#{host} --port\\=#{port} --execute\\=CREATE\\ DATABASE\\ IF\\ NOT\\ EXISTS\\ \\`#{database}\\`\\ DEFAULT\\ CHARACTER\\ SET\\ #{charset}\\ DEFAULT\\ COLLATE\\ #{collation}"
30
30
  )
31
31
  subject._create
@@ -33,30 +33,30 @@ describe SequelRails::Storage::Mysql, :mysql do
33
33
  end
34
34
  end
35
35
 
36
- describe "#_drop" do
37
- it "uses the mysql command" do
38
- subject.should_receive(:`).with(
36
+ describe '#_drop' do
37
+ it 'uses the mysql command' do
38
+ expect(subject).to receive(:`).with(
39
39
  "mysql --user\\=#{username} --password\\=#{password} --host\\=#{host} --port\\=#{port} --execute\\=DROP\\ DATABASE\\ IF\\ EXISTS\\ \\`#{database}\\`"
40
40
  )
41
41
  subject._drop
42
42
  end
43
43
  end
44
44
 
45
- describe "#_dump" do
46
- let(:dump_file_name) { "dump.sql" }
47
- it "uses the mysqldump command" do
48
- subject.should_receive(:`).with(
45
+ describe '#_dump' do
46
+ let(:dump_file_name) { 'dump.sql' }
47
+ it 'uses the mysqldump command' do
48
+ expect(subject).to receive(:`).with(
49
49
  "mysqldump --user\\=#{username} --password\\=#{password} --host\\=#{host} --port\\=#{port} --no-data --result-file\\=#{dump_file_name} #{database}"
50
50
  )
51
51
  subject._dump dump_file_name
52
52
  end
53
53
  end
54
54
 
55
- describe "#_load" do
56
- let(:dump_file_name) { "dump.sql" }
57
- it "uses the mysql command" do
58
- subject.should_receive(:`).with(
59
- "mysql --user\\=username --password\\=password --host\\=host --port\\=1234 --database\\=database --execute\\=SET\\ FOREIGN_KEY_CHECKS\\ \\=\\ 0\\;\\ SOURCE\\ dump.sql\\;\\ SET\\ FOREIGN_KEY_CHECKS\\ \\=\\ 1"
55
+ describe '#_load' do
56
+ let(:dump_file_name) { 'dump.sql' }
57
+ it 'uses the mysql command' do
58
+ expect(subject).to receive(:`).with(
59
+ 'mysql --user\\=username --password\\=password --host\\=host --port\\=1234 --database\\=database --execute\\=SET\\ FOREIGN_KEY_CHECKS\\ \\=\\ 0\\;\\ SOURCE\\ dump.sql\\;\\ SET\\ FOREIGN_KEY_CHECKS\\ \\=\\ 1'
60
60
  )
61
61
  subject._load dump_file_name
62
62
  end
@@ -1,121 +1,121 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe SequelRails::Storage::Postgres, :postgres do
4
- let(:username) { "username" }
5
- let(:host) { "host" }
4
+ let(:username) { 'username' }
5
+ let(:host) { 'host' }
6
6
  let(:port) { 1234 }
7
- let(:password) { "password" }
8
- let(:maintenance_db){ "maintenance_db" }
9
- let(:encoding) { "encoding" }
10
- let(:locale) { "locale" }
11
- let(:collation) { "collation" }
12
- let(:ctype) { "ctype" }
13
- let(:template) { "template" }
14
- let(:tablespace) { "tablespace" }
15
- let(:owner) { "owner" }
16
- let(:database) { "database" }
7
+ let(:password) { 'password' }
8
+ let(:maintenance_db) { 'maintenance_db' }
9
+ let(:encoding) { 'encoding' }
10
+ let(:locale) { 'locale' }
11
+ let(:collation) { 'collation' }
12
+ let(:ctype) { 'ctype' }
13
+ let(:template) { 'template' }
14
+ let(:tablespace) { 'tablespace' }
15
+ let(:owner) { 'owner' }
16
+ let(:database) { 'database' }
17
17
  let(:config) do
18
18
  {
19
- "adapter" => "postgres",
20
- "username" => username,
21
- "password" => password,
22
- "host" => host,
23
- "port" => port,
24
- "maintenance_db" => maintenance_db,
25
- "encoding" => encoding,
26
- "locale" => locale,
27
- "collation" => collation,
28
- "ctype" => ctype,
29
- "template" => template,
30
- "tablespace" => tablespace,
31
- "owner" => owner,
32
- "database" => database,
19
+ 'adapter' => 'postgres',
20
+ 'username' => username,
21
+ 'password' => password,
22
+ 'host' => host,
23
+ 'port' => port,
24
+ 'maintenance_db' => maintenance_db,
25
+ 'encoding' => encoding,
26
+ 'locale' => locale,
27
+ 'collation' => collation,
28
+ 'ctype' => ctype,
29
+ 'template' => template,
30
+ 'tablespace' => tablespace,
31
+ 'owner' => owner,
32
+ 'database' => database,
33
33
  }
34
34
  end
35
35
 
36
36
  subject { described_class.new config }
37
37
 
38
- describe "#_create" do
39
- context "with all possible options" do
40
- it "uses the createdb command" do
41
- subject.should_receive(:`).with(
38
+ describe '#_create' do
39
+ context 'with all possible options' do
40
+ it 'uses the createdb command' do
41
+ expect(subject).to receive(:`).with(
42
42
  "createdb --username\\=#{username} --host\\=#{host} --port\\=#{port} --maintenance-db\\=#{maintenance_db} --encoding\\=#{encoding} --locale\\=#{locale} --lc-collate\\=#{collation} --lc-ctype\\=#{ctype} --template\\=#{template} --tablespace\\=#{tablespace} --owner\\=#{owner} #{database}"
43
43
  )
44
44
  subject._create
45
45
  end
46
46
  end
47
47
 
48
- context "with only a subset of possible options" do
49
- let(:maintenance_db) { "" }
50
- let(:locale) { "" }
51
- it "uses the createdb command" do
52
- subject.should_receive(:`).with(
48
+ context 'with only a subset of possible options' do
49
+ let(:maintenance_db) { '' }
50
+ let(:locale) { '' }
51
+ it 'uses the createdb command' do
52
+ expect(subject).to receive(:`).with(
53
53
  "createdb --username\\=#{username} --host\\=#{host} --port\\=#{port} --encoding\\=#{encoding} --lc-collate\\=#{collation} --lc-ctype\\=#{ctype} --template\\=#{template} --tablespace\\=#{tablespace} --owner\\=#{owner} #{database}"
54
54
  )
55
55
  subject._create
56
56
  end
57
57
  end
58
58
 
59
- it "sets and remove the password in environment variable PGPASSWORD" do
60
- ENV["PGPASSWORD"].should be_nil
61
- subject.should_receive(:`) do |_|
62
- ENV["PGPASSWORD"].should == password
59
+ it 'sets and remove the password in environment variable PGPASSWORD' do
60
+ expect(ENV['PGPASSWORD']).to be_nil
61
+ expect(subject).to receive(:`) do |_|
62
+ expect(ENV['PGPASSWORD']).to eq(password)
63
63
  end
64
64
  subject._create
65
- ENV["PGPASSWORD"].should be_nil
65
+ expect(ENV['PGPASSWORD']).to be_nil
66
66
  end
67
67
  end
68
68
 
69
- describe "#_drop" do
70
- it "uses the dropdb command" do
71
- subject.should_receive(:`).with(
69
+ describe '#_drop' do
70
+ it 'uses the dropdb command' do
71
+ expect(subject).to receive(:`).with(
72
72
  "dropdb --username\\=#{username} --host\\=#{host} --port\\=#{port} #{database}"
73
73
  )
74
74
  subject._drop
75
75
  end
76
- it "sets and remove the password in environment variable PGPASSWORD" do
77
- ENV["PGPASSWORD"].should be_nil
78
- subject.should_receive(:`) do |_|
79
- ENV["PGPASSWORD"].should == password
76
+ it 'sets and remove the password in environment variable PGPASSWORD' do
77
+ expect(ENV['PGPASSWORD']).to be_nil
78
+ expect(subject).to receive(:`) do |_|
79
+ expect(ENV['PGPASSWORD']).to eq(password)
80
80
  end
81
81
  subject._drop
82
- ENV["PGPASSWORD"].should be_nil
82
+ expect(ENV['PGPASSWORD']).to be_nil
83
83
  end
84
84
  end
85
85
 
86
- describe "#_dump" do
87
- let(:dump_file_name) { "dump.sql" }
88
- it "uses the pg_dump command" do
89
- subject.should_receive(:`).with(
86
+ describe '#_dump' do
87
+ let(:dump_file_name) { 'dump.sql' }
88
+ it 'uses the pg_dump command' do
89
+ expect(subject).to receive(:`).with(
90
90
  "pg_dump --username\\=#{username} --host\\=#{host} --port\\=#{port} -i -s -x -O --file\\=#{dump_file_name} #{database}"
91
91
  )
92
92
  subject._dump dump_file_name
93
93
  end
94
- it "sets and remove the password in environment variable PGPASSWORD" do
95
- ENV["PGPASSWORD"].should be_nil
96
- subject.should_receive(:`) do |_|
97
- ENV["PGPASSWORD"].should == password
94
+ it 'sets and remove the password in environment variable PGPASSWORD' do
95
+ expect(ENV['PGPASSWORD']).to be_nil
96
+ expect(subject).to receive(:`) do |_|
97
+ expect(ENV['PGPASSWORD']).to eq(password)
98
98
  end
99
99
  subject._dump dump_file_name
100
- ENV["PGPASSWORD"].should be_nil
100
+ expect(ENV['PGPASSWORD']).to be_nil
101
101
  end
102
102
  end
103
103
 
104
- describe "#_load" do
105
- let(:dump_file_name) { "dump.sql" }
106
- it "uses the psql command" do
107
- subject.should_receive(:`).with(
104
+ describe '#_load' do
105
+ let(:dump_file_name) { 'dump.sql' }
106
+ it 'uses the psql command' do
107
+ expect(subject).to receive(:`).with(
108
108
  "psql --username\\=#{username} --host\\=#{host} --port\\=#{port} --file\\=#{dump_file_name} #{database}"
109
109
  )
110
110
  subject._load dump_file_name
111
111
  end
112
- it "sets and remove the password in environment variable PGPASSWORD" do
113
- ENV["PGPASSWORD"].should be_nil
114
- subject.should_receive(:`) do |_|
115
- ENV["PGPASSWORD"].should == password
112
+ it 'sets and remove the password in environment variable PGPASSWORD' do
113
+ expect(ENV['PGPASSWORD']).to be_nil
114
+ expect(subject).to receive(:`) do |_|
115
+ expect(ENV['PGPASSWORD']).to eq(password)
116
116
  end
117
117
  subject._load dump_file_name
118
- ENV["PGPASSWORD"].should be_nil
118
+ expect(ENV['PGPASSWORD']).to be_nil
119
119
  end
120
120
  end
121
121
  end
@@ -1,50 +1,50 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe SequelRails::Storage::Sqlite, :sqlite do
4
4
  let(:config) do
5
5
  {
6
- "adapter" => "sqlite3",
7
- "database" => database,
6
+ 'adapter' => 'sqlite3',
7
+ 'database' => database,
8
8
  }
9
9
  end
10
10
  subject { described_class.new config }
11
11
 
12
- context "when database is not in memory" do
13
- let(:database) { "test_database.sqlite" }
12
+ context 'when database is not in memory' do
13
+ let(:database) { 'test_database.sqlite' }
14
14
  let(:database_path) { "#{Combustion::Application.root}/#{database}" }
15
15
 
16
- describe "#_create" do
17
- it "defer to Sequel" do
18
- path = mock :path
19
- subject.stub(:path).and_return path
20
- ::Sequel.should_receive(:connect).with("adapter"=>"sqlite3", "database"=>path)
16
+ describe '#_create' do
17
+ it 'defer to Sequel' do
18
+ path = double(:path)
19
+ allow(subject).to receive(:path).and_return path
20
+ expect(::Sequel).to receive(:connect).with('adapter' => 'sqlite3', 'database' => path)
21
21
  subject._create
22
22
  end
23
23
  end
24
24
 
25
- describe "#_drop" do
26
- it "delete the database file" do
27
- path = mock :path, :file? => true
28
- subject.stub(:path).and_return path
29
- path.should_receive :unlink
25
+ describe '#_drop' do
26
+ it 'delete the database file' do
27
+ path = double(:path, :file? => true)
28
+ allow(subject).to receive(:path).and_return path
29
+ expect(path).to receive :unlink
30
30
  subject._drop
31
31
  end
32
32
  end
33
33
 
34
- describe "#_dump" do
35
- let(:dump_file_name) { "dump.sql" }
36
- it "uses the sqlite3 command" do
37
- subject.should_receive(:`).with(
34
+ describe '#_dump' do
35
+ let(:dump_file_name) { 'dump.sql' }
36
+ it 'uses the sqlite3 command' do
37
+ expect(subject).to receive(:`).with(
38
38
  "sqlite3 #{database_path} .schema > #{dump_file_name}"
39
39
  )
40
40
  subject._dump dump_file_name
41
41
  end
42
42
  end
43
43
 
44
- describe "#_load" do
45
- let(:dump_file_name) { "dump.sql" }
46
- it "uses the sqlite3 command" do
47
- subject.should_receive(:`).with(
44
+ describe '#_load' do
45
+ let(:dump_file_name) { 'dump.sql' }
46
+ it 'uses the sqlite3 command' do
47
+ expect(subject).to receive(:`).with(
48
48
  "sqlite3 #{database_path} < #{dump_file_name}"
49
49
  )
50
50
  subject._load dump_file_name
@@ -52,36 +52,36 @@ describe SequelRails::Storage::Sqlite, :sqlite do
52
52
  end
53
53
  end
54
54
 
55
- context "when database is in memory" do
56
- let(:database) { ":memory:" }
55
+ context 'when database is in memory' do
56
+ let(:database) { ':memory:' }
57
57
 
58
- describe "#_create" do
58
+ describe '#_create' do
59
59
  it "don't do anything" do
60
- ::Sequel.should_not_receive(:connect)
60
+ expect(::Sequel).to_not receive(:connect)
61
61
  subject._create
62
62
  end
63
63
  end
64
64
 
65
- describe "#_drop" do
66
- it "do not try to delete the database file" do
67
- path = mock :path, :file? => true
68
- subject.stub(:path).and_return path
69
- path.should_not_receive :unlink
65
+ describe '#_drop' do
66
+ it 'do not try to delete the database file' do
67
+ path = double(:path, :file? => true)
68
+ allow(subject).to receive(:path).and_return path
69
+ expect(path).to_not receive :unlink
70
70
  subject._drop
71
71
  end
72
72
  end
73
73
 
74
- describe "#_dump" do
75
- it "do not dump anything" do
76
- subject.should_not_receive(:`)
77
- subject._dump "dump.sql"
74
+ describe '#_dump' do
75
+ it 'do not dump anything' do
76
+ expect(subject).to_not receive(:`)
77
+ subject._dump 'dump.sql'
78
78
  end
79
79
  end
80
80
 
81
- describe "#_load" do
82
- it "do not load anything" do
83
- subject.should_not_receive(:`)
84
- subject._load "dump.sql"
81
+ describe '#_load' do
82
+ it 'do not load anything' do
83
+ expect(subject).to_not receive(:`)
84
+ subject._load 'dump.sql'
85
85
  end
86
86
  end
87
87
  end