-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathspec_helper.rb
52 lines (39 loc) · 1.41 KB
/
spec_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true
require 'rubocop'
require 'rubocop/rspec/shared_contexts/default_rspec_language_config_context'
require 'rubocop/rspec/support' # `expect_offense` etc
require 'simplecov' unless ENV['NO_COVERAGE']
module SpecHelper
ROOT = Pathname.new(__dir__).parent.freeze
end
spec_helper_glob =
'{support,shared,../lib/rubocop/rspec/shared_contexts}/*.rb'
Dir
.glob(File.expand_path(spec_helper_glob, __dir__))
.sort
.each(&method(:require))
RSpec.configure do |config|
# Set metadata so smoke tests are run on all cop specs
config.define_derived_metadata(
file_path: %r{/spec/rubocop/cop/}
) do |meta|
meta[:type] = :cop_spec
end
# Include config shared context for all cop specs
config.define_derived_metadata(type: :cop_spec) do |meta|
meta[:config] = true
end
config.order = :random
# Run focused tests with `fdescribe`, `fit`, `:focus` etc.
config.filter_run_when_matching :focus
# We should address configuration warnings when we upgrade
config.raise_errors_for_deprecations!
# RSpec gives helpful warnings when you are doing something wrong.
# We should take their advice!
config.raise_on_warning = true
config.include_context 'with default RSpec/Language config', :config
config.include_context 'smoke test', type: :cop_spec
end
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rubocop-rspec'
require 'rubocop-rspec_rails'