Skip to content

Commit a932e16

Browse files
committed
Clean up our spec helper
- Use the same block variable name both times `define_derived_metadata` is called. - Use `each` instead of `map` when not using the returned array anyway. - RSpec will add `/spec` to the load path, so we don't need to.
1 parent fc8422a commit a932e16

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

spec/spec_helper.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
require 'rubocop'
4-
54
require 'rubocop/rspec/support'
65

76
if ENV['COVERAGE'] == 'true'
@@ -14,16 +13,17 @@ module SpecHelper
1413
end
1514

1615
spec_helper_glob = File.expand_path('{support,shared}/*.rb', __dir__)
17-
Dir.glob(spec_helper_glob).map(&method(:require))
16+
Dir.glob(spec_helper_glob).sort.each(&method(:require))
1817

1918
RSpec.configure do |config|
19+
# Set metadata so smoke tests are run on all cop specs
2020
config.define_derived_metadata(file_path: %r{/spec/rubocop/cop/}) do |meta|
2121
meta[:type] = :cop_spec
2222
end
2323

2424
# Include config shared context for all cop specs
25-
config.define_derived_metadata(type: :cop_spec) do |metadata|
26-
metadata[:config] = true
25+
config.define_derived_metadata(type: :cop_spec) do |meta|
26+
meta[:config] = true
2727
end
2828

2929
config.order = :random
@@ -42,6 +42,5 @@ module SpecHelper
4242
end
4343

4444
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
45-
$LOAD_PATH.unshift(File.dirname(__FILE__))
4645

4746
require 'rubocop-rspec'

0 commit comments

Comments
 (0)