chefspec 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/chefspec/chef_runner.rb
CHANGED
@@ -51,7 +51,10 @@ module ChefSpec
|
|
51
51
|
end
|
52
52
|
|
53
53
|
Chef::Config[:solo] = true
|
54
|
+
Chef::Config[:cache_type] = "Memory"
|
55
|
+
Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest) }
|
54
56
|
Chef::Config[:cookbook_path] = options[:cookbook_path]
|
57
|
+
Chef::Config[:client_key] = nil
|
55
58
|
Chef::Log.verbose = true if Chef::Log.respond_to?(:verbose)
|
56
59
|
Chef::Log.level(options[:log_level])
|
57
60
|
@client = Chef::Client.new
|
@@ -99,6 +102,14 @@ module ChefSpec
|
|
99
102
|
find_resource('directory', path)
|
100
103
|
end
|
101
104
|
|
105
|
+
# Find any cookbook_file declared with the given path
|
106
|
+
#
|
107
|
+
# @param [String] path The cookbook_file path
|
108
|
+
# @return [Chef::Resource::Directory] The matching cookbook_file, or Nil
|
109
|
+
def cookbook_file(path)
|
110
|
+
find_resource('cookbook_file', path)
|
111
|
+
end
|
112
|
+
|
102
113
|
# Find any file declared with the given path
|
103
114
|
#
|
104
115
|
# @param [String] path The file path
|
@@ -3,7 +3,7 @@ require 'chefspec/matchers/shared'
|
|
3
3
|
module ChefSpec
|
4
4
|
module Matchers
|
5
5
|
|
6
|
-
define_resource_matchers([:create, :delete], [:file, :directory], :path)
|
6
|
+
define_resource_matchers([:create, :delete], [:file, :directory, :cookbook_file], :path)
|
7
7
|
|
8
8
|
RSpec::Matchers.define :be_owned_by do |user, group|
|
9
9
|
match do |file|
|
@@ -6,7 +6,7 @@ module ChefSpec
|
|
6
6
|
match do |chef_run|
|
7
7
|
chef_run.resources.any? do |resource|
|
8
8
|
if resource.name == path
|
9
|
-
if resource.action.
|
9
|
+
if (Array(resource.action).map { |action| action.to_sym } & [:create, :create_if_missing]).any?
|
10
10
|
case resource_type(resource)
|
11
11
|
when 'template'
|
12
12
|
@actual_content = render(resource, chef_run.node)
|
@@ -14,6 +14,11 @@ module ChefSpec
|
|
14
14
|
when 'file'
|
15
15
|
@actual_content = resource.content
|
16
16
|
@actual_content.to_s.include? content
|
17
|
+
when 'cookbook_file'
|
18
|
+
cookbook_name = resource.cookbook || resource.cookbook_name
|
19
|
+
cookbook = chef_run.node.cookbook_collection[cookbook_name]
|
20
|
+
@actual_content = File.read(cookbook.preferred_filename_on_disk_location(chef_run.node, :files, resource.source, resource.path))
|
21
|
+
@actual_content.to_s.include? content
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
@@ -3,7 +3,7 @@ require 'chefspec/matchers/shared'
|
|
3
3
|
module ChefSpec
|
4
4
|
module Matchers
|
5
5
|
|
6
|
-
define_resource_matchers([:install, :remove, :upgrade, :purge], [:package], :package_name)
|
6
|
+
define_resource_matchers([:install, :remove, :upgrade, :purge], [:package, :gem_package], :package_name)
|
7
7
|
|
8
8
|
RSpec::Matchers.define :install_package_at_version do |package_name, version|
|
9
9
|
match do |chef_run|
|
@@ -12,5 +12,12 @@ module ChefSpec
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
|
+
RSpec::Matchers.define :install_gem_package_at_version do |package_name, version|
|
16
|
+
match do |chef_run|
|
17
|
+
chef_run.resources.any? do |resource|
|
18
|
+
resource_type(resource) == 'gem_package' and resource.package_name == package_name and resource.action.to_s.include? 'install' and resource.version == version
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
15
22
|
end
|
16
|
-
end
|
23
|
+
end
|
@@ -3,14 +3,14 @@ class Hash
|
|
3
3
|
|
4
4
|
# Monkey-patch to stdlib Hash to give us Mash style lookup
|
5
5
|
# @param [Symbol] method_id The method name
|
6
|
-
def method_missing(method_id)
|
6
|
+
def method_missing(method_id, *)
|
7
7
|
key = method_id.id2name
|
8
8
|
if has_key?(key)
|
9
9
|
self[key]
|
10
10
|
elsif has_key?(key.to_sym)
|
11
11
|
self[key.to_sym]
|
12
12
|
else
|
13
|
-
super
|
13
|
+
super
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/chefspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,58 +1,84 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: chefspec
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Andrew Crump
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
|
18
|
+
date: 2012-02-20 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
17
22
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 35
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 9
|
30
|
+
- 12
|
21
31
|
version: 0.9.12
|
22
32
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
hash: 31
|
35
|
+
segments:
|
36
|
+
- 0
|
37
|
+
- 10
|
38
|
+
version: "0.10"
|
39
|
+
requirement: *id001
|
25
40
|
type: :runtime
|
26
41
|
prerelease: false
|
27
|
-
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
|
30
|
-
requirement: &2152365220 !ruby/object:Gem::Requirement
|
42
|
+
name: chef
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
31
45
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 3
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
requirement: *id002
|
36
54
|
type: :runtime
|
37
55
|
prerelease: false
|
38
|
-
|
39
|
-
- !ruby/object:Gem::Dependency
|
40
|
-
|
41
|
-
requirement: &2152364200 !ruby/object:Gem::Requirement
|
56
|
+
name: erubis
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
42
59
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 47
|
64
|
+
segments:
|
65
|
+
- 2
|
66
|
+
- 8
|
67
|
+
- 0
|
68
|
+
version: 2.8.0
|
69
|
+
requirement: *id003
|
47
70
|
type: :runtime
|
48
71
|
prerelease: false
|
49
|
-
|
72
|
+
name: rspec
|
50
73
|
description: Write RSpec examples for Opscode Chef recipes
|
51
74
|
email:
|
52
75
|
executables: []
|
76
|
+
|
53
77
|
extensions: []
|
78
|
+
|
54
79
|
extra_rdoc_files: []
|
55
|
-
|
80
|
+
|
81
|
+
files:
|
56
82
|
- lib/chef/knife/cookbook_create_specs.rb
|
57
83
|
- lib/chefspec/chef_runner.rb
|
58
84
|
- lib/chefspec/matchers/execute.rb
|
@@ -67,34 +93,38 @@ files:
|
|
67
93
|
- lib/chefspec/version.rb
|
68
94
|
- lib/chefspec.rb
|
69
95
|
homepage: http://acrmp.github.com/chefspec
|
70
|
-
licenses:
|
96
|
+
licenses:
|
71
97
|
- MIT
|
72
98
|
post_install_message:
|
73
99
|
rdoc_options: []
|
74
|
-
|
100
|
+
|
101
|
+
require_paths:
|
75
102
|
- lib
|
76
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
104
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
segments:
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 3
|
109
|
+
segments:
|
83
110
|
- 0
|
84
|
-
|
85
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
version: "0"
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
113
|
none: false
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
segments:
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
hash: 3
|
118
|
+
segments:
|
92
119
|
- 0
|
93
|
-
|
120
|
+
version: "0"
|
94
121
|
requirements: []
|
122
|
+
|
95
123
|
rubyforge_project:
|
96
124
|
rubygems_version: 1.8.10
|
97
125
|
signing_key:
|
98
126
|
specification_version: 3
|
99
|
-
summary: chefspec-0.
|
127
|
+
summary: chefspec-0.5.0
|
100
128
|
test_files: []
|
129
|
+
|
130
|
+
has_rdoc:
|