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

Capybara/FeatureMethods - improve the suggestion? #505

Closed
andyw8 opened this issue Nov 18, 2017 · 6 comments
Closed

Capybara/FeatureMethods - improve the suggestion? #505

andyw8 opened this issue Nov 18, 2017 · 6 comments

Comments

@andyw8
Copy link
Collaborator

andyw8 commented Nov 18, 2017

I've just upgraded to the latest gem so ran into this.

The Capybara/FeatureMethods cop suggests that scenario 'with OAuth' should be changed to it 'with OAuth'. I feel this is bad advice. When RSpec is run with --format documentation, the specs should give a readable, plain-language overview of the behaviour. it with OAuth is nonsensical.

Even though scenario is an alias of it, I feel that it would better map to a combination of context and it. For example:

scenario "with OAuth" do
  sign_in_with_oauth
  expect(page).to have_text("Welcome")
end

Would become:

context "with OAuth" do
  it "authenticates successfully" do
    sign_in_with_oauth
    expect(page).to have_text("Welcome")
  end
end

Any thoughts on this @rspeicher?

@rspeicher
Copy link
Contributor

@andyw8 That would improve the documentation format, but so would it "authenticates with OAuth successfully".

I'm not sure the gem should be suggesting the context/it combo, because not every description needs it, and it would make autocorrecting extremely difficult (where would "authenticates successfully" come from in this case?)

@andyw8
Copy link
Collaborator Author

andyw8 commented Nov 20, 2017

Yes, "authenticates with OAuth successfully" would be fine.

I think trying to auto-correct from the Capybara DSL to plain RSpec is going to be difficult in many cases. I wonder if it's better not to try, rather than make bad corrections?

@rspeicher
Copy link
Contributor

Even making bad corrections/suggestions would be difficult, since we're basically parsing English (or any other natural language) at that point, right?

@andyw8
Copy link
Collaborator Author

andyw8 commented Nov 20, 2017

Indeed. So maybe the cop should just report the problem rather than try making any fix, e.g. Prefer native RSpec over Capybara's acceptance test DSL ('given')

cc @backus for any thoughts.

@mvz
Copy link
Contributor

mvz commented Mar 9, 2018

See also #538 for another issue with this cop's suggestions.

@bquorning
Copy link
Collaborator

I am closing this issue, since the RSpec/Capybara/FeatureMethods cop was removed in #1876 / v3.0.0.

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

No branches or pull requests

4 participants