-
-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathspec_helper.rb
More file actions
67 lines (49 loc) · 1.23 KB
/
spec_helper.rb
File metadata and controls
67 lines (49 loc) · 1.23 KB
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
require 'simplecov'
SimpleCov.start
require 'rspec'
require 'bundler/audit/database'
module Fixtures
ROOT = File.expand_path('../fixtures',__FILE__)
TMP_DIR = File.expand_path('../tmp',__FILE__)
module Database
PATH = File.join(ROOT,'database')
COMMIT = '137a425b9f4f30f895df8765b0e773400170803d'
def self.clone
system 'git', 'clone', '--quiet', Bundler::Audit::Database::URL, PATH
end
def self.reset!(commit=COMMIT)
Dir.chdir(PATH) do
system 'git', 'reset', '--hard', commit
end
end
end
def self.join(*paths)
File.join(ROOT,*paths)
end
end
module Helpers
def sh(command, options={})
result = `#{command} 2>&1`
if $?.success? == !!options[:fail]
raise "FAILED #{command}\n#{result}"
end
result
end
def decolorize(string)
string.gsub(/\e\[\d+m/, "")
end
end
include Bundler::Audit
RSpec.configure do |config|
include Helpers
config.before(:suite) do
unless File.directory?(Fixtures::Database::PATH)
Fixtures::Database.clone
end
Fixtures::Database.reset!
FileUtils.mkdir_p(Fixtures::TMP_DIR)
end
config.before(:each) do
stub_const("Bundler::Audit::Database::DEFAULT_PATH",Fixtures::Database::PATH)
end
end