From 27dc8d971a365f56b5cdd2306ef9be024d19175d Mon Sep 17 00:00:00 2001 From: Tomasz Pajor Date: Mon, 15 Feb 2016 17:30:49 +0100 Subject: [PATCH 1/2] fix Style/MutableConstant --- .rubocop.yml | 4 ---- lib/rubocop/cop/rspec/any_instance.rb | 4 ++-- lib/rubocop/cop/rspec/describe_class.rb | 2 +- lib/rubocop/cop/rspec/describe_method.rb | 2 +- lib/rubocop/cop/rspec/described_class.rb | 2 +- lib/rubocop/cop/rspec/example_wording.rb | 2 +- lib/rubocop/cop/rspec/file_path.rb | 2 +- lib/rubocop/cop/rspec/instance_variable.rb | 2 +- lib/rubocop/cop/rspec/multiple_describes.rb | 5 +++-- lib/rubocop/cop/rspec/verified_doubles.rb | 2 +- 10 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index daa6cde4b..d8bb37449 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,7 +7,3 @@ Style/MultilineMethodCallIndentation: Style/MultilineOperationIndentation: EnforcedStyle: indented - -# to be re-enabled once bbatsov/rubocop#2634 is merged -Style/MutableConstant: - Enabled: false diff --git a/lib/rubocop/cop/rspec/any_instance.rb b/lib/rubocop/cop/rspec/any_instance.rb index db011b93b..710a3b048 100644 --- a/lib/rubocop/cop/rspec/any_instance.rb +++ b/lib/rubocop/cop/rspec/any_instance.rb @@ -21,13 +21,13 @@ module RSpec # end # end class AnyInstance < Cop - MESSAGE = 'Avoid stubbing using `%{method}`' + MESSAGE = 'Avoid stubbing using `%{method}`'.freeze ANY_INSTANCE_METHODS = [ :any_instance, :allow_any_instance_of, :expect_any_instance_of - ] + ].freeze def on_send(node) _receiver, method_name, *_args = *node diff --git a/lib/rubocop/cop/rspec/describe_class.rb b/lib/rubocop/cop/rspec/describe_class.rb index c539acde7..206b9479b 100644 --- a/lib/rubocop/cop/rspec/describe_class.rb +++ b/lib/rubocop/cop/rspec/describe_class.rb @@ -25,7 +25,7 @@ class DescribeClass < Cop FEATURE_PAIR = s(:pair, s(:sym, :type), s(:sym, :feature)) MESSAGE = 'The first argument to describe should be the class or ' \ - 'module being tested.' + 'module being tested.'.freeze def on_top_level_describe(_node, args) return if args[0] && args[0].type == :const diff --git a/lib/rubocop/cop/rspec/describe_method.rb b/lib/rubocop/cop/rspec/describe_method.rb index 0e3b2705c..d45ea90a3 100644 --- a/lib/rubocop/cop/rspec/describe_method.rb +++ b/lib/rubocop/cop/rspec/describe_method.rb @@ -22,7 +22,7 @@ class DescribeMethod < Cop include RuboCop::RSpec::TopLevelDescribe MESSAGE = 'The second argument to describe should be the method ' \ - "being tested. '#instance' or '.class'" + "being tested. '#instance' or '.class'".freeze METHOD_STRING_MATCHER = /^[\#\.].+/ def on_top_level_describe(_node, args) diff --git a/lib/rubocop/cop/rspec/described_class.rb b/lib/rubocop/cop/rspec/described_class.rb index 3fbd55726..15ac0f420 100644 --- a/lib/rubocop/cop/rspec/described_class.rb +++ b/lib/rubocop/cop/rspec/described_class.rb @@ -21,7 +21,7 @@ module RSpec class DescribedClass < Cop include RuboCop::RSpec::TopLevelDescribe - MESSAGE = 'Use `described_class` instead of `%s`' + MESSAGE = 'Use `described_class` instead of `%s`'.freeze def on_block(node) method, _args, body = *node diff --git a/lib/rubocop/cop/rspec/example_wording.rb b/lib/rubocop/cop/rspec/example_wording.rb index a14948b37..a93390cb2 100644 --- a/lib/rubocop/cop/rspec/example_wording.rb +++ b/lib/rubocop/cop/rspec/example_wording.rb @@ -19,7 +19,7 @@ module RSpec # it 'finds nothing' do # end class ExampleWording < Cop - MSG = 'Do not use should when describing your tests.' + MSG = 'Do not use should when describing your tests.'.freeze def on_block(node) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/LineLength method, = *node diff --git a/lib/rubocop/cop/rspec/file_path.rb b/lib/rubocop/cop/rspec/file_path.rb index 1567589d9..bdca5ecee 100644 --- a/lib/rubocop/cop/rspec/file_path.rb +++ b/lib/rubocop/cop/rspec/file_path.rb @@ -18,7 +18,7 @@ module RSpec class FilePath < Cop include RuboCop::RSpec::TopLevelDescribe - MESSAGE = 'Spec path should end with `%s`' + MESSAGE = 'Spec path should end with `%s`'.freeze METHOD_STRING_MATCHER = /^[\#\.].+/ def on_top_level_describe(node, args) diff --git a/lib/rubocop/cop/rspec/instance_variable.rb b/lib/rubocop/cop/rspec/instance_variable.rb index 83ee0cd8d..eb074ce8c 100644 --- a/lib/rubocop/cop/rspec/instance_variable.rb +++ b/lib/rubocop/cop/rspec/instance_variable.rb @@ -20,7 +20,7 @@ module RSpec # it { expect(foo).to be_empty } # end class InstanceVariable < Cop - MESSAGE = 'Use `let` instead of an instance variable' + MESSAGE = 'Use `let` instead of an instance variable'.freeze EXAMPLE_GROUP_METHODS = [ :example_group, :describe, :context, :xdescribe, :xcontext, :fdescribe, :fcontext, :shared_examples, :shared_context, diff --git a/lib/rubocop/cop/rspec/multiple_describes.rb b/lib/rubocop/cop/rspec/multiple_describes.rb index e9ccbb8d2..a7155ef9c 100644 --- a/lib/rubocop/cop/rspec/multiple_describes.rb +++ b/lib/rubocop/cop/rspec/multiple_describes.rb @@ -24,13 +24,14 @@ module RSpec class MultipleDescribes < Cop include RuboCop::RSpec::TopLevelDescribe - MESSAGE = 'Do not use multiple top level describes - try to nest them.' + MSG = 'Do not use multiple top level describes - ' \ + 'try to nest them.'.freeze def on_top_level_describe(node, _args) return if single_top_level_describe? return unless top_level_nodes.first == node - add_offense(node, :expression, MESSAGE) + add_offense(node, :expression, MSG) end end end diff --git a/lib/rubocop/cop/rspec/verified_doubles.rb b/lib/rubocop/cop/rspec/verified_doubles.rb index 7e228cd68..4a516c3c9 100644 --- a/lib/rubocop/cop/rspec/verified_doubles.rb +++ b/lib/rubocop/cop/rspec/verified_doubles.rb @@ -18,7 +18,7 @@ module RSpec # widget = instance_double("Widget") # end class VerifiedDoubles < Cop - MSG = 'Prefer using verifying doubles over normal doubles.' + MSG = 'Prefer using verifying doubles over normal doubles.'.freeze def on_send(node) _receiver, method_name, *_args = *node From 1d788e51a7a1505f4f0cf8a00767a36150dfdaa3 Mon Sep 17 00:00:00 2001 From: Tomasz Pajor Date: Mon, 15 Feb 2016 17:31:04 +0100 Subject: [PATCH 2/2] release 1.4.0 --- CHANGELOG.md | 2 ++ lib/rubocop/rspec/version.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b204bb806..ea3cf8099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master (unreleased) +## 1.4.0 (15/02/2016) + * Update to rubocop 0.37.2. ([@nijikon][]) * Update ruby versions we test against. ([@nijikon][]) * Add `RSpec::NotToNot` cop. ([@miguelfteixeira][]) diff --git a/lib/rubocop/rspec/version.rb b/lib/rubocop/rspec/version.rb index 914ddb1b9..ae16056a7 100644 --- a/lib/rubocop/rspec/version.rb +++ b/lib/rubocop/rspec/version.rb @@ -5,7 +5,7 @@ module RuboCop module RSpec # Version information for the RSpec RuboCop plugin. module Version - STRING = '1.3.1' + STRING = '1.4.0'.freeze end end end