Open
Description
We had a spec file where we were asserting against an oracle. Then, we discovered issues with the values themselves, so we switched to string interpolation. Unfortunately, with the string interpolation, RSpec/RepeatedExample says there is an issue, when the values are actually different.
Expected behavior
Given the following code:
RSpec.describe OrderTagsService, :order_tags do
let(:contingency_date) { ... }
let(:order) { ... }
context 'given an appointment-based order with one requested inspection' do
let!(:inspection) { create(:inspection, :requested, order:) }
context 'with no availabilities at all' do
describe 'the Ruby implementation' do
it { expect(subject).not_to be_urgent(order, now: T("#{contingency_date}T12:00-0700")) }
it { expect(subject).not_to be_urgent(order, now: T("#{contingency_date}T16:00-0700")) }
end
end
end
end
No Rubocop failures were expected. Note the string interpolation is different between the two lines.
In the trace below, these are lines 287 and 288.
Actual behavior
For /Users/francois/Projects/marketplace: configuration from /Users/francois/Projects/marketplace/.rubocop.yml
configuration from /Users/francois/.rvm/gems/ruby-3.2.4/gems/rubocop-rails-2.17.2/config/default.yml
configuration from /Users/francois/.rvm/gems/ruby-3.2.4/gems/rubocop-rails-2.17.2/config/default.yml
Default configuration from /Users/francois/.rvm/gems/ruby-3.2.4/gems/rubocop-1.43.0/config/default.yml
configuration from /Users/francois/.rvm/gems/ruby-3.2.4/gems/rubocop-rspec-2.15.0/config/default.yml
configuration from /Users/francois/.rvm/gems/ruby-3.2.4/gems/rubocop-rspec-2.15.0/config/default.yml
Inheriting configuration from /Users/francois/Projects/marketplace/.rubocop_todo.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /Users/francois/Projects/marketplace/spec/services/order_tags_service_spec.rb
Loading cache from /Users/francois/.cache/rubocop_cache/f851b9b9ba5b973bce8ba476853645abc5b75ef2/6d7a3b621ca1730e04accd938619e4bdab66cfb1/e3a436b429fad69dc8aa1d9be4ea25bdea422812
C
Offenses:
spec/services/order_tags_service_spec.rb:287:9: C: RSpec/RepeatedExample: Don't repeat examples within an example group.
it { expect(subject).not_to be_urgent(order, now: T("#{contingency_date}T12:00-0700")) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/order_tags_service_spec.rb:288:9: C: RSpec/RepeatedExample: Don't repeat examples within an example group.
it { expect(subject).not_to be_urgent(order, now: T("#{contingency_date}T16:00-0700")) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/order_tags_service_spec.rb:290:9: C: RSpec/RepeatedExample: Don't repeat examples within an example group.
it { expect(subject).not_to be_urgent(order, now: T("#{contingency_date}T12:00-0700")) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/order_tags_service_spec.rb:291:9: C: RSpec/RepeatedExample: Don't repeat examples within an example group.
it { expect(subject).not_to be_urgent(order, now: T("#{contingency_date}T16:00-0700")) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/order_tags_service_spec.rb:292:9: C: RSpec/RepeatedExample: Don't repeat examples within an example group.
it { expect(subject).to be_urgent(order, now: T("#{contingency_date}T17:00-0700")) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/order_tags_service_spec.rb:293:9: C: RSpec/RepeatedExample: Don't repeat examples within an example group.
it { expect(subject).to be_urgent(order, now: T("#{contingency_date}T12:00-0700")) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/order_tags_service_spec.rb:295:9: C: RSpec/RepeatedExample: Don't repeat examples within an example group.
it { expect(subject).to be_urgent(order, now: T("#{contingency_date}T17:00-0700")) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/order_tags_service_spec.rb:296:9: C: RSpec/RepeatedExample: Don't repeat examples within an example group.
it { expect(subject).to be_urgent(order, now: T("#{contingency_date}T12:00-0700")) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 8 offenses detected
Finished in 0.27164399999992384 seconds
Steps to reproduce the problem
Of course, I can't reproduce this issue on a fresh file. In the original
RuboCop version
$ rubocop -V
1.43.0 (using Parser 3.3.1.0, rubocop-ast 1.24.1, running on ruby 3.2.4) [arm64-darwin23]
- rubocop-rails 2.17.2
- rubocop-rspec 2.15.0
$ ruby --version
ruby 3.2.4 (2024-04-23 revision af471c0e01) [arm64-darwin23]
Metadata
Metadata
Assignees
Labels
No labels