Skip to content

Commit

Permalink
Make RSpec::ExampleWording case insensitive.
Browse files Browse the repository at this point in the history
Closes rubocop#31 - thanks to @EsterYtterbrinkAtTrialbee
  • Loading branch information
geniou committed Feb 26, 2015
1 parent 60f2e40 commit f4797ce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

# master

* Make `RSpec::ExampleWording` case insensitive. ([@geniou][])

## 1.2.1

* Add `RSpec::VerifiedDoubles` cop. ([@andyw8][])
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/example_wording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/rubocop/cop/rspec/example_wording_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f4797ce

Please sign in to comment.