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

Fix specs for code transparently fixed with RuboCop 0.84 update #914

Merged
merged 4 commits into from
May 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/example_wording_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
context 'when configuration is empty' do
include_examples 'autocorrect',
'it "should have trait" do end',
'it "haves trait" do end'
'it "has trait" do end'

include_examples 'autocorrect',
'it "should only fail" do end',
Expand Down
26 changes: 13 additions & 13 deletions spec/rubocop/cop/rspec/verified_doubles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,27 @@
end
end

it 'doubles that have no name specified' do
expect_offense(<<-RUBY)
it do
foo = double
^^^^^^ Prefer using verifying doubles over normal doubles.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's quite strange how it worked like that, since IgnoreNameless: true by default.
Nice, it's fixed now.

This gives me an interesting thought, since on the one hand, it's a bug fix, and on the other, it's a change in behaviour. But we're unable to "protect" our users from that change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps cop_config was not merged with the default values?
Anyway, it's better to have the values explicitly set in specs and not rely on defaults

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. Previously – before rubocop/rubocop#7970 – the default configuration was not present when testing. And it is now, so we can simplify a lot of our test.

I was too working on fixing our specs (and applied the exact same changes to spec/rubocop/cop/rspec/verified_doubles_spec.rb) and have taken the liberty of adding a few commits to your branch. I hope that is ok with you @pirj

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such a wonderful idea. I recall it was discussed before, and so good it's now in place.

is ok with you

Of course, nice cleanup!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mention in the commit message of 4e7272b that the change in RuboCop actually introduces a “mystery guest”, which could be considered a code smell.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything works and looks nice. Do you have something else in mind tbd here, or is it good to merge?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we‘re good to merge.

end
RUBY
end
context 'when configured not to ignore nameless doubles' do
let(:cop_config) { { 'IgnoreNameless' => false } }

context 'when configured to ignore nameless doubles' do
let(:cop_config) { { 'IgnoreNameless' => true } }

it 'ignores doubles that have no name specified' do
expect_no_offenses(<<-RUBY)
it 'flags doubles that have no name specified' do
expect_offense(<<-RUBY)
it do
foo = double
^^^^^^ Prefer using verifying doubles over normal doubles.
end
RUBY
end
end

it 'ignores doubles that have no name specified' do
expect_no_offenses(<<-RUBY)
it do
foo = double
end
RUBY
end

it 'ignores instance_doubles' do
expect_no_offenses(<<-RUBY)
it do
Expand Down