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

Cop idea: Avoid example keyword #1732

Closed
ydakuka opened this issue Oct 17, 2023 · 4 comments
Closed

Cop idea: Avoid example keyword #1732

ydakuka opened this issue Oct 17, 2023 · 4 comments
Labels

Comments

@ydakuka
Copy link

ydakuka commented Oct 17, 2023

This is dialect of it and specify. There is no information in the guide how to use example. I think it should be done this way.

# bad
example 'answers success status' do
  expect(pinger.call).to eq(200)
end

# good
it 'answers success status' do
  expect(pinger.call).to eq(200)
end
@pirj
Copy link
Member

pirj commented Oct 18, 2023

‘it’ is certainly more common.
Related http://rspec.info/features/3-12/rspec-core/example-groups/aliasing/ - no info on example aliasing, though, but as you point out, it’s similar.
rubocop/rspec-style-guide#64 On it vs specify

@ydah
Copy link
Member

ydah commented Jan 12, 2024

For example, in system spec I have a use case that uses example. So I don't want it to be uniformly avoided.

example 'golden path to register user information' do
  #...
end

@pirj
Copy link
Member

pirj commented Jan 12, 2024

I think the Dialect cop would work for both cases, won’t it?

@ydah
Copy link
Member

ydah commented Feb 16, 2024

I think this should probably be mentioned in the Style guide about the use of example and it. You shouldn't create a cop that forces rubocop-rspec to do either, as shown below. So I'd like to close this issue. Thank you for your suggestion.

#1732 (comment)

@ydah ydah closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2024
@ydah ydah added the wontfix label Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants