Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case insensitive should in example_wording.rb #31

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.start_with?('should', '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