diff --git a/spec/aruba/dbconsole_spec.rb b/spec/aruba/dbconsole_spec.rb index 8fab834..9ffab3a 100644 --- a/spec/aruba/dbconsole_spec.rb +++ b/spec/aruba/dbconsole_spec.rb @@ -3,11 +3,12 @@ require 'spec_helper' RSpec.describe 'rails dbconsole', type: :aruba do + subject { action && last_command_started } + let(:action) { run_command("bash -c \"echo 'select 1 as foo_column; \\q' | bundle exec rails db\"") } - let(:last_command) { action && last_command_started } before { copy_db_config } - it { expect(last_command).to be_successfully_executed } - it { expect(last_command).to have_output(/\bfoo_column\b/) } + it { is_expected.to be_successfully_executed } + it { is_expected.to have_output(/\bfoo_column\b/) } end diff --git a/spec/aruba/migrations_spec.rb b/spec/aruba/migrations_spec.rb index b2e0ce7..0a8014f 100644 --- a/spec/aruba/migrations_spec.rb +++ b/spec/aruba/migrations_spec.rb @@ -8,34 +8,37 @@ context 'when a migration is generated' do before { run_command_and_stop('bundle exec rails g migration CreateModels name:string') } - describe 'bundle exec rake db:migrate' do - let(:action) { run_command('bundle exec rake db:migrate') } - let(:last_command) { action && last_command_started } + describe 'bundle exec rails db:migrate' do + subject { action && last_command_started } - it { expect(last_command).to be_successfully_executed } - it { expect(last_command).to have_output(/CreateModels: migrated/) } + let(:action) { run_command('bundle exec rails db:migrate') } + + it { is_expected.to be_successfully_executed } + it { is_expected.to have_output(/CreateModels: migrated/) } end end - describe 'rerun bundle exec rake db:drop db:create db:migrate', issue: 56 do - let(:command) { 'bundle exec rake db:drop db:create db:migrate' } + describe 'rerun bundle exec rails db:drop db:create db:migrate', issue: 56 do + subject { action && last_command_started } + + let(:command) { 'bundle exec rails db:drop db:create db:migrate' } let(:action) { run_command(command) } let(:regex) { /-- change_table\(:impressions, {:temporal=>true, :copy_data=>true}\)/ } before { copy('%/migrations/56/', 'db/migrate') } describe 'once' do - let(:last_command) { action && last_command_started } - - it { expect(last_command).to be_successfully_executed } - it { expect(last_command).to have_output(regex) } + it { is_expected.to be_successfully_executed } + it { is_expected.to have_output(regex) } end describe 'twice' do - let(:last_command) { run_command_and_stop(command) && action && last_command_started } + before do + action + end - it { expect(last_command).to be_successfully_executed } - it { expect(last_command).to have_output(regex) } + it { is_expected.to be_successfully_executed } + it { is_expected.to have_output(regex) } end end end diff --git a/spec/aruba/rake_task_spec.rb b/spec/aruba/rake_task_spec.rb index cae6f85..54a72b1 100644 --- a/spec/aruba/rake_task_spec.rb +++ b/spec/aruba/rake_task_spec.rb @@ -22,21 +22,23 @@ end describe dump_schema_task.to_s do + subject { last_command_started } + let(:db_file) { 'db/test.sql' } before do copy_db_config - run_command_and_stop("bundle exec rake #{dump_schema_task} SCHEMA=db/test.sql") + run_command_and_stop("bundle exec rails #{dump_schema_task} SCHEMA=db/test.sql") end - it { expect(last_command_started).to be_successfully_executed } + it { is_expected.to be_successfully_executed } it { expect(db_file).to be_an_existing_file } it { expect(db_file).not_to have_file_content(/\A--/) } context 'with schema_search_path option' do before do copy_db_config('database_with_schema_search_path.yml') - run_command_and_stop("bundle exec rake #{dump_schema_task} SCHEMA=db/test.sql") + run_command_and_stop("bundle exec rails #{dump_schema_task} SCHEMA=db/test.sql") end it 'includes chronomodel schemas' do @@ -51,15 +53,16 @@ before do copy_db_config copy('%/set_config.sql', 'db/test.sql') - run_command_and_stop('bundle exec rake db:schema:load SCHEMA=db/test.sql') + run_command_and_stop('bundle exec rails db:schema:load SCHEMA=db/test.sql') end it { expect(last_command_started).to be_successfully_executed } end describe load_schema_task.to_s do - let(:action) { run_command("bundle exec rake #{load_schema_task}") } - let(:last_command) { action && last_command_started } + subject { action && last_command_started } + + let(:action) { run_command("bundle exec rails #{load_schema_task}") } context 'with db/structure.sql' do before do @@ -86,13 +89,13 @@ end end - it { expect(last_command).to be_successfully_executed } + it { is_expected.to be_successfully_executed } end context 'without a specified username and password', issue: 55 do before { copy_db_config } - it { expect(last_command).to be_successfully_executed } + it { is_expected.to be_successfully_executed } end end end @@ -101,7 +104,7 @@ before do copy_db_config copy('%/set_config.sql', 'db/test.sql') - run_command_and_stop('bundle exec rake db:data:dump DUMP=db/test.sql') + run_command_and_stop('bundle exec rails db:data:dump DUMP=db/test.sql') end it { expect(last_command_started).to be_successfully_executed } @@ -112,7 +115,7 @@ before do copy_db_config copy('%/empty_structure.sql', 'db/test.sql') - run_command_and_stop('bundle exec rake db:data:load DUMP=db/test.sql') + run_command_and_stop('bundle exec rails db:data:load DUMP=db/test.sql') end it { expect(last_command_started).to be_successfully_executed } diff --git a/spec/aruba/subclasses_spec.rb b/spec/aruba/subclasses_spec.rb index 5ccaf89..e41f03b 100644 --- a/spec/aruba/subclasses_spec.rb +++ b/spec/aruba/subclasses_spec.rb @@ -3,8 +3,9 @@ require 'spec_helper' RSpec.describe 'subclasses spec', type: :aruba do + subject(:last_command) { action && last_command_started } + let(:action) { run_command('bundle exec rails runner "Foo.subclasses"') } - let(:last_command) { action && last_command_started } before do set_environment_variable 'CM_TEST_EAGER_LOAD', true