chefspec 8.0.1 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +16 -9
- data/Rakefile +60 -52
- data/chefspec.gemspec +20 -20
- data/lib/chefspec.rb +29 -29
- data/lib/chefspec/api.rb +15 -13
- data/lib/chefspec/api/core.rb +3 -3
- data/lib/chefspec/api/described.rb +3 -5
- data/lib/chefspec/api/include_any_recipe.rb +24 -0
- data/lib/chefspec/api/stubs.rb +2 -2
- data/lib/chefspec/api/stubs_for.rb +23 -20
- data/lib/chefspec/berkshelf.rb +4 -4
- data/lib/chefspec/cacher.rb +2 -2
- data/lib/chefspec/coverage.rb +35 -40
- data/lib/chefspec/coverage/filters.rb +18 -15
- data/lib/chefspec/deprecations.rb +3 -3
- data/lib/chefspec/errors.rb +7 -7
- data/lib/chefspec/expect_exception.rb +2 -1
- data/lib/chefspec/extensions.rb +14 -13
- data/lib/chefspec/extensions/chef/client.rb +3 -3
- data/lib/chefspec/extensions/chef/conditional.rb +2 -1
- data/lib/chefspec/extensions/chef/cookbook/gem_installer.rb +5 -4
- data/lib/chefspec/extensions/chef/cookbook_loader.rb +1 -0
- data/lib/chefspec/extensions/chef/cookbook_uploader.rb +1 -1
- data/lib/chefspec/extensions/chef/data_query.rb +3 -3
- data/lib/chefspec/extensions/chef/lwrp_base.rb +1 -0
- data/lib/chefspec/extensions/chef/provider.rb +8 -5
- data/lib/chefspec/extensions/chef/resource.rb +18 -12
- data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +2 -1
- data/lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb +21 -1
- data/lib/chefspec/extensions/chef/securable.rb +1 -1
- data/lib/chefspec/extensions/ohai/system.rb +11 -0
- data/lib/chefspec/file_cache_path_proxy.rb +3 -3
- data/lib/chefspec/formatter.rb +15 -3
- data/lib/chefspec/librarian.rb +7 -6
- data/lib/chefspec/matchers.rb +9 -8
- data/lib/chefspec/matchers/do_nothing_matcher.rb +15 -15
- data/lib/chefspec/matchers/include_any_recipe_matcher.rb +51 -0
- data/lib/chefspec/matchers/include_recipe_matcher.rb +1 -1
- data/lib/chefspec/matchers/link_to_matcher.rb +2 -2
- data/lib/chefspec/matchers/notifications_matcher.rb +5 -4
- data/lib/chefspec/matchers/render_file_matcher.rb +3 -3
- data/lib/chefspec/matchers/resource_matcher.rb +18 -16
- data/lib/chefspec/mixins/normalize.rb +1 -1
- data/lib/chefspec/policyfile.rb +6 -6
- data/lib/chefspec/renderer.rb +4 -4
- data/lib/chefspec/rspec.rb +1 -1
- data/lib/chefspec/runner.rb +1 -1
- data/lib/chefspec/server.rb +1 -1
- data/lib/chefspec/server_methods.rb +8 -8
- data/lib/chefspec/server_runner.rb +10 -10
- data/lib/chefspec/solo_runner.rb +26 -24
- data/lib/chefspec/stubs/command_registry.rb +1 -1
- data/lib/chefspec/stubs/command_stub.rb +1 -1
- data/lib/chefspec/stubs/data_bag_item_registry.rb +1 -1
- data/lib/chefspec/stubs/data_bag_item_stub.rb +1 -1
- data/lib/chefspec/stubs/data_bag_registry.rb +1 -1
- data/lib/chefspec/stubs/data_bag_stub.rb +1 -1
- data/lib/chefspec/stubs/registry.rb +1 -1
- data/lib/chefspec/stubs/search_registry.rb +2 -2
- data/lib/chefspec/stubs/search_stub.rb +2 -2
- data/lib/chefspec/util.rb +7 -7
- data/lib/chefspec/version.rb +1 -1
- data/lib/chefspec/zero_server.rb +4 -4
- data/spec/spec_helper.rb +3 -4
- data/spec/support/hash.rb +3 -3
- data/spec/unit/cacher_spec.rb +17 -17
- data/spec/unit/coverage/filters_spec.rb +16 -16
- data/spec/unit/deprecations_spec.rb +8 -9
- data/spec/unit/errors_spec.rb +15 -15
- data/spec/unit/expect_exception_spec.rb +9 -9
- data/spec/unit/macros_spec.rb +50 -50
- data/spec/unit/matchers/do_nothing_matcher.rb +1 -1
- data/spec/unit/matchers/include_any_recipe_matcher_spec.rb +52 -0
- data/spec/unit/matchers/include_recipe_matcher_spec.rb +15 -15
- data/spec/unit/matchers/link_to_matcher_spec.rb +18 -18
- data/spec/unit/matchers/notifications_matcher_spec.rb +15 -16
- data/spec/unit/matchers/render_file_matcher_spec.rb +26 -26
- data/spec/unit/matchers/resource_matcher_spec.rb +1 -1
- data/spec/unit/matchers/state_attrs_matcher_spec.rb +24 -24
- data/spec/unit/matchers/subscribes_matcher_spec.rb +27 -29
- data/spec/unit/renderer_spec.rb +36 -36
- data/spec/unit/server_runner_spec.rb +6 -6
- data/spec/unit/solo_runner_spec.rb +69 -69
- data/spec/unit/stubs/command_registry_spec.rb +11 -11
- data/spec/unit/stubs/command_stub_spec.rb +26 -26
- data/spec/unit/stubs/data_bag_item_registry_spec.rb +17 -17
- data/spec/unit/stubs/data_bag_item_stub_spec.rb +14 -14
- data/spec/unit/stubs/data_bag_registry_spec.rb +16 -16
- data/spec/unit/stubs/data_bag_stub_spec.rb +13 -13
- data/spec/unit/stubs/registry_spec.rb +9 -9
- data/spec/unit/stubs/search_registry_spec.rb +17 -17
- data/spec/unit/stubs/search_stub_spec.rb +14 -14
- data/spec/unit/stubs/stub_spec.rb +22 -22
- metadata +16 -12
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Force loading Chef Config to fix a bad dependency tree. See
|
|
2
2
|
# https://github.com/opscode/chef/issues/2703 for more information.
|
|
3
|
-
require
|
|
3
|
+
require "chef/config"
|
|
4
4
|
|
|
5
5
|
# Providers has to be included before client... probably a weird
|
|
6
6
|
# include missing in Chef-land, but we can make sure we get it right anyway.
|
|
7
|
-
require
|
|
8
|
-
require
|
|
7
|
+
require "chef/providers"
|
|
8
|
+
require "chef/client"
|
|
9
9
|
|
|
10
10
|
# @private
|
|
11
11
|
Chef::Client.prepend(Module.new do
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "chef/resource/conditional"
|
|
2
2
|
|
|
3
3
|
Chef::Resource::Conditional.prepend(Module.new do
|
|
4
4
|
# @see Chef::Resource::Conditional#evaluate_command
|
|
5
5
|
def evaluate_command
|
|
6
6
|
return super unless $CHEFSPEC_MODE
|
|
7
|
+
|
|
7
8
|
stub = ChefSpec::Stubs::CommandRegistry.stub_for(@command)
|
|
8
9
|
|
|
9
10
|
if stub.nil?
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "chef/cookbook/gem_installer"
|
|
2
2
|
|
|
3
3
|
Chef::Cookbook::GemInstaller.prepend(Module.new do
|
|
4
4
|
# Installs the gems into the omnibus gemset.
|
|
5
5
|
def install
|
|
6
6
|
return super unless $CHEFSPEC_MODE
|
|
7
|
+
|
|
7
8
|
cookbook_gems = Hash.new { |h, k| h[k] = [] }
|
|
8
9
|
|
|
9
10
|
cookbook_collection.each do |cookbook_name, cookbook_version|
|
|
@@ -20,10 +21,10 @@ Chef::Cookbook::GemInstaller.prepend(Module.new do
|
|
|
20
21
|
private
|
|
21
22
|
|
|
22
23
|
def locate_gem(gem_name, gem_requirements)
|
|
23
|
-
::Gem::Specification
|
|
24
|
+
::Gem::Specification.find_by_name(gem_name, gem_requirements)
|
|
24
25
|
rescue ::Gem::MissingSpecError
|
|
25
|
-
gem_cmd = "gem install #{gem_name} --version '#{gem_requirements.join(
|
|
26
|
-
gemfile_line = "gem '#{[gem_name, *gem_requirements].join('
|
|
26
|
+
gem_cmd = "gem install #{gem_name} --version '#{gem_requirements.join(", ")}'"
|
|
27
|
+
gemfile_line = "gem '#{[gem_name, *gem_requirements].join("', '")}'"
|
|
27
28
|
warn "No matching version found for '#{gem_name}' in your gem environment.\n" \
|
|
28
29
|
" - if you are using Chef Workstation, run the following command: \"chef #{gem_cmd}\"\n" \
|
|
29
30
|
" - if you are using bundler, append \"#{gemfile_line}\" to your Gemfile and run \"bundle install\"\n" \
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "chef/dsl/data_query"
|
|
2
2
|
|
|
3
3
|
Chef::DSL::DataQuery.prepend(Module.new do
|
|
4
4
|
# @see Chef::DSL::DataQuery#search
|
|
@@ -6,7 +6,7 @@ Chef::DSL::DataQuery.prepend(Module.new do
|
|
|
6
6
|
return super unless Chef::Config[:solo] && $CHEFSPEC_MODE
|
|
7
7
|
|
|
8
8
|
type = args[0]
|
|
9
|
-
query = args[1] ||
|
|
9
|
+
query = args[1] || "*:*"
|
|
10
10
|
stub = ChefSpec::Stubs::SearchRegistry.stub_for(type, query)
|
|
11
11
|
|
|
12
12
|
if stub.nil?
|
|
@@ -14,7 +14,7 @@ Chef::DSL::DataQuery.prepend(Module.new do
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
if block
|
|
17
|
-
Array(stub.result).each {|r| block.call(r) }
|
|
17
|
+
Array(stub.result).each { |r| block.call(r) }
|
|
18
18
|
true
|
|
19
19
|
else
|
|
20
20
|
stub.result
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require
|
|
2
|
-
|
|
1
|
+
require "chef/provider"
|
|
2
|
+
require_relative "../../api"
|
|
3
3
|
|
|
4
4
|
Chef::Provider.prepend(Module.new do
|
|
5
5
|
def self.name
|
|
@@ -20,17 +20,20 @@ Chef::Provider.prepend(Module.new do
|
|
|
20
20
|
if ChefSpec::API::StubsFor::HAS_SHELLOUT_COMPACTED.satisfied_by?(Gem::Version.create(Chef::VERSION))
|
|
21
21
|
def shell_out_compacted(*args)
|
|
22
22
|
return super unless $CHEFSPEC_MODE
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
raise ChefSpec::Error::ShellOutNotStubbed.new(args: args, type: "provider", resource: new_resource)
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
def shell_out_compacted!(*args)
|
|
27
28
|
return super unless $CHEFSPEC_MODE
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
shell_out_compacted(*args).tap(&:error!)
|
|
29
31
|
end
|
|
30
32
|
else
|
|
31
33
|
def shell_out(*args)
|
|
32
34
|
return super unless $CHEFSPEC_MODE
|
|
33
|
-
|
|
35
|
+
|
|
36
|
+
raise ChefSpec::Error::ShellOutNotStubbed.new(args: args, type: "provider", resource: new_resource)
|
|
34
37
|
end
|
|
35
38
|
end
|
|
36
39
|
end)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
|
|
1
|
+
require "chef/resource"
|
|
2
|
+
require "chef/version"
|
|
3
|
+
require_relative "../../api"
|
|
4
4
|
|
|
5
5
|
#
|
|
6
6
|
# Three concerns:
|
|
@@ -21,25 +21,27 @@ module ChefSpec::Extensions::Chef::Resource
|
|
|
21
21
|
# If we're directly inside a `load_current_resource`, this is probably
|
|
22
22
|
# something like `new_resource.class.new` so we want to call this a current_resource,
|
|
23
23
|
# Otherwise it's probably a normal resource instantiation.
|
|
24
|
-
mode =
|
|
24
|
+
mode = :resource
|
|
25
|
+
mode = :current_value if caller.any? { |x| x.include?("`load_current_resource'") || x.include?("`load_after_resource'") }
|
|
25
26
|
ChefSpec::API::StubsFor.setup_stubs_for(self, mode)
|
|
26
27
|
end
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def dup
|
|
30
31
|
return super unless $CHEFSPEC_MODE
|
|
32
|
+
|
|
31
33
|
# Also here be dragons.
|
|
32
|
-
stack = caller
|
|
33
34
|
super.tap do |dup_resource|
|
|
34
35
|
# We're directly inside a load_current_resource, which is probably via
|
|
35
36
|
# the load_current_value DSL system, so call this a current resource.
|
|
36
|
-
ChefSpec::API::StubsFor.setup_stubs_for(dup_resource, :
|
|
37
|
+
ChefSpec::API::StubsFor.setup_stubs_for(dup_resource, :current_value) if caller.any? { |x| x.include?("`load_current_resource'") || x.include?("`load_after_resource'") }
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
# mix of no-op and tracking concerns
|
|
41
42
|
def run_action(action, notification_type = nil, notifying_resource = nil)
|
|
42
43
|
return super unless $CHEFSPEC_MODE
|
|
44
|
+
|
|
43
45
|
resolve_notification_references
|
|
44
46
|
validate_action(action)
|
|
45
47
|
|
|
@@ -67,17 +69,20 @@ module ChefSpec::Extensions::Chef::Resource
|
|
|
67
69
|
if ChefSpec::API::StubsFor::HAS_SHELLOUT_COMPACTED.satisfied_by?(Gem::Version.create(Chef::VERSION))
|
|
68
70
|
def shell_out_compacted(*args)
|
|
69
71
|
return super unless $CHEFSPEC_MODE
|
|
70
|
-
|
|
72
|
+
|
|
73
|
+
raise ChefSpec::Error::ShellOutNotStubbed.new(args: args, type: "resource", resource: self)
|
|
71
74
|
end
|
|
72
75
|
|
|
73
76
|
def shell_out_compacted!(*args)
|
|
74
77
|
return super unless $CHEFSPEC_MODE
|
|
75
|
-
|
|
78
|
+
|
|
79
|
+
shell_out_compacted(*args).tap(&:error!)
|
|
76
80
|
end
|
|
77
81
|
else
|
|
78
82
|
def shell_out(*args)
|
|
79
83
|
return super unless $CHEFSPEC_MODE
|
|
80
|
-
|
|
84
|
+
|
|
85
|
+
raise ChefSpec::Error::ShellOutNotStubbed.new(args: args, type: "resource", resource: self)
|
|
81
86
|
end
|
|
82
87
|
end
|
|
83
88
|
|
|
@@ -133,15 +138,15 @@ module ChefSpec::Extensions::Chef::Resource
|
|
|
133
138
|
super
|
|
134
139
|
end
|
|
135
140
|
|
|
136
|
-
def provides(name,
|
|
141
|
+
def provides(name, **options, &block)
|
|
137
142
|
provides_names << name unless provides_names.include?(name)
|
|
138
143
|
inject_actions(*allowed_actions)
|
|
139
144
|
super
|
|
140
145
|
end
|
|
141
146
|
|
|
142
|
-
def action(sym, &block)
|
|
147
|
+
def action(sym, description: nil, &block)
|
|
143
148
|
inject_actions(sym)
|
|
144
|
-
super
|
|
149
|
+
super(sym, &block)
|
|
145
150
|
end
|
|
146
151
|
|
|
147
152
|
def allowed_actions(*actions)
|
|
@@ -167,6 +172,7 @@ module ChefSpec::Extensions::Chef::Resource
|
|
|
167
172
|
def inject_actions(*actions)
|
|
168
173
|
provides_names.each do |resource_name|
|
|
169
174
|
next unless resource_name
|
|
175
|
+
|
|
170
176
|
ChefSpec.define_matcher(resource_name)
|
|
171
177
|
actions.each do |action|
|
|
172
178
|
inject_method(:"#{action}_#{resource_name}", resource_name, action)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "chef/resource/freebsd_package"
|
|
2
2
|
|
|
3
3
|
Chef::Resource::FreebsdPackage.prepend(Module.new do
|
|
4
4
|
#
|
|
@@ -11,6 +11,7 @@ Chef::Resource::FreebsdPackage.prepend(Module.new do
|
|
|
11
11
|
#
|
|
12
12
|
def supports_pkgng?
|
|
13
13
|
return super unless $CHEFSPEC_MODE
|
|
14
|
+
|
|
14
15
|
true
|
|
15
16
|
end
|
|
16
17
|
end)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "chef/run_context/cookbook_compiler"
|
|
2
2
|
|
|
3
3
|
Chef::RunContext::CookbookCompiler.prepend(Module.new do
|
|
4
4
|
# List of compile phases as of Chef 14:
|
|
@@ -15,27 +15,44 @@ Chef::RunContext::CookbookCompiler.prepend(Module.new do
|
|
|
15
15
|
|
|
16
16
|
def load_libraries_from_cookbook(cookbook)
|
|
17
17
|
return super unless $CHEFSPEC_MODE
|
|
18
|
+
|
|
18
19
|
$CHEFSPEC_LIBRARY_PRELOAD ||= {}
|
|
19
20
|
# Already loaded this once.
|
|
20
21
|
return if $CHEFSPEC_LIBRARY_PRELOAD[cookbook]
|
|
22
|
+
|
|
21
23
|
$CHEFSPEC_LIBRARY_PRELOAD[cookbook] = true
|
|
22
24
|
super
|
|
23
25
|
end
|
|
24
26
|
|
|
27
|
+
def load_ohai_plugins_from_cookbook(cookbook)
|
|
28
|
+
return super unless $CHEFSPEC_MODE
|
|
29
|
+
|
|
30
|
+
$CHEFSPEC_OHAI_PRELOAD ||= {}
|
|
31
|
+
# Already loaded this once.
|
|
32
|
+
return if $CHEFSPEC_OHAI_PRELOAD[cookbook]
|
|
33
|
+
|
|
34
|
+
$CHEFSPEC_OHAI_PRELOAD[cookbook] = true
|
|
35
|
+
super
|
|
36
|
+
end
|
|
37
|
+
|
|
25
38
|
def load_lwrps_from_cookbook(cookbook)
|
|
26
39
|
return super unless $CHEFSPEC_MODE
|
|
40
|
+
|
|
27
41
|
$CHEFSPEC_LWRP_PRELOAD ||= {}
|
|
28
42
|
# Already loaded this once.
|
|
29
43
|
return if $CHEFSPEC_LWRP_PRELOAD[cookbook]
|
|
44
|
+
|
|
30
45
|
$CHEFSPEC_LWRP_PRELOAD[cookbook] = true
|
|
31
46
|
super
|
|
32
47
|
end
|
|
33
48
|
|
|
34
49
|
def load_resource_definitions_from_cookbook(cookbook)
|
|
35
50
|
return super unless $CHEFSPEC_MODE
|
|
51
|
+
|
|
36
52
|
$CHEFSPEC_DEFINITION_PRELOAD ||= {}
|
|
37
53
|
# Already loaded this once.
|
|
38
54
|
return if $CHEFSPEC_DEFINITION_PRELOAD[cookbook]
|
|
55
|
+
|
|
39
56
|
$CHEFSPEC_DEFINITION_PRELOAD[cookbook] = true
|
|
40
57
|
super
|
|
41
58
|
end
|
|
@@ -47,18 +64,21 @@ Chef::RunContext::CookbookCompiler.prepend(Module.new do
|
|
|
47
64
|
def compile_ohai_plugins
|
|
48
65
|
return super unless $CHEFSPEC_MODE
|
|
49
66
|
return if $CHEFSPEC_PRELOAD
|
|
67
|
+
|
|
50
68
|
super
|
|
51
69
|
end
|
|
52
70
|
|
|
53
71
|
def compile_attributes
|
|
54
72
|
return super unless $CHEFSPEC_MODE
|
|
55
73
|
return if $CHEFSPEC_PRELOAD
|
|
74
|
+
|
|
56
75
|
super
|
|
57
76
|
end
|
|
58
77
|
|
|
59
78
|
def compile_recipes
|
|
60
79
|
return super unless $CHEFSPEC_MODE
|
|
61
80
|
return if $CHEFSPEC_PRELOAD
|
|
81
|
+
|
|
62
82
|
super
|
|
63
83
|
end
|
|
64
84
|
end)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require "ohai/system"
|
|
2
|
+
|
|
3
|
+
Ohai::System.prepend(Module.new do
|
|
4
|
+
# If an Ohai segment exists, don't actually pull data in for ohai.
|
|
5
|
+
# (we have fake data for that)
|
|
6
|
+
# @see Ohai::System#run_additional_plugins
|
|
7
|
+
def run_additional_plugins(plugin_path)
|
|
8
|
+
return super unless $CHEFSPEC_MODE
|
|
9
|
+
# noop
|
|
10
|
+
end
|
|
11
|
+
end)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "fileutils" unless defined?(FileUtils)
|
|
2
|
+
require "singleton" unless defined?(Singleton)
|
|
3
3
|
|
|
4
4
|
module ChefSpec
|
|
5
5
|
class FileCachePathProxy
|
|
@@ -8,7 +8,7 @@ module ChefSpec
|
|
|
8
8
|
attr_reader :file_cache_path
|
|
9
9
|
|
|
10
10
|
def initialize
|
|
11
|
-
@file_cache_path = Dir.mktmpdir(
|
|
11
|
+
@file_cache_path = Dir.mktmpdir(%w{chefspec file_cache_path})
|
|
12
12
|
at_exit { FileUtils.rm_rf(@file_cache_path) }
|
|
13
13
|
end
|
|
14
14
|
end
|
data/lib/chefspec/formatter.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "chef/formatters/base"
|
|
2
|
+
require "chef/formatters/error_mapper"
|
|
3
3
|
|
|
4
4
|
module ChefSpec
|
|
5
5
|
class ChefFormatter < Chef::Formatters::Base
|
|
@@ -133,6 +133,18 @@ module ChefSpec
|
|
|
133
133
|
# Called when LWRPs are finished loading
|
|
134
134
|
def lwrp_load_complete; end
|
|
135
135
|
|
|
136
|
+
# Called when an ohai plugin file loading starts
|
|
137
|
+
def ohai_plugin_load_start(file_count); end
|
|
138
|
+
|
|
139
|
+
# Called when an ohai plugin file has been loaded
|
|
140
|
+
def ohai_plugin_file_loaded(path); end
|
|
141
|
+
|
|
142
|
+
# Called when an ohai plugin file has an error on load.
|
|
143
|
+
def ohai_plugin_file_load_failed(path, exception); end
|
|
144
|
+
|
|
145
|
+
# Called when an ohai plugin file loading has finished
|
|
146
|
+
def ohai_plugin_load_complete; end
|
|
147
|
+
|
|
136
148
|
# Called before attribute files are loaded
|
|
137
149
|
def attribute_load_start(attribute_file_count); end
|
|
138
150
|
|
|
@@ -190,7 +202,7 @@ module ChefSpec
|
|
|
190
202
|
def converge_complete; end
|
|
191
203
|
|
|
192
204
|
# Called before action is executed on a resource.
|
|
193
|
-
def resource_action_start(resource, action, notification_type=nil, notifier=nil); end
|
|
205
|
+
def resource_action_start(resource, action, notification_type = nil, notifier = nil); end
|
|
194
206
|
|
|
195
207
|
# Called when a resource fails, but will retry.
|
|
196
208
|
def resource_failed_retriable(resource, action, retry_count, exception); end
|
data/lib/chefspec/librarian.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
begin
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
2
|
+
require "librarian/chef/environment"
|
|
3
|
+
require "librarian/action/resolve"
|
|
4
|
+
require "librarian/action/install"
|
|
5
5
|
rescue LoadError
|
|
6
6
|
raise ChefSpec::Error::GemLoadError.new(
|
|
7
|
-
gem:
|
|
7
|
+
gem: "librarian-chef", name: "Librarian"
|
|
8
|
+
)
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
module ChefSpec
|
|
@@ -25,7 +26,7 @@ module ChefSpec
|
|
|
25
26
|
#
|
|
26
27
|
def setup!
|
|
27
28
|
env = ::Librarian::Chef::Environment.new(project_path: Dir.pwd)
|
|
28
|
-
@originalpath, env.config_db.local[
|
|
29
|
+
@originalpath, env.config_db.local["path"] = env.config_db.local["path"], @tmpdir
|
|
29
30
|
::Librarian::Action::Resolve.new(env).run
|
|
30
31
|
::Librarian::Action::Install.new(env).run
|
|
31
32
|
|
|
@@ -37,7 +38,7 @@ module ChefSpec
|
|
|
37
38
|
#
|
|
38
39
|
def teardown!
|
|
39
40
|
env = ::Librarian::Chef::Environment.new(project_path: Dir.pwd)
|
|
40
|
-
env.config_db.local[
|
|
41
|
+
env.config_db.local["path"] = @originalpath
|
|
41
42
|
|
|
42
43
|
FileUtils.rm_rf(@tmpdir) if File.exist?(@tmpdir)
|
|
43
44
|
end
|
data/lib/chefspec/matchers.rb
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
module ChefSpec
|
|
2
2
|
module Matchers
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
8
|
-
require_relative
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
3
|
+
require_relative "matchers/do_nothing_matcher"
|
|
4
|
+
require_relative "matchers/include_any_recipe_matcher"
|
|
5
|
+
require_relative "matchers/include_recipe_matcher"
|
|
6
|
+
require_relative "matchers/link_to_matcher"
|
|
7
|
+
require_relative "matchers/notifications_matcher"
|
|
8
|
+
require_relative "matchers/render_file_matcher"
|
|
9
|
+
require_relative "matchers/resource_matcher"
|
|
10
|
+
require_relative "matchers/state_attrs_matcher"
|
|
11
|
+
require_relative "matchers/subscribes_matcher"
|
|
11
12
|
end
|
|
12
13
|
end
|
|
@@ -14,37 +14,37 @@ module ChefSpec::Matchers
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def description
|
|
17
|
-
|
|
17
|
+
"do nothing"
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def failure_message
|
|
21
21
|
if @resource
|
|
22
|
-
message =
|
|
23
|
-
message <<
|
|
24
|
-
message <<
|
|
22
|
+
message = %{expected #{@resource} to do nothing, but the following }
|
|
23
|
+
message << %{actions were performed:}
|
|
24
|
+
message << %{\n\n}
|
|
25
25
|
@resource.performed_actions.each do |action|
|
|
26
|
-
message <<
|
|
26
|
+
message << %{ :#{action}}
|
|
27
27
|
end
|
|
28
28
|
message
|
|
29
29
|
else
|
|
30
|
-
message =
|
|
31
|
-
message <<
|
|
32
|
-
message <<
|
|
33
|
-
message <<
|
|
34
|
-
message <<
|
|
35
|
-
message <<
|
|
30
|
+
message = %{expected _something_ to do nothing, but the _something_ }
|
|
31
|
+
message << %{you gave me was nil! If you are running a test like:}
|
|
32
|
+
message << %{\n\n}
|
|
33
|
+
message << %{ expect(_something_).to do_nothing}
|
|
34
|
+
message << %{\n\n}
|
|
35
|
+
message << %{make sure that `_something_` exists, because I got nil!}
|
|
36
36
|
message
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def failure_message_when_negated
|
|
41
41
|
if @resource
|
|
42
|
-
message =
|
|
43
|
-
message <<
|
|
42
|
+
message = %{expected #{@resource} to do something, but no actions }
|
|
43
|
+
message << %{were performed.}
|
|
44
44
|
message
|
|
45
45
|
else
|
|
46
|
-
message =
|
|
47
|
-
message <<
|
|
46
|
+
message = %{expected _something_ to do something, but no actions }
|
|
47
|
+
message << %{were performed.}
|
|
48
48
|
message
|
|
49
49
|
end
|
|
50
50
|
end
|