Skip to content

Commit 7a3a7b2

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

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-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: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,22 @@
33
# Chef::Mixin::ShellOut is required to mock shellout
44
include Chef::Mixin::ShellOut
55

6+
# Set default cookbook path for ChefSpec
7+
ChefSpec::SoloRunner.send(:define_method, :initialize) do |options = {}|
8+
options[:cookbook_path] ||= [
9+
File.expand_path('../..', __dir__),
10+
File.expand_path('../../cookbooks', __dir__),
11+
File.expand_path('../../cookbooks/third-party', __dir__)
12+
]
13+
super(options)
14+
end
15+
616
RSpec.configure do |c|
17+
c.cookbook_path = [
18+
File.expand_path('../..', __dir__),
19+
File.expand_path('../../cookbooks', __dir__),
20+
File.expand_path('../../cookbooks/third-party', __dir__)
21+
]
722
c.before(:each) do
823
allow(File).to receive(:exist?).and_call_original
924
allow(Dir).to receive(:exist?).and_call_original
@@ -58,7 +73,16 @@ def for_all_node_types
5873
end
5974

6075
def runner(platform:, version:, step_into: [])
61-
ChefSpec::SoloRunner.new(platform: platform, version: version, step_into: step_into) do |node|
76+
ChefSpec::SoloRunner.new(
77+
platform: platform,
78+
version: version,
79+
step_into: step_into,
80+
cookbook_path: [
81+
File.expand_path('../..', __dir__),
82+
File.expand_path('../../cookbooks', __dir__),
83+
File.expand_path('../../cookbooks/third-party', __dir__)
84+
]
85+
) do |node|
6286
yield node if block_given?
6387
end
6488
end

0 commit comments

Comments
 (0)