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

RSpec/ImplicitSubject does not use example methods defined by third-party gems #1290

Closed
inkstak opened this issue May 31, 2022 · 3 comments · May be fixed by zverok/saharspec#7
Closed

RSpec/ImplicitSubject does not use example methods defined by third-party gems #1290

inkstak opened this issue May 31, 2022 · 3 comments · May be fixed by zverok/saharspec#7

Comments

@inkstak
Copy link

inkstak commented May 31, 2022

I use saharspecs and its its_call alias :

its_call(1) do
  is_expected
    .to  send_message(Foo, :method).once
    .and change { whatever }
end

I've add saharspec aliases to rubocop and RSpec/ImplicitSubject is set to accept single statement

inherit_gem:
  saharspec: config/rubocop-rspec.yml

[...]

RSpec/ImplicitSubject:
  EnforcedStyle: single_statement_only

It report offenses on Implicit subject:

RSpec/ImplicitSubject: Don't use implicit subject. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject)
    is_expected
    ^^^^^^^^^^^

I've got the same error when I set RSpec/ImplicitSubject to accept single line

its_call(1) { is_expected.to send_message(Foo, :method).once }
RSpec/ImplicitSubject:
  EnforcedStyle: single_line_only
RSpec/ImplicitSubject: Don't use implicit subject. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject)
  its_call(1) { is_expected.to send_message(Foo, :method).once }
                ^^^^^^^^^^^
@pirj
Copy link
Member

pirj commented May 31, 2022

The fix is quite simple.

image

Would you like to turn it into a PR?

@inkstak
Copy link
Author

inkstak commented Jun 1, 2022

Thanks, I was a little overwhelmed by the DSL.
I'll try to turn it into a PR with tests today.

@pirj
Copy link
Member

pirj commented Jun 2, 2022

I'm closing this, as it turns out that aliases were not properly defined in a third-party library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants