diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fc127342..4f9b82c7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +# master + +* Make `RSpec::ExampleWording` case insensitive. ([@geniou][]) + ## 1.2.1 * Add `RSpec::VerifiedDoubles` cop. ([@andyw8][]) diff --git a/lib/rubocop/cop/rspec/example_wording.rb b/lib/rubocop/cop/rspec/example_wording.rb index dcf730a25..56c6e9884 100644 --- a/lib/rubocop/cop/rspec/example_wording.rb +++ b/lib/rubocop/cop/rspec/example_wording.rb @@ -28,7 +28,7 @@ def on_block(node) # rubocop:disable Metrics/AbcSize arguments = *(args.first) message = arguments.first.to_s - return unless message.start_with?('should') + return unless message.downcase.start_with?('should') arg1 = args.first.loc.expression message = Parser::Source::Range diff --git a/spec/rubocop/cop/rspec/example_wording_spec.rb b/spec/rubocop/cop/rspec/example_wording_spec.rb index 393f63942..f98325e17 100644 --- a/spec/rubocop/cop/rspec/example_wording_spec.rb +++ b/spec/rubocop/cop/rspec/example_wording_spec.rb @@ -18,6 +18,15 @@ expect(cop.highlights).to eq(['should do something']) end + it 'finds description with `Should` at the beginning' do + inspect_source(cop, ["it 'Should do something' do", 'end']) + expect(cop.offenses.size).to eq(1) + expect(cop.offenses.map(&:line).sort).to eq([1]) + expect(cop.messages) + .to eq(['Do not use should when describing your tests.']) + expect(cop.highlights).to eq(['Should do something']) + end + it 'finds description with `shouldn\'t` at the beginning' do inspect_source(cop, ['it "shouldn\'t do something" do', 'end']) expect(cop.offenses.size).to eq(1)