rubocop-rspec icon indicating copy to clipboard operation
rubocop-rspec copied to clipboard

False positive for `RSpec/PendingWithoutReason` cop

Open ydakuka opened this issue 2 years ago • 2 comments

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 avatar Oct 17 '23 22:10 ydakuka

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

ydakuka avatar Oct 17 '23 22:10 ydakuka

Pending reason and the docstring are different.

pirj avatar Oct 18 '23 07:10 pirj