-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Capybara/FeatureMethods identifies given
calls from other DSLs.
#1719
Comments
Would it make sense to configure this cop to only include feature/system spec paths. What do you think?
Not really. This would limit its inspection capabilities to the very basic spec structures. |
While syntactically you can nest describe "something" do
let(:abc) do
let(:de) do
1
end
2
end
it "works" do
puts abc
puts de
end
end produces:
So only "the very basic spec structures" are where |
Please accept my apologies. That must have been Alright, it's an edge case, but worth and possible to fix.
Would you like to send a PR? |
given
calls from other DSLs.given
calls from other DSLs.
Whilst this is a bit of a minefield. I'm also finding huge amounts of offenses in .... (wait for it), the internal testing suites for cucumber which doesn't lean too heavily on capybara. In it we have helpers that write things like A real world example is here: https://github.com/cucumber/cucumber-ruby-core/blob/main/spec/cucumber/core/gherkin/parser_spec.rb#L139-L153
Not sure if it's relevant to be called out, or we should just prefix all our internal tests with maybe an underscore or something similar, so it's |
Quite an interesting case, @luke-hill Are they even interested in linting their inner code under test? The spec looks like a regular RSpec DSL with its describe/context/it structure. |
Sorry for the noise from transferring back and forth, it slipped my mind some Capybara cops remain here. Speaking of the issue itself. I would suggest changing this to ‘directly_under_example_group?’. To my best memory, we did this for some other cops already. A PR is welcome. |
If it's something that will be fixed in the short-medium term I'm happy to wait. I have 1000 other things to fix up in cucumber. As for the why, the scenario/feature e.t.c. are generating the pickles for just that. a scenario or feature. |
Apologies for coming in with more bad news / incorrections. But it seems Tidying up more things today and saw this:
Wider context
|
I am closing this issue, since the RSpec/Capybara/FeatureMethods cop was removed in #1876 / v3.0.0. |
I have a spec that is exercising a DSL of its own:
and yet I'm getting
RSpec/Capybara/FeatureMethods: Use let instead of given.
It seems like this cop should only look for
given
calls immediately inside ofdescribe
,context
, etc. blocks, and not in arbitrary code. At the least not inside of alet
itself.rubocop -V
:The text was updated successfully, but these errors were encountered: