forked from dependabot/dependabot-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spec_helper.rb
43 lines (36 loc) · 1005 Bytes
/
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
# typed: false
# frozen_string_literal: true
def common_dir
@common_dir ||= Gem::Specification.find_by_name("dependabot-common").gem_dir
end
def require_common_spec(path)
require "#{common_dir}/spec/dependabot/#{path}"
end
def run_git(args, dir)
stdout, stderr, status = Open3.capture3(
{
"GIT_AUTHOR_NAME" => "Pub Test",
"GIT_AUTHOR_EMAIL" => "pub@dartlang.org",
"GIT_COMMITTER_NAME" => "Pub Test",
"GIT_COMMITTER_EMAIL" => "pub@dartlang.org",
# To make stable commits ids we fix the date.
"GIT_COMMITTER_DATE" => "1970-01-01T00:00:00.000",
"GIT_AUTHOR_DATE" => "1970-01-01T00:00:00.000"
},
"git",
*args,
chdir: dir
)
raise "git #{args.join(' ')} failed `#{stdout}` `#{stderr}`" if status != 0
stdout
end
shared_context "with temp dir" do
around do |example|
Dir.mktmpdir("rspec-") do |dir|
@temp_dir = dir
example.run
end
end
attr_reader :temp_dir
end
require "#{common_dir}/spec/spec_helper.rb"