Sha256: 3176b162b3b3790929f492eca7d3646ce18f306f5eb8ca3961e7df7338a1d97b

Contents?: true

Size: 692 Bytes

Versions: 4

Compression:

Stored size: 692 Bytes

Contents

# frozen_string_literal: true

RSpec.describe 'Project requires' do
  it 'alphabetizes cop requires' do
    source   = SpecHelper::ROOT.join('lib', 'rubocop', 'cop', 'rspec_cops.rb')
    captures = source.read.scan(%r{^(require_relative 'rspec/(.*?/)?(.*?)')$})

    require_statements = captures.map(&:first)
    sorted_require_statements =
      captures.sort_by do |_require_statement, cop_category, name|
        [cop_category || 'rspec', name]
      end.map(&:first)

    aggregate_failures do
      # Sanity check that we actually discovered require statements.
      expect(captures).not_to be_empty
      expect(require_statements).to eql(sorted_require_statements)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-rspec-1.35.0 spec/project/project_requires_spec.rb
rubocop-rspec-1.34.1 spec/project/project_requires_spec.rb
rubocop-rspec-1.34.0 spec/project/project_requires_spec.rb
rubocop-rspec-1.33.0 spec/project/project_requires_spec.rb