chef 12.0.1-x86-mingw32 → 12.0.3-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -1
  3. data/lib/chef/digester.rb +1 -0
  4. data/lib/chef/dsl/recipe.rb +2 -1
  5. data/lib/chef/exceptions.rb +5 -0
  6. data/lib/chef/knife.rb +7 -0
  7. data/lib/chef/knife/cookbook_site_install.rb +34 -10
  8. data/lib/chef/provider/link.rb +1 -1
  9. data/lib/chef/provider/package/apt.rb +2 -2
  10. data/lib/chef/provider/package/homebrew.rb +11 -2
  11. data/lib/chef/provider/package/windows/msi.rb +2 -0
  12. data/lib/chef/provider/subversion.rb +3 -3
  13. data/lib/chef/resource.rb +23 -91
  14. data/lib/chef/resource/homebrew_package.rb +2 -1
  15. data/lib/chef/resource/resource_notification.rb +109 -0
  16. data/lib/chef/resource_collection/resource_set.rb +8 -8
  17. data/lib/chef/run_context.rb +4 -4
  18. data/lib/chef/version.rb +1 -1
  19. data/lib/chef/whitelist.rb +3 -1
  20. data/lib/chef/win32/api/file.rb +17 -3
  21. data/spec/functional/notifications_spec.rb +169 -0
  22. data/spec/functional/resource/link_spec.rb +31 -32
  23. data/spec/support/platform_helpers.rb +5 -2
  24. data/spec/unit/knife/cookbook_site_install_spec.rb +157 -116
  25. data/spec/unit/knife_spec.rb +108 -78
  26. data/spec/unit/mixin/shell_out_spec.rb +39 -40
  27. data/spec/unit/node_spec.rb +34 -0
  28. data/spec/unit/provider/link_spec.rb +5 -5
  29. data/spec/unit/provider/package/apt_spec.rb +264 -257
  30. data/spec/unit/provider/package/homebrew_spec.rb +26 -0
  31. data/spec/unit/provider/package/windows/msi_spec.rb +18 -3
  32. data/spec/unit/provider/subversion_spec.rb +5 -5
  33. data/spec/unit/provider_resolver_spec.rb +2 -2
  34. data/spec/unit/recipe_spec.rb +1 -0
  35. data/spec/unit/resource/apt_package_spec.rb +3 -5
  36. data/spec/unit/resource/resource_notification_spec.rb +170 -0
  37. data/spec/unit/resource_spec.rb +0 -151
  38. data/spec/unit/run_context_spec.rb +94 -55
  39. metadata +5 -2
@@ -24,23 +24,26 @@ require 'support/lib/library_load_order'
24
24
  Chef::Log.level = :debug
25
25
 
26
26
  describe Chef::RunContext do
27
- before(:each) do
28
- @chef_repo_path = File.expand_path(File.join(CHEF_SPEC_DATA, "run_context", "cookbooks"))
29
- cl = Chef::CookbookLoader.new(@chef_repo_path)
27
+ let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "run_context", "cookbooks")) }
28
+ let(:cookbook_collection) {
29
+ cl = Chef::CookbookLoader.new(chef_repo_path)
30
30
  cl.load_cookbooks
31
- @cookbook_collection = Chef::CookbookCollection.new(cl)
32
- @node = Chef::Node.new
33
- @node.run_list << "test" << "test::one" << "test::two"
34
- @events = Chef::EventDispatch::Dispatcher.new
35
- @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
36
- end
31
+ Chef::CookbookCollection.new(cl)
32
+ }
33
+ let(:node) {
34
+ node = Chef::Node.new
35
+ node.run_list << "test" << "test::one" << "test::two"
36
+ node
37
+ }
38
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
39
+ let(:run_context) { Chef::RunContext.new(node, cookbook_collection, events) }
37
40
 
38
41
  it "has a cookbook collection" do
39
- @run_context.cookbook_collection.should == @cookbook_collection
42
+ run_context.cookbook_collection.should == cookbook_collection
40
43
  end
41
44
 
42
45
  it "has a node" do
43
- @run_context.node.should == @node
46
+ run_context.node.should == node
44
47
  end
45
48
 
46
49
  describe "loading cookbooks for a run list" do
@@ -52,44 +55,44 @@ describe Chef::RunContext do
52
55
  Chef::Provider.send(:remove_const, :TestProvider)
53
56
  end
54
57
 
55
- @node.run_list << "test" << "test::one" << "test::two"
56
- @node.should_receive(:loaded_recipe).with(:test, "default")
57
- @node.should_receive(:loaded_recipe).with(:test, "one")
58
- @node.should_receive(:loaded_recipe).with(:test, "two")
59
- @run_context.load(@node.run_list.expand('_default'))
58
+ node.run_list << "test" << "test::one" << "test::two"
59
+ node.should_receive(:loaded_recipe).with(:test, "default")
60
+ node.should_receive(:loaded_recipe).with(:test, "one")
61
+ node.should_receive(:loaded_recipe).with(:test, "two")
62
+ run_context.load(node.run_list.expand('_default'))
60
63
  end
61
64
 
62
65
  it "should load all the definitions in the cookbooks for this node" do
63
- @run_context.definitions.should have_key(:new_cat)
64
- @run_context.definitions.should have_key(:new_badger)
65
- @run_context.definitions.should have_key(:new_dog)
66
+ run_context.definitions.should have_key(:new_cat)
67
+ run_context.definitions.should have_key(:new_badger)
68
+ run_context.definitions.should have_key(:new_dog)
66
69
  end
67
70
 
68
71
  it "should load all the recipes specified for this node" do
69
- @run_context.resource_collection[0].to_s.should == "cat[einstein]"
70
- @run_context.resource_collection[1].to_s.should == "cat[loulou]"
71
- @run_context.resource_collection[2].to_s.should == "cat[birthday]"
72
- @run_context.resource_collection[3].to_s.should == "cat[peanut]"
73
- @run_context.resource_collection[4].to_s.should == "cat[fat peanut]"
72
+ run_context.resource_collection[0].to_s.should == "cat[einstein]"
73
+ run_context.resource_collection[1].to_s.should == "cat[loulou]"
74
+ run_context.resource_collection[2].to_s.should == "cat[birthday]"
75
+ run_context.resource_collection[3].to_s.should == "cat[peanut]"
76
+ run_context.resource_collection[4].to_s.should == "cat[fat peanut]"
74
77
  end
75
78
 
76
79
  it "loads all the attribute files in the cookbook collection" do
77
- @run_context.loaded_fully_qualified_attribute?("test", "george").should be_true
78
- @node[:george].should == "washington"
80
+ run_context.loaded_fully_qualified_attribute?("test", "george").should be_true
81
+ node[:george].should == "washington"
79
82
  end
80
83
 
81
84
  it "registers attributes files as loaded so they won't be reloaded" do
82
85
  # This test unfortunately is pretty tightly intertwined with the
83
86
  # implementation of how nodes load attribute files, but is the only
84
87
  # convenient way to test this behavior.
85
- @node.should_not_receive(:from_file)
86
- @node.include_attribute("test::george")
88
+ node.should_not_receive(:from_file)
89
+ node.include_attribute("test::george")
87
90
  end
88
91
 
89
92
  it "raises an error when attempting to include_recipe from a cookbook not reachable by run list or dependencies" do
90
- @node.should_receive(:loaded_recipe).with(:ancient, "aliens")
93
+ node.should_receive(:loaded_recipe).with(:ancient, "aliens")
91
94
  lambda do
92
- @run_context.include_recipe("ancient::aliens")
95
+ run_context.include_recipe("ancient::aliens")
93
96
  # In CHEF-5120, this becomes a Chef::Exceptions::MissingCookbookDependency error:
94
97
  end.should raise_error(Chef::Exceptions::CookbookNotFound)
95
98
  end
@@ -97,39 +100,34 @@ describe Chef::RunContext do
97
100
  end
98
101
 
99
102
  describe "querying the contents of cookbooks" do
100
- before do
101
- @chef_repo_path = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks"))
102
- cl = Chef::CookbookLoader.new(@chef_repo_path)
103
- cl.load_cookbooks
104
- @cookbook_collection = Chef::CookbookCollection.new(cl)
105
- @node = Chef::Node.new
106
- @node.set[:platform] = "ubuntu"
107
- @node.set[:platform_version] = "13.04"
108
- @node.name("testing")
109
- @events = Chef::EventDispatch::Dispatcher.new
110
- @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
111
- end
112
-
103
+ let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks")) }
104
+ let(:node) {
105
+ node = Chef::Node.new
106
+ node.set[:platform] = "ubuntu"
107
+ node.set[:platform_version] = "13.04"
108
+ node.name("testing")
109
+ node
110
+ }
113
111
 
114
112
  it "queries whether a given cookbook has a specific template" do
115
- @run_context.should have_template_in_cookbook("openldap", "test.erb")
116
- @run_context.should_not have_template_in_cookbook("openldap", "missing.erb")
113
+ run_context.should have_template_in_cookbook("openldap", "test.erb")
114
+ run_context.should_not have_template_in_cookbook("openldap", "missing.erb")
117
115
  end
118
116
 
119
117
  it "errors when querying for a template in a not-available cookbook" do
120
118
  expect do
121
- @run_context.has_template_in_cookbook?("no-such-cookbook", "foo.erb")
119
+ run_context.has_template_in_cookbook?("no-such-cookbook", "foo.erb")
122
120
  end.to raise_error(Chef::Exceptions::CookbookNotFound)
123
121
  end
124
122
 
125
123
  it "queries whether a given cookbook has a specific cookbook_file" do
126
- @run_context.should have_cookbook_file_in_cookbook("java", "java.response")
127
- @run_context.should_not have_cookbook_file_in_cookbook("java", "missing.txt")
124
+ run_context.should have_cookbook_file_in_cookbook("java", "java.response")
125
+ run_context.should_not have_cookbook_file_in_cookbook("java", "missing.txt")
128
126
  end
129
127
 
130
128
  it "errors when querying for a cookbook_file in a not-available cookbook" do
131
129
  expect do
132
- @run_context.has_cookbook_file_in_cookbook?("no-such-cookbook", "foo.txt")
130
+ run_context.has_cookbook_file_in_cookbook?("no-such-cookbook", "foo.txt")
133
131
  end.to raise_error(Chef::Exceptions::CookbookNotFound)
134
132
  end
135
133
  end
@@ -140,13 +138,54 @@ describe Chef::RunContext do
140
138
  end
141
139
 
142
140
  it "stores and deletes the reboot request" do
143
- @run_context.request_reboot(expected)
144
- expect(@run_context.reboot_info).to eq(expected)
145
- expect(@run_context.reboot_requested?).to be_true
141
+ run_context.request_reboot(expected)
142
+ expect(run_context.reboot_info).to eq(expected)
143
+ expect(run_context.reboot_requested?).to be_true
144
+
145
+ run_context.cancel_reboot
146
+ expect(run_context.reboot_info).to eq({})
147
+ expect(run_context.reboot_requested?).to be_false
148
+ end
149
+ end
150
+
151
+ describe "notifications" do
152
+ let(:notification) { Chef::Resource::Notification.new(nil, nil, notifying_resource) }
153
+
154
+ shared_context "notifying resource is a Chef::Resource" do
155
+ let(:notifying_resource) { Chef::Resource.new("gerbil") }
156
+
157
+ it "should be keyed off the resource name" do
158
+ run_context.send(setter, notification)
159
+ expect(run_context.send(getter, notifying_resource)).to eq([notification])
160
+ end
161
+ end
162
+
163
+ shared_context "notifying resource is a subclass of Chef::Resource" do
164
+ let(:declared_type) { :alpaca }
165
+ let(:notifying_resource) {
166
+ r = Class.new(Chef::Resource).new("guinea pig")
167
+ r.declared_type = declared_type
168
+ r
169
+ }
170
+
171
+ it "should be keyed off the resource declared key" do
172
+ run_context.send(setter, notification)
173
+ expect(run_context.send(getter, notifying_resource)).to eq([notification])
174
+ end
175
+ end
176
+
177
+ describe "of the immediate kind" do
178
+ let(:setter) { :notifies_immediately }
179
+ let(:getter) { :immediate_notifications }
180
+ include_context "notifying resource is a Chef::Resource"
181
+ include_context "notifying resource is a subclass of Chef::Resource"
182
+ end
146
183
 
147
- @run_context.cancel_reboot
148
- expect(@run_context.reboot_info).to eq({})
149
- expect(@run_context.reboot_requested?).to be_false
184
+ describe "of the delayed kind" do
185
+ let(:setter) { :notifies_delayed }
186
+ let(:getter) { :delayed_notifications }
187
+ include_context "notifying resource is a Chef::Resource"
188
+ include_context "notifying resource is a subclass of Chef::Resource"
150
189
  end
151
190
  end
152
191
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.0.1
4
+ version: 12.0.3
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-09 00:00:00.000000000 Z
11
+ date: 2014-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-config
@@ -1196,6 +1196,7 @@ files:
1196
1196
  - lib/chef/resource/registry_key.rb
1197
1197
  - lib/chef/resource/remote_directory.rb
1198
1198
  - lib/chef/resource/remote_file.rb
1199
+ - lib/chef/resource/resource_notification.rb
1199
1200
  - lib/chef/resource/route.rb
1200
1201
  - lib/chef/resource/rpm_package.rb
1201
1202
  - lib/chef/resource/ruby.rb
@@ -1596,6 +1597,7 @@ files:
1596
1597
  - spec/functional/knife/smoke_test.rb
1597
1598
  - spec/functional/knife/ssh_spec.rb
1598
1599
  - spec/functional/mixin/shell_out_spec.rb
1600
+ - spec/functional/notifications_spec.rb
1599
1601
  - spec/functional/provider/remote_file/cache_control_data_spec.rb
1600
1602
  - spec/functional/provider/whyrun_safe_ruby_block_spec.rb
1601
1603
  - spec/functional/rebooter_spec.rb
@@ -2031,6 +2033,7 @@ files:
2031
2033
  - spec/unit/resource/registry_key_spec.rb
2032
2034
  - spec/unit/resource/remote_directory_spec.rb
2033
2035
  - spec/unit/resource/remote_file_spec.rb
2036
+ - spec/unit/resource/resource_notification_spec.rb
2034
2037
  - spec/unit/resource/route_spec.rb
2035
2038
  - spec/unit/resource/rpm_package_spec.rb
2036
2039
  - spec/unit/resource/ruby_block_spec.rb