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/prevent_strings_spec.rb')
-rw-r--r--spec/rubocop/cop/migration/prevent_strings_spec.rb22
1 files changed, 9 insertions, 13 deletions
diff --git a/spec/rubocop/cop/migration/prevent_strings_spec.rb b/spec/rubocop/cop/migration/prevent_strings_spec.rb
index 560a485017a..d8d4058363e 100644
--- a/spec/rubocop/cop/migration/prevent_strings_spec.rb
+++ b/spec/rubocop/cop/migration/prevent_strings_spec.rb
@@ -5,45 +5,41 @@ require 'rubocop'
require_relative '../../../../rubocop/cop/migration/prevent_strings'
RSpec.describe RuboCop::Cop::Migration::PreventStrings do
- include CopHelper
-
subject(:cop) { described_class.new }
- context 'in migration' do
+ context 'when in migration' do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
context 'when the string data type is used' do
it 'registers an offense' do
- expect_offense(<<~RUBY)
+ expect_offense(<<~RUBY, msg: "Do not use the `string` data type, use `text` instead.[...]")
class Users < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
create_table :users do |t|
t.string :username, null: false
- ^^^^^^ #{described_class::MSG}
+ ^^^^^^ %{msg}
t.timestamps_with_timezone null: true
t.string :password
- ^^^^^^ #{described_class::MSG}
+ ^^^^^^ %{msg}
end
add_column(:users, :bio, :string)
- ^^^^^^^^^^ #{described_class::MSG}
+ ^^^^^^^^^^ %{msg}
add_column_with_default(:users, :url, :string, default: '/-/user', allow_null: false, limit: 255)
- ^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
+ ^^^^^^^^^^^^^^^^^^^^^^^ %{msg}
change_column_type_concurrently :users, :commit_id, :string
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %{msg}
end
end
RUBY
-
- expect(cop.offenses.map(&:cop_name)).to all(eq('Migration/PreventStrings'))
end
end
@@ -109,7 +105,7 @@ RSpec.describe RuboCop::Cop::Migration::PreventStrings do
end
end
- context 'on down' do
+ context 'when using down method' do
it 'registers no offense' do
expect_no_offenses(<<~RUBY)
class Users < ActiveRecord::Migration[6.0]
@@ -138,7 +134,7 @@ RSpec.describe RuboCop::Cop::Migration::PreventStrings do
end
end
- context 'outside of migration' do
+ context 'when outside of migration' do
it 'registers no offense' do
expect_no_offenses(<<~RUBY)
class Users < ActiveRecord::Migration[6.0]