chefspec 3.0.0.beta.4 → 3.0.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/lib/chefspec/matchers/include_recipe_matcher.rb +3 -3
- data/lib/chefspec/matchers/link_to_matcher.rb +4 -4
- data/lib/chefspec/matchers/notifications_matcher.rb +7 -7
- data/lib/chefspec/matchers/render_file_matcher.rb +12 -3
- data/lib/chefspec/matchers/resource_matcher.rb +14 -14
- data/lib/chefspec/rspec.rb +1 -0
- data/lib/chefspec/runner.rb +16 -0
- data/lib/chefspec/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5868a82ecd4f7dd2ae15c73f08bdd3f407873b33
|
4
|
+
data.tar.gz: 442370c544b95393e0e615a991417a4e1ecc253d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e63ea25673e6c2634069474f565b15db07e6d03cf05494e312ff61a426b35854d7842e3d8264c492a598309e967b799537c4b117889dfeacc89ab2bbfb3885
|
7
|
+
data.tar.gz: de9ba082834b7e5ad26ae9e5bf7f2ae91af39dafb6cfb4d6109112dcb1e52e22d0179492098e0cf8b307c78cf2ae1ddac90301a11d06b88c633cdd8a7545c18b
|
@@ -10,15 +10,15 @@ module ChefSpec::Matchers
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def description
|
13
|
-
|
13
|
+
%Q{include recipe "#{@recipe_name}"}
|
14
14
|
end
|
15
15
|
|
16
16
|
def failure_message_for_should
|
17
|
-
|
17
|
+
%Q{expected #{loaded_recipes.inspect} to include "#{@recipe_name}"}
|
18
18
|
end
|
19
19
|
|
20
20
|
def failure_message_for_should_not
|
21
|
-
|
21
|
+
%Q{expected "#{@recipe_name}" to not be included}
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -13,19 +13,19 @@ module ChefSpec::Matchers
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def description
|
16
|
-
|
16
|
+
%Q{link to "#{@path}"}
|
17
17
|
end
|
18
18
|
|
19
19
|
def failure_message_for_should
|
20
20
|
if @link.nil?
|
21
|
-
|
21
|
+
%Q{expected "link[#{@path}]" with action :create to be in Chef run}
|
22
22
|
else
|
23
|
-
|
23
|
+
%Q{expected "#{@link}" to link to "#{@path}" but was "#{@link.to}"}
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def failure_message_for_should_not
|
28
|
-
|
28
|
+
%Q{expected "#{@link}" to not link to "#{@path}"}
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -42,8 +42,8 @@ module ChefSpec::Matchers
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def description
|
45
|
-
message =
|
46
|
-
message << " with action
|
45
|
+
message = %Q{notify "#{@expected_resource_type}[#{@expected_resource_name}]"}
|
46
|
+
message << " with action :#{@action}" if @action
|
47
47
|
message << " immediately" if @immediately
|
48
48
|
message << " delayed" if @delayed
|
49
49
|
message
|
@@ -51,8 +51,8 @@ module ChefSpec::Matchers
|
|
51
51
|
|
52
52
|
def failure_message_for_should
|
53
53
|
if @resource
|
54
|
-
message =
|
55
|
-
message << " with action
|
54
|
+
message = %Q{expected "#{@resource.resource_name}[#{@resource.name}]" to notify "#{@expected_resource_type}[#{@expected_resource_name}]"}
|
55
|
+
message << " with action :#{@action}" if @action
|
56
56
|
message << " immediately" if @immediately
|
57
57
|
message << " delayed" if @delayed
|
58
58
|
message << ", but did not."
|
@@ -61,8 +61,8 @@ module ChefSpec::Matchers
|
|
61
61
|
message << "\n "
|
62
62
|
message
|
63
63
|
else
|
64
|
-
message =
|
65
|
-
message << " with action
|
64
|
+
message = %Q{expected _something_ to notify "#{@expected_resource_type}[#{@expected_resource_name}]"}
|
65
|
+
message << " with action :#{@action}" if @action
|
66
66
|
message << " immediately" if @immediately
|
67
67
|
message << " delayed" if @delayed
|
68
68
|
message << ", but the _something_ you gave me was nil! If you are running a test like:"
|
@@ -98,7 +98,7 @@ module ChefSpec::Matchers
|
|
98
98
|
resource = notification.resource
|
99
99
|
type = notification.notifying_resource.immediate_notifications.include?(notification) ? :immediately : :delayed
|
100
100
|
|
101
|
-
"
|
101
|
+
%Q{ "#{notifying_resource.to_s}" notifies "#{resource.resource_name}[#{resource.name}]" to :#{notification.action}, :#{type}}
|
102
102
|
end
|
103
103
|
|
104
104
|
def format_notifications
|
@@ -15,11 +15,19 @@ module ChefSpec::Matchers
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def description
|
18
|
-
|
18
|
+
message = %Q{render file "#{@path}"}
|
19
|
+
if @expected_content
|
20
|
+
if @expected_content.include?("\n")
|
21
|
+
message << " with content <suppressed>"
|
22
|
+
else
|
23
|
+
message << " with content #{@expected_content.inspect}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
message
|
19
27
|
end
|
20
28
|
|
21
29
|
def failure_message_for_should
|
22
|
-
message =
|
30
|
+
message = %Q{expected Chef run to render "#{@path}"}
|
23
31
|
if @expected_content
|
24
32
|
message << " with:"
|
25
33
|
message << "\n\n"
|
@@ -34,7 +42,7 @@ module ChefSpec::Matchers
|
|
34
42
|
end
|
35
43
|
|
36
44
|
def failure_message_for_should_not
|
37
|
-
message =
|
45
|
+
message = %Q{expected file "#{@path}"}
|
38
46
|
if @expected_content
|
39
47
|
message << " with:"
|
40
48
|
message << "\n\n"
|
@@ -42,6 +50,7 @@ module ChefSpec::Matchers
|
|
42
50
|
message << "\n\n"
|
43
51
|
end
|
44
52
|
message << " to not be in Chef run"
|
53
|
+
message
|
45
54
|
end
|
46
55
|
|
47
56
|
private
|
@@ -35,6 +35,10 @@ module ChefSpec::Matchers
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def description
|
39
|
+
%Q{#{@expected_action} #{@resource_name} "#{@expected_identity}"}
|
40
|
+
end
|
41
|
+
|
38
42
|
def matches?(runner)
|
39
43
|
@runner = runner
|
40
44
|
|
@@ -50,24 +54,24 @@ module ChefSpec::Matchers
|
|
50
54
|
if resource.performed_action?(@expected_action)
|
51
55
|
if unmatched_parameters.empty?
|
52
56
|
if @compile_time
|
53
|
-
|
57
|
+
%Q{expected "#{resource.to_s}" to be run at compile time}
|
54
58
|
else
|
55
|
-
|
59
|
+
%Q{expected "#{resource.to_s}" to be run at converge time}
|
56
60
|
end
|
57
61
|
else
|
58
|
-
|
62
|
+
%Q{expected "#{resource.to_s}" to have parameters:} \
|
59
63
|
"\n\n" \
|
60
64
|
" " + unmatched_parameters.collect { |parameter, h|
|
61
65
|
"#{parameter} #{h[:expected].inspect}, was #{h[:actual].inspect}"
|
62
66
|
}.join("\n ")
|
63
67
|
end
|
64
68
|
else
|
65
|
-
|
66
|
-
" to include
|
69
|
+
%Q{expected "#{resource.to_s}" actions #{resource.performed_actions.inspect}} \
|
70
|
+
" to include :#{@expected_action}"
|
67
71
|
end
|
68
72
|
else
|
69
|
-
|
70
|
-
" action
|
73
|
+
%Q{expected "#{@resource_name}[#{@expected_identity}] with"} \
|
74
|
+
" action :#{@expected_action} to be in Chef run. Other" \
|
71
75
|
" #{@resource_name} resources:" \
|
72
76
|
"\n\n" \
|
73
77
|
" " + similar_resources.map(&:to_s).join("\n ") + "\n "
|
@@ -76,20 +80,16 @@ module ChefSpec::Matchers
|
|
76
80
|
|
77
81
|
def failure_message_for_should_not
|
78
82
|
if resource
|
79
|
-
message =
|
83
|
+
message = %Q{expected "#{resource.to_s}" actions #{resource.performed_actions.inspect} to not exist}
|
80
84
|
else
|
81
|
-
message =
|
85
|
+
message = %Q{expected "#{resource.to_s}" to not exist}
|
82
86
|
end
|
83
87
|
|
84
|
-
message << " at compile time"
|
88
|
+
message << " at compile time" if @compile_time
|
85
89
|
message << " at converge time" if @converge_time
|
86
90
|
message
|
87
91
|
end
|
88
92
|
|
89
|
-
def description
|
90
|
-
"#{@expected_action} #{@resource_name}"
|
91
|
-
end
|
92
|
-
|
93
93
|
private
|
94
94
|
def unmatched_parameters
|
95
95
|
return @_unmatched_parameters if @_unmatched_parameters
|
data/lib/chefspec/rspec.rb
CHANGED
data/lib/chefspec/runner.rb
CHANGED
@@ -63,6 +63,7 @@ module ChefSpec
|
|
63
63
|
def initialize(options = {}, &block)
|
64
64
|
@options = options = {
|
65
65
|
cookbook_path: RSpec.configuration.cookbook_path || calling_cookbook_path(caller),
|
66
|
+
role_path: RSpec.configuration.role_path || default_role_path,
|
66
67
|
log_level: RSpec.configuration.log_level,
|
67
68
|
path: RSpec.configuration.path,
|
68
69
|
platform: RSpec.configuration.platform,
|
@@ -77,6 +78,7 @@ module ChefSpec
|
|
77
78
|
Chef::Config[:cache_type] = 'Memory'
|
78
79
|
Chef::Config[:client_key] = nil
|
79
80
|
Chef::Config[:cookbook_path] = Array(options[:cookbook_path])
|
81
|
+
Chef::Config[:role_path] = Array(options[:role_path])
|
80
82
|
Chef::Config[:force_logger] = true
|
81
83
|
Chef::Config[:solo] = true
|
82
84
|
|
@@ -293,6 +295,20 @@ module ChefSpec
|
|
293
295
|
File.expand_path(File.join(bits.slice(0, spec_dir), '..'))
|
294
296
|
end
|
295
297
|
|
298
|
+
#
|
299
|
+
# The inferred path to roles.
|
300
|
+
#
|
301
|
+
# @return [String, nil]
|
302
|
+
#
|
303
|
+
def default_role_path
|
304
|
+
Pathname.new(Dir.pwd).ascend do |path|
|
305
|
+
possible = File.join(path, 'roles')
|
306
|
+
return possible if File.exists?(possible)
|
307
|
+
end
|
308
|
+
|
309
|
+
nil
|
310
|
+
end
|
311
|
+
|
296
312
|
#
|
297
313
|
# The +Chef::Client+ for this runner.
|
298
314
|
#
|
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
|
4
|
+
version: 3.0.0
|
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-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -211,14 +211,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
211
211
|
version: '1.9'
|
212
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
213
|
requirements:
|
214
|
-
- - '
|
214
|
+
- - '>='
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
version:
|
216
|
+
version: '0'
|
217
217
|
requirements: []
|
218
218
|
rubyforge_project:
|
219
219
|
rubygems_version: 2.0.3
|
220
220
|
signing_key:
|
221
221
|
specification_version: 4
|
222
|
-
summary: chefspec-3.0.0
|
222
|
+
summary: chefspec-3.0.0
|
223
223
|
test_files: []
|
224
224
|
has_rdoc:
|