-
Notifications
You must be signed in to change notification settings - Fork 280
/
Copy pathspec_helper.rb
75 lines (61 loc) · 1.85 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# frozen_string_literal: true
require 'bundler'
require 'simplecov'
SimpleCov.start do
add_filter 'bin/'
add_filter 'libexec/'
add_filter 'spec/'
add_filter 'template-dir/'
if ENV['CI']
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.single_report_path = 'coverage/lcov.info'
end
formatter SimpleCov::Formatter::LcovFormatter
end
end
require 'overcommit'
require 'tempfile'
hook_types =
Dir[File.join(Overcommit::HOOK_DIRECTORY, '*')].
select { |f| File.directory?(f) }.
reject { |f| File.basename(f) == 'shared' }.
sort
hook_types.each do |hook_type|
require File.join(hook_type, 'base.rb')
Dir[File.join(hook_type, '**/*.rb')].
select { |f| File.file?(f) && File.basename(f, '.rb') != 'base' }.
sort.
each { |f| require f }
end
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].sort.each { |f| require f }
RSpec.configure do |config|
config.include GitSpecHelpers
config.include OutputHelpers
config.include ShellHelpers
# Continue to enable the older `should` syntax for expectations
config.expect_with :rspec do |c|
c.syntax = [:expect, :should]
end
config.mock_with :rspec do |c|
c.syntax = [:expect, :should]
end
config.around(:each) do |example|
# Most tests don't deal with verification, so disable it by default
env = {}
unless respond_to?(:enable_verification) && enable_verification
env['OVERCOMMIT_NO_VERIFY'] = '1'
end
Overcommit::Utils.with_environment env do
example.run
end
end
# Much of Overcommit depends on these helpers, so they are aggressively
# cached. Unset them before each example so we always get fresh values.
config.before(:each) do
%w[git_dir repo_root].each do |var|
Overcommit::Utils.instance_variable_set(:"@#{var}", nil)
end
end
end