Skip to content

Commit

Permalink
Fix duplicated spec descriptions
Browse files Browse the repository at this point in the history
Found these offending spec descriptions while testing out
rubocop/rubocop-rspec#259. Searching for duplicate spec descriptions
revealed a few categories of issues:

1. Examples with repeated descriptions that tested different cases
   but didn't describe the specific difference. For example:

    ```ruby
    it 'autocorrects' do
      new_source = autocorrect_source(cop, '"this is the #{}"')
      expect(new_source).to eq('"this is the "')
    end

    it 'autocorrects' do
      new_source = autocorrect_source(cop, '"this is the #{ }"')
      expect(new_source).to eq('"this is the "')
    end
    ```

2. Examples with repeated descriptions where one or more descriptions
   were wrong. For example:

    ```ruby
    it 'does not register offense if range startpoint is not constant' do
      inspect_source(cop, '(a..10).each {}')
      expect(cop.offenses).to be_empty
    end

    it 'does not register offense if range startpoint is not constant' do
      inspect_source(cop, '(0..b).each {}')
      expect(cop.offenses).to be_empty
    end
    ```

3. Redundant examples where the spec and its corresponding description
   showed up twice in the same context. For example:

    ```ruby
    it 'picks ruby executable files with no extension' do
      expect(found_basenames).to include('executable')
    end

    # ...

    it 'picks ruby executable files with no extension' do
      expect(found_basenames).to include('executable')
    end
    ```
  • Loading branch information
SerhiiMisiura committed Oct 12, 2018
1 parent 384a58f commit f1f2f6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spec/rubocop/cop/performance/detect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
expect(cop.messages).to eq(["Use `detect` instead of `#{method}.first`."])
end

it "registers an offense when first is called on multiline #{method}" do
it "registers an offense when last is called on multiline #{method}" do
inspect_source(cop, ["[1, 2, 3].#{method} do |i|",
' i % 2 == 0',
'end.last'])
Expand Down

0 comments on commit f1f2f6b

Please sign in to comment.