rubocop / rubocop-rspec

Code style checking for RSpec files.
https://docs.rubocop.org/rubocop-rspec
MIT License
800 stars 276 forks source link

False positive for `RSpec/PendingWithoutReason` cop #1733

Open ydakuka opened 10 months ago

ydakuka commented 10 months ago

Describe the solution you'd like:

# good
xspecify do
  pending 'Need to upgrade to the latest HTTP gem version before this will work again.'
  expect(pinger.call).to eq(204)
end

# good
xit 'answers success status' do
  pending 'Need to upgrade to the latest HTTP gem version before this will work again.'
  expect(pinger.call).to eq(200)
end

terminal:

ydakuka@yauhenid:~/Work/main_app$ bin/rails_docker rubocop spec/models/user_spec.rb
Inspecting 1 file
C

Offenses:

spec/models/user_spec.rb:7:3: C: RSpec/PendingWithoutReason: Give the reason for xspecify.
  xspecify do
  ^^^^^^^^
spec/models/user_spec.rb:13:3: C: RSpec/PendingWithoutReason: Give the reason for xit.
  xit 'answers success status' do
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 2 offenses detected
ydakuka commented 10 months ago

xspecify and specify should not have a ~reason~ docstring (https://github.com/rubocop/rubocop-rspec/issues/1658) and the following example will be correct if I run rubocop:

# good
specify do
  pending 'Need to upgrade to the latest HTTP gem version before this will work again.'
  expect(pinger.call).to eq(204)
end
pirj commented 10 months ago

Pending reason and the docstring are different.