Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

BrentWheeldon
Copy link
Contributor

Currently if you have a double/spy with no name (or default stubs) it will never cause a violation according to the RSpec/VerifiedDoubles cop. This adds an optional configuration to allow violations to be added for code that looks like:

foo = double
allow(foo).to receive(:bar) do |arg1|
  “#{arg1} based result”
end

I left the default configuration not enforcing this cop on nameless doubles so as to make this a non-breaking change.

Copy link
Member

@Darhazer Darhazer left a comment

Choose a reason for hiding this comment

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

Thank you.

Just 2 minor comments on the tests

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

it 'ignores doubles whose name is a symbol' do
Copy link
Member

Choose a reason for hiding this comment

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

the test description does not match its body

@BrentWheeldon
Copy link
Contributor Author

@Darhazer Thanks for the quick review, and sorry for the spec sloppiness. Those are fixed up now.


it 'ignores doubles without a name' do
expect_no_offenses(<<-RUBY)
it 'finds a double when the no name is specified' do
Copy link
Member

Choose a reason for hiding this comment

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

this one needs improving. Perpahs finds a double without a name is enough

Copy link
Member

Choose a reason for hiding this comment

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

doubles that have no name specified also works, as it is consistent with the other test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 fixed that up.

BrentWheeldon and others added 2 commits October 3, 2018 11:45
…ubles

Currently if you have a double/spy with no name (or default stubs) it will never cause a violation according to the `RSpec/VerifiedDoubles` cop. This adds an optional configuration to allow violations to be added for code that looks like:

```
foo = double
allow(foo).to receive(:bar) do |arg1|
  “#{arg1} based result”
end
```
@Darhazer Darhazer merged commit 507a7f7 into rubocop:master Oct 4, 2018
@BrentWheeldon BrentWheeldon deleted the bmw-verify-nameless-doubles branch January 2, 2019 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants