chefspec 3.0.0.beta.3 → 3.0.0.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chefspec.rb +0 -2
- data/lib/chefspec/extensions/chef/resource.rb +21 -5
- data/lib/chefspec/matchers/render_file_matcher.rb +3 -3
- data/lib/chefspec/runner.rb +23 -5
- data/lib/chefspec/version.rb +1 -1
- metadata +3 -5
- data/lib/chefspec/extensions/chef/provider.rb +0 -20
- data/lib/chefspec/reporter.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de6569c7801bd9192460934175605ba237962958
|
4
|
+
data.tar.gz: 005ba7b59b0d660be5b71565c4a8fa0c0edeb719
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b17504fd6a5fc2642a43a47a720cfedaac7cc0553efe9c0b243c3aac2cf0fc41c962807eb1e9531981bb89728535823f72d7c4375662900c6849b166cb7149db
|
7
|
+
data.tar.gz: cec924c49870eb6afb3fc9756fc7e4acf8cf5d44a8da80b7034e91f236ef05e26e334023ec7058058f47bf1f7b83fda23b4600f7e78b2e2404d26c4d52d27793
|
data/lib/chefspec.rb
CHANGED
@@ -4,7 +4,6 @@ require_relative 'chefspec/extensions/chef/client'
|
|
4
4
|
require_relative 'chefspec/extensions/chef/conditional'
|
5
5
|
require_relative 'chefspec/extensions/chef/data_query'
|
6
6
|
require_relative 'chefspec/extensions/chef/lwrp_base'
|
7
|
-
require_relative 'chefspec/extensions/chef/provider'
|
8
7
|
require_relative 'chefspec/extensions/chef/resource'
|
9
8
|
require_relative 'chefspec/extensions/chef/securable'
|
10
9
|
|
@@ -26,7 +25,6 @@ require_relative 'chefspec/formatter'
|
|
26
25
|
require_relative 'chefspec/macros'
|
27
26
|
require_relative 'chefspec/matchers'
|
28
27
|
require_relative 'chefspec/renderer'
|
29
|
-
require_relative 'chefspec/reporter'
|
30
28
|
require_relative 'chefspec/rspec'
|
31
29
|
require_relative 'chefspec/runner'
|
32
30
|
require_relative 'chefspec/version'
|
@@ -2,21 +2,37 @@ require 'chef/resource'
|
|
2
2
|
|
3
3
|
class Chef::Resource
|
4
4
|
alias_method :old_initialize, :initialize
|
5
|
-
|
6
5
|
def initialize(*args)
|
7
6
|
@performed_actions = {}
|
8
7
|
old_initialize(*args)
|
9
8
|
end
|
10
9
|
|
10
|
+
alias_method :old_run_action, :run_action
|
11
|
+
def run_action(action, notification_type = nil, notifying_resource = nil)
|
12
|
+
resolve_notification_references
|
13
|
+
validate_action(action)
|
14
|
+
|
15
|
+
Chef::Log.info("Processing #{self} action #{action} (#{defined_at})")
|
16
|
+
|
17
|
+
unless should_skip?(action)
|
18
|
+
if node.runner.step_into?(self)
|
19
|
+
instance_eval { @not_if = []; @only_if = [] }
|
20
|
+
old_run_action(action, notification_type, notifying_resource)
|
21
|
+
end
|
22
|
+
|
23
|
+
if node.runner.compiling?
|
24
|
+
perform_action(action, compile_time: true)
|
25
|
+
else
|
26
|
+
perform_action(action, converge_time: true)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
11
31
|
def perform_action(action, options = {})
|
12
32
|
@performed_actions[action.to_sym] ||= {}
|
13
33
|
@performed_actions[action.to_sym].merge!(options)
|
14
34
|
end
|
15
35
|
|
16
|
-
def unperform_action(action)
|
17
|
-
@performed_actions.delete(action.to_sym)
|
18
|
-
end
|
19
|
-
|
20
36
|
def performed_action(action)
|
21
37
|
@performed_actions[action.to_sym]
|
22
38
|
end
|
@@ -23,11 +23,11 @@ module ChefSpec::Matchers
|
|
23
23
|
if @expected_content
|
24
24
|
message << " with:"
|
25
25
|
message << "\n\n"
|
26
|
-
message << @expected_content
|
26
|
+
message << @expected_content.to_s
|
27
27
|
message << "\n\n"
|
28
28
|
message << "but got:"
|
29
29
|
message << "\n\n"
|
30
|
-
message << @actual_content
|
30
|
+
message << @actual_content.to_s
|
31
31
|
message << "\n "
|
32
32
|
end
|
33
33
|
message
|
@@ -38,7 +38,7 @@ module ChefSpec::Matchers
|
|
38
38
|
if @expected_content
|
39
39
|
message << " with:"
|
40
40
|
message << "\n\n"
|
41
|
-
message << @expected_content
|
41
|
+
message << @expected_content.to_s
|
42
42
|
message << "\n\n"
|
43
43
|
end
|
44
44
|
message << " to not be in Chef run"
|
data/lib/chefspec/runner.rb
CHANGED
@@ -75,7 +75,7 @@ module ChefSpec
|
|
75
75
|
Chef::Config.formatters.clear
|
76
76
|
Chef::Config.add_formatter('chefspec')
|
77
77
|
Chef::Config[:cache_type] = 'Memory'
|
78
|
-
Chef::Config[:
|
78
|
+
Chef::Config[:client_key] = nil
|
79
79
|
Chef::Config[:cookbook_path] = Array(options[:cookbook_path])
|
80
80
|
Chef::Config[:force_logger] = true
|
81
81
|
Chef::Config[:solo] = true
|
@@ -115,6 +115,7 @@ module ChefSpec
|
|
115
115
|
# Setup the run_context
|
116
116
|
@run_context = Chef::RunContext.new(client.node, {}, client.events)
|
117
117
|
|
118
|
+
@converging = true
|
118
119
|
@client.converge(@run_context)
|
119
120
|
self
|
120
121
|
end
|
@@ -148,6 +149,7 @@ module ChefSpec
|
|
148
149
|
# Setup the run_context
|
149
150
|
@run_context = client.setup_run_context
|
150
151
|
|
152
|
+
@converging = true
|
151
153
|
@client.converge(@run_context)
|
152
154
|
self
|
153
155
|
end
|
@@ -221,12 +223,28 @@ module ChefSpec
|
|
221
223
|
end
|
222
224
|
|
223
225
|
#
|
224
|
-
#
|
226
|
+
# Boolean method to determine the current phase of the Chef run (compiling
|
227
|
+
# or converging)
|
225
228
|
#
|
226
|
-
# @return [
|
229
|
+
# @return [Boolean]
|
230
|
+
#
|
231
|
+
def compiling?
|
232
|
+
!@converging
|
233
|
+
end
|
234
|
+
|
235
|
+
#
|
236
|
+
# Determines if the runner should step into the given resource. The
|
237
|
+
# +step_into+ option takes a string, but this method coerces everything
|
238
|
+
# to symbols for safety.
|
239
|
+
#
|
240
|
+
# @param [Chef::Resource] resource
|
241
|
+
# the Chef resource to try and step in to
|
242
|
+
#
|
243
|
+
# @return [Boolean]
|
227
244
|
#
|
228
|
-
def step_into
|
229
|
-
|
245
|
+
def step_into?(resource)
|
246
|
+
key = resource.resource_name.to_sym
|
247
|
+
Array(options[:step_into]).map(&:to_sym).include?(key)
|
230
248
|
end
|
231
249
|
|
232
250
|
#
|
data/lib/chefspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chefspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.beta.
|
4
|
+
version: 3.0.0.beta.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Crump
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -171,7 +171,6 @@ files:
|
|
171
171
|
- lib/chefspec/extensions/chef/conditional.rb
|
172
172
|
- lib/chefspec/extensions/chef/data_query.rb
|
173
173
|
- lib/chefspec/extensions/chef/lwrp_base.rb
|
174
|
-
- lib/chefspec/extensions/chef/provider.rb
|
175
174
|
- lib/chefspec/extensions/chef/resource.rb
|
176
175
|
- lib/chefspec/extensions/chef/securable.rb
|
177
176
|
- lib/chefspec/formatter.rb
|
@@ -183,7 +182,6 @@ files:
|
|
183
182
|
- lib/chefspec/matchers/resource_matcher.rb
|
184
183
|
- lib/chefspec/matchers.rb
|
185
184
|
- lib/chefspec/renderer.rb
|
186
|
-
- lib/chefspec/reporter.rb
|
187
185
|
- lib/chefspec/rspec.rb
|
188
186
|
- lib/chefspec/runner.rb
|
189
187
|
- lib/chefspec/stubs/command_registry.rb
|
@@ -221,6 +219,6 @@ rubyforge_project:
|
|
221
219
|
rubygems_version: 2.0.3
|
222
220
|
signing_key:
|
223
221
|
specification_version: 4
|
224
|
-
summary: chefspec-3.0.0.beta.
|
222
|
+
summary: chefspec-3.0.0.beta.4
|
225
223
|
test_files: []
|
226
224
|
has_rdoc:
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'chef/provider'
|
2
|
-
|
3
|
-
class Chef::Provider
|
4
|
-
alias_method :old_run_action, :run_action unless method_defined?(:old_run_action)
|
5
|
-
|
6
|
-
def run_action(action = nil)
|
7
|
-
Chef::Log.debug("Running action '#{action}' for #{self} (skipping because ChefSpec)")
|
8
|
-
@new_resource.updated_by_last_action(true)
|
9
|
-
|
10
|
-
if node.runner.step_into.include?(@new_resource.resource_name.to_s)
|
11
|
-
Chef::Log.debug("Stepping into LWRP #{@new_resource.resource_name.to_s}")
|
12
|
-
|
13
|
-
if whyrun_supported?
|
14
|
-
Chef::Log.warn("#{self} does not support whyrun mode. This could be dangerous!")
|
15
|
-
end
|
16
|
-
|
17
|
-
old_run_action(action)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/chefspec/reporter.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'chef/event_dispatch/base'
|
2
|
-
|
3
|
-
module ChefSpec
|
4
|
-
class Reporter < ::Chef::EventDispatch::Base
|
5
|
-
#
|
6
|
-
# Called when a resource is converged ({Chef::Resource#run_action}).
|
7
|
-
# This appends the action to the resource's +performed_actions+ so that
|
8
|
-
# ChefSpec can assert the resource received the proper message.
|
9
|
-
#
|
10
|
-
# @param [Chef::Resource] resource
|
11
|
-
# the resource to report on
|
12
|
-
# @param [Symbol] action
|
13
|
-
# the action
|
14
|
-
#
|
15
|
-
def resource_action_start(resource, action, notification_type = nil, notifier = nil)
|
16
|
-
if @converging
|
17
|
-
resource.perform_action(action, converge_time: true)
|
18
|
-
else
|
19
|
-
resource.perform_action(action, compile_time: true)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
# Called when a resource action is skipped (due to a resource guard
|
25
|
-
# or +action :nothing+). This removes the given action from the list
|
26
|
-
# of +performed_actions+ on the resource.
|
27
|
-
#
|
28
|
-
# @param [Chef::Resource] resource
|
29
|
-
# the resource to report on
|
30
|
-
# @param [Symbol] action
|
31
|
-
# the action
|
32
|
-
# @param [Chef::Resource::Conditional] conditional
|
33
|
-
# the conditional that ran
|
34
|
-
#
|
35
|
-
def resource_skipped(resource, action, conditional)
|
36
|
-
resource.unperform_action(action)
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
# Called when we start convering. This method sets an instance variable
|
41
|
-
# that other classes use to determine if a resource action was run during
|
42
|
-
# compile time or converge time.
|
43
|
-
#
|
44
|
-
# @param [Chef::RunContext] run_context
|
45
|
-
# the Chef run context
|
46
|
-
#
|
47
|
-
def converge_start(run_context)
|
48
|
-
@converging = true
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|