rubocop-rspec: RSpec/RepeatedDescription should not fire when using rspec-its

We are using rspec-its and after updating rubocop-rspec experienced a lot of reports for this rule violation.

We often use contexts and check the resulting objects for specific attribute values like so:

describe 'foo' do
  subject { my_subject }
  context 'bar' do
    its(:attrib1) { is_expected.to eq 'value1' }
    its(:attrib2) { is_expected.to eq 'value2' }
  end
end

rubocop-rspec complaints about the two its-statements sharing the same description.

We do not expect this rule to pick up those autogenerated descriptions.

(EDIT: I updated this text to better reflect the problem. Please note that the comment below by @pirj is referring to the previous content of this description which was not specific enough.)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 17 (13 by maintainers)

Most upvoted comments

@pirj sure, I was a little busy at work, but I believe that I can handle this in a week

@lazycoder9 Yet another interesting case to look at.

  describe '#sample' do
    subject(:operation) { OpenStruct.new(test_name: 'Test sample', attribute: 23) }

    its(:test_name) { is_expected.to eq 'Test sample' }
    its(:attribute) { is_expected.to eq 23 }
  end

this code raises these problems

spec/sample.rb:36:5: C: Don't repeat descriptions within an example group.
    its(:test_name) { is_expected.to eq 'Test sample' }
    ^^^^^^^^^^^^^^^
spec/sample.rb:37:5: C: Don't repeat descriptions within an example group.
    its(:attribute) { is_expected.to eq 23 }