rubocop-rspec: `RSpec/RepeatedExampleGroupBody` false positive
We have the following code: https://github.com/voxpupuli/puppet-trusted_ca/blob/428fa7425a69aa61bd7a18201a4b0bc876eddc50/spec/acceptance/certs_spec.rb#L47-L53
Copied here for an easier overview:
describe 'trusted_ca' do
# ... other code ...
describe command("/usr/bin/curl https://#{fact('hostname')}.example.com:443") do
its(:exit_status) { is_expected.to eq 0 }
end
describe command("cd /root && /usr/bin/java SSLPoke #{fact('hostname')}.example.com 443") do
its(:exit_status) { is_expected.to eq 0 }
end
end
This is using serverspec’s command and verifies the exit code is 0. Somehow this triggers RSpec/RepeatedExampleGroupBody but they’re clearly different. Is this a bug?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (11 by maintainers)
Commits related to this issue
- Modernize rspec syntax This takes lessons from the rubocop-rspec issue[1] and applies them to write a more modern style. This should be more compatible with future versions of rspec. [1]: https://gi... — committed to ekohl/puppet-trusted_ca by ekohl 2 years ago
- Modernize rspec syntax This takes lessons from the rubocop-rspec issue[1] and applies them to write a more modern style. This should be more compatible with future versions of rspec. [1]: https://gi... — committed to ekohl/puppet-trusted_ca by ekohl 2 years ago
- Modernize rspec syntax This takes lessons from the rubocop-rspec issue[1] and applies them to write a more modern style. This should be more compatible with future versions of rspec. [1]: https://gi... — committed to ekohl/puppet-trusted_ca by ekohl 2 years ago
- Modernize rspec syntax This takes lessons from the rubocop-rspec issue[1] and applies them to write a more modern style. This should be more compatible with future versions of rspec. [1]: https://gi... — committed to ekohl/puppet-trusted_ca by ekohl 2 years ago
- Modernize rspec syntax This takes lessons from the rubocop-rspec issue[1] and applies them to write a more modern style. This should be more compatible with future versions of rspec. [1]: https://gi... — committed to ekohl/puppet-trusted_ca by ekohl 2 years ago
I think for now there is nothing actionable here. It’s been very enlightening and I’ll have to see about changing the style we use in our tests. Thanks for the insights!
This issue has quickly become way more enlightening than I expected. I greatly appreciate it.
That looks very nice. I was not aware that this was possible.
So back to the original problem: how would I rewrite the commands listed in my initial message. They’re using rspec-its but looking at the matcher documentation I suppose
have_attributeswould be the correct matcher.I’ve opened https://github.com/voxpupuli/puppet-trusted_ca/pull/44 to try out this new syntax in a rather trivial module.