This repository has been archived by the owner on Dec 20, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspec_helper.rb
61 lines (51 loc) · 1.62 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
require 'chefspec'
require 'fauxhai'
# append repo home in load path
$:.unshift(File.expand_path("../..", __FILE__))
$:.unshift(File.expand_path("../../site-cookbooks", __FILE__))
module PagerDuty
module SpecHelper
def pd_cookbook_paths
cookbook_paths = []
%w{vendor site-cookbooks cookbooks }.each do |path|
cookbook_paths << File.expand_path("../../" + path, __FILE__)
end
cookbook_paths
end
def chef_repo
File.expand_path("../../", __FILE__)
end
def pd_data_bag_paths
Array(File.expand_path("../../data_bags" , __FILE__))
end
def pd_role_paths
Array(File.expand_path("../../roles" , __FILE__))
end
def mock_node(name, options = {})
n = Chef::Node.new
n.name(name)
n.set[:tags] = Array(options.delete(:tags))
n.automatic_attrs = options
n
end
def memoized_runner(recipe, options={})
@runner ||= begin
runner = ChefSpec::Runner.new(options)
yield runner.node if block_given?
runner.converge(recipe)
runner
end
end
end
end
Chef::Config[:http_retry_count] = 0
RSpec.configure do |config|
config.version = '12.04'
config.platform = 'ubuntu'
config.cookbook_path = %w{vendor site-cookbooks}.map{|p| File.expand_path("../../" + p, __FILE__)}
config.role_path = Array(File.expand_path("../../roles" , __FILE__))
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.include PagerDuty::SpecHelper
end