Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubocop/cop/migration/remove_column_spec.rb')
-rw-r--r--spec/rubocop/cop/migration/remove_column_spec.rb44
1 files changed, 18 insertions, 26 deletions
diff --git a/spec/rubocop/cop/migration/remove_column_spec.rb b/spec/rubocop/cop/migration/remove_column_spec.rb
index 4768093b10d..a8a828bc62a 100644
--- a/spec/rubocop/cop/migration/remove_column_spec.rb
+++ b/spec/rubocop/cop/migration/remove_column_spec.rb
@@ -5,63 +5,55 @@ require 'rubocop'
require_relative '../../../../rubocop/cop/migration/remove_column'
RSpec.describe RuboCop::Cop::Migration::RemoveColumn do
- include CopHelper
-
subject(:cop) { described_class.new }
def source(meth = 'change')
"def #{meth}; remove_column :table, :column; end"
end
- context 'in a regular migration' do
+ context 'when in a regular migration' do
before do
allow(cop).to receive(:in_migration?).and_return(true)
allow(cop).to receive(:in_post_deployment_migration?).and_return(false)
end
it 'registers an offense when remove_column is used in the change method' do
- inspect_source(source('change'))
-
- aggregate_failures do
- expect(cop.offenses.size).to eq(1)
- expect(cop.offenses.map(&:line)).to eq([1])
- end
+ expect_offense(<<~RUBY)
+ def change
+ remove_column :table, :column
+ ^^^^^^^^^^^^^ `remove_column` must only be used in post-deployment migrations
+ end
+ RUBY
end
it 'registers an offense when remove_column is used in the up method' do
- inspect_source(source('up'))
-
- aggregate_failures do
- expect(cop.offenses.size).to eq(1)
- expect(cop.offenses.map(&:line)).to eq([1])
- end
+ expect_offense(<<~RUBY)
+ def up
+ remove_column :table, :column
+ ^^^^^^^^^^^^^ `remove_column` must only be used in post-deployment migrations
+ end
+ RUBY
end
it 'registers no offense when remove_column is used in the down method' do
- inspect_source(source('down'))
-
- expect(cop.offenses.size).to eq(0)
+ expect_no_offenses(source('down'))
end
end
- context 'in a post-deployment migration' do
+ context 'when in a post-deployment migration' do
before do
allow(cop).to receive(:in_migration?).and_return(true)
allow(cop).to receive(:in_post_deployment_migration?).and_return(true)
end
it 'registers no offense' do
- inspect_source(source)
-
- expect(cop.offenses.size).to eq(0)
+ expect_no_offenses(source)
end
end
- context 'outside of a migration' do
+ context 'when outside of a migration' do
it 'registers no offense' do
- inspect_source(source)
-
- expect(cop.offenses.size).to eq(0)
+ expect_no_offenses(source)
end
end
end