Skip to content

Commit da7da89

Browse files
Chef unit test
Signed-off-by: Hanwen <[email protected]>
1 parent 32623e2 commit da7da89

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

cookbooks/aws-parallelcluster-platform/spec/spec_helper.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'chefspec'
2-
31
require_relative '../../aws-parallelcluster-shared/spec/spec_helper'
42

53
RSpec.configure do |c|

cookbooks/aws-parallelcluster-shared/spec/spec_helper.rb

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,26 @@
33
# Chef::Mixin::ShellOut is required to mock shellout
44
include Chef::Mixin::ShellOut
55

6+
# Set default cookbook path for ChefSpec
7+
module ChefSpecCookbookPath
8+
def initialize(options = {})
9+
options[:cookbook_path] ||= [
10+
File.expand_path('../..', __dir__),
11+
File.expand_path('../../cookbooks', __dir__),
12+
File.expand_path('../../cookbooks/third-party', __dir__)
13+
]
14+
super(options)
15+
end
16+
end
17+
18+
ChefSpec::SoloRunner.prepend(ChefSpecCookbookPath)
19+
620
RSpec.configure do |c|
21+
c.cookbook_path = [
22+
File.expand_path('../..', __dir__),
23+
File.expand_path('../../cookbooks', __dir__),
24+
File.expand_path('../../cookbooks/third-party', __dir__)
25+
]
726
c.before(:each) do
827
allow(File).to receive(:exist?).and_call_original
928
allow(Dir).to receive(:exist?).and_call_original
@@ -58,7 +77,16 @@ def for_all_node_types
5877
end
5978

6079
def runner(platform:, version:, step_into: [])
61-
ChefSpec::SoloRunner.new(platform: platform, version: version, step_into: step_into) do |node|
80+
ChefSpec::SoloRunner.new(
81+
platform: platform,
82+
version: version,
83+
step_into: step_into,
84+
cookbook_path: [
85+
File.expand_path('../..', __dir__),
86+
File.expand_path('../../cookbooks', __dir__),
87+
File.expand_path('../../cookbooks/third-party', __dir__)
88+
]
89+
) do |node|
6290
yield node if block_given?
6391
end
6492
end

0 commit comments

Comments
 (0)