halite 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +48 -22
  3. data/CHANGELOG.md +4 -0
  4. data/gemfiles/chef-12.16.gemfile +19 -0
  5. data/gemfiles/chef-12.17.gemfile +19 -0
  6. data/gemfiles/chef-12.18.gemfile +19 -0
  7. data/gemfiles/chef-12.19.gemfile +19 -0
  8. data/gemfiles/chef-12.20.gemfile +19 -0
  9. data/gemfiles/chef-12.21.gemfile +19 -0
  10. data/gemfiles/chef-12.gemfile +2 -2
  11. data/gemfiles/chef-13.0.gemfile +19 -0
  12. data/gemfiles/chef-13.1.gemfile +19 -0
  13. data/gemfiles/chef-13.10.gemfile +19 -0
  14. data/gemfiles/chef-13.2.gemfile +19 -0
  15. data/gemfiles/chef-13.3.gemfile +19 -0
  16. data/gemfiles/chef-13.4.gemfile +19 -0
  17. data/gemfiles/{chef-12.0.gemfile → chef-13.5.gemfile} +2 -2
  18. data/gemfiles/{chef-12.1.gemfile → chef-13.6.gemfile} +2 -2
  19. data/gemfiles/chef-13.7.gemfile +19 -0
  20. data/gemfiles/{chef-12.2.gemfile → chef-13.8.gemfile} +2 -2
  21. data/gemfiles/{chef-12.3.gemfile → chef-13.9.gemfile} +2 -2
  22. data/gemfiles/chef-13.gemfile +2 -2
  23. data/gemfiles/chef-14.0.gemfile +19 -0
  24. data/gemfiles/chef-14.1.gemfile +19 -0
  25. data/gemfiles/chef-14.2.gemfile +19 -0
  26. data/gemfiles/chef-14.3.gemfile +19 -0
  27. data/gemfiles/chef-14.4.gemfile +19 -0
  28. data/gemfiles/{chef-12.4.0.gemfile → chef-14.gemfile} +2 -2
  29. data/lib/halite/spec_helper.rb +37 -37
  30. data/lib/halite/spec_helper/patcher.rb +6 -129
  31. data/lib/halite/spec_helper/runner.rb +30 -35
  32. data/lib/halite/version.rb +1 -1
  33. data/spec/example_resources/custom.rb +29 -0
  34. data/spec/example_resources/simple.rb +4 -10
  35. data/spec/runner_spec.rb +17 -55
  36. data/spec/spec_helper.rb +2 -0
  37. data/spec/spec_helper_spec.rb +34 -12
  38. metadata +28 -13
  39. data/gemfiles/chef-12.4.gemfile +0 -19
  40. data/gemfiles/chef-12.5.gemfile +0 -19
  41. data/gemfiles/chef-12.6.gemfile +0 -19
  42. data/gemfiles/chef-12.7.gemfile +0 -19
  43. data/gemfiles/chef-13.7.16.gemfile +0 -21
@@ -17,5 +17,5 @@
17
17
 
18
18
  module Halite
19
19
  # Halite version.
20
- VERSION = '1.8.1'
20
+ VERSION = '1.8.2'
21
21
  end
@@ -0,0 +1,29 @@
1
+ #
2
+ # Copyright 2018, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'chef/resource'
18
+ require 'chef/provider'
19
+
20
+
21
+ # A `halite_test_custom` resource for use in Halite's unit tests.
22
+ class HaliteTestCustom < Chef::Resource
23
+ resource_name(:halite_test_custom)
24
+ action(:run) do
25
+ ruby_block new_resource.name do
26
+ block { }
27
+ end
28
+ end
29
+ end
@@ -21,21 +21,15 @@ require 'chef/provider'
21
21
  # A `halite_test_simple` resource for use in Halite's unit tests.
22
22
  class Chef
23
23
  class Resource::HaliteTestSimple < Resource
24
- provides(:halite_test_simple) # For Chef >= 12.4
25
-
26
- def initialize(*args)
27
- super
28
- @resource_name = :halite_test_simple
29
- @action = :run
30
- @allowed_actions << :run
31
- end
24
+ resource_name(:halite_test_simple)
25
+ # actions(:run)
26
+ default_action(:run)
32
27
  end
33
28
 
34
29
  class Provider::HaliteTestSimple < Provider
30
+ provides(:halite_test_simple)
35
31
  include Chef::DSL::Recipe
36
32
 
37
- provides(:halite_test_simple) # For Chef >= 12.4
38
-
39
33
  def load_current_resource
40
34
  end
41
35
 
@@ -22,40 +22,10 @@ require 'halite/spec_helper/runner'
22
22
 
23
23
  describe Halite::SpecHelper::Runner do
24
24
  let(:options) { Hash.new }
25
- subject { described_class.new(options) }
26
-
27
- describe 'Runner.converge' do
28
- let(:instance) { double('Runner instance') }
29
- before do
30
- expect(described_class).to receive(:new).with(options).and_return(instance)
31
- end
32
-
33
- context 'with a block' do
34
- it do
35
- expect(instance).to receive(:converge) do |&block|
36
- expect(block).to be_a(Proc)
37
- end
38
- described_class.converge { ruby_block 'test' }
39
- end
40
- end # /context with a block
41
-
42
- context 'with a recipe' do
43
- it do
44
- expect(instance).to receive(:converge).with('test')
45
- described_class.converge('test')
46
- end
47
- end # /context with a recipe
48
-
49
- context 'with options' do
50
- let(:options) { {dry_run: true} }
51
- it do
52
- expect(instance).to receive(:converge).with('test')
53
- described_class.converge('test', dry_run: true)
54
- end
55
- end # /context with options
56
- end # /describe Runner.converge
25
+ subject { described_class.new(options.merge(platform: 'ubuntu')) }
57
26
 
58
27
  describe '#initialize' do
28
+ before { subject.converge }
59
29
 
60
30
  context 'with a simple option' do
61
31
  let(:options) { {dry_run: true} }
@@ -64,7 +34,7 @@ describe Halite::SpecHelper::Runner do
64
34
 
65
35
  context 'with default_attributes' do
66
36
  let(:options) { {default_attributes: {halite: 'test'}} }
67
- it { expect(subject.node.default['halite']).to eq('test') }
37
+ it { expect(subject.node.role_default['halite']).to eq('test') }
68
38
  it { expect(subject.node['halite']).to eq('test') }
69
39
  end # /context with default_attributes
70
40
 
@@ -76,33 +46,25 @@ describe Halite::SpecHelper::Runner do
76
46
 
77
47
  context 'with override_attributes' do
78
48
  let(:options) { {override_attributes: {halite: 'test'}} }
79
- it { expect(subject.node.override['halite']).to eq('test') }
49
+ it { expect(subject.node.role_override['halite']).to eq('test') }
80
50
  it { expect(subject.node['halite']).to eq('test') }
81
51
  end # /context with override_attributes
82
52
  end # /describe #initialize
83
53
 
84
54
  describe '#converge' do
85
- context 'with a block' do
86
- it do
87
- sentinel = [false]
88
- subject.converge { sentinel[0] = true }
89
- expect(sentinel[0]).to eq(true)
90
- end
91
- end # /context with a block
55
+ let(:options) { {dry_run: true} }
92
56
 
93
- context 'with a recipe' do
94
- let(:options) { {dry_run: true} }
95
-
96
- it do
97
- expect(subject.node.run_list).to receive(:add).with('test')
98
- subject.converge('test')
99
- end
100
- end # /context with a recipe
101
-
102
- context 'with both a block and a recipe' do
103
- it do
104
- expect { subject.converge('test') { } }.to raise_error(Halite::Error)
105
- end
106
- end # /context with both a block and a recipe
57
+ it do
58
+ expect(subject.node.run_list).to receive(:add).with('test')
59
+ subject.converge('test')
60
+ end
107
61
  end # /describe #converge
62
+
63
+ describe '#converge_block' do
64
+ it do
65
+ sentinel = [false]
66
+ subject.converge_block { sentinel[0] = true }
67
+ expect(sentinel[0]).to eq(true)
68
+ end
69
+ end # /describe #converge_block
108
70
  end
@@ -17,5 +17,7 @@
17
17
  require 'poise_boiler/helpers/spec_helper'
18
18
  PoiseBoiler::Helpers::SpecHelper.install(no_halite: true)
19
19
  require 'halite'
20
+ require 'chefspec'
20
21
  require 'example_resources/simple'
21
22
  require 'example_resources/poise'
23
+ require 'example_resources/custom'
@@ -58,9 +58,9 @@ describe Halite::SpecHelper do
58
58
  it { is_expected.to be_a(Class) }
59
59
  it { is_expected.to be < Chef::Resource }
60
60
  its(:resource_name) { is_expected.to eq :halite_test } if defined?(Chef::Resource.resource_name)
61
- it { expect(subject.new(nil, nil).resource_name).to eq(:halite_test) }
62
- it { expect(Array(subject.new(nil, nil).action)).to eq([:run]) }
63
- it { expect(subject.new(nil, nil).allowed_actions).to eq([:nothing, :run]) }
61
+ it { expect(subject.new('test', nil).resource_name).to eq(:halite_test) }
62
+ it { expect(Array(subject.new('test', nil).action)).to eq([:run]) }
63
+ it { expect(subject.new('test', nil).allowed_actions).to eq([:nothing, :run]) }
64
64
  end # /context with defaults
65
65
 
66
66
  context 'with auto:false' do
@@ -68,9 +68,9 @@ describe Halite::SpecHelper do
68
68
  it { is_expected.to be_a(Class) }
69
69
  it { is_expected.to be < Chef::Resource }
70
70
  # #resource_name was added upstream in 12.4 so ignore this test there.
71
- it { expect(subject.new(nil, nil).resource_name).to be_nil } unless defined?(Chef::Resource.resource_name)
72
- it { expect(Array(subject.new(nil, nil).action)).to eq [:nothing] }
73
- it { expect(subject.new(nil, nil).allowed_actions).to eq [:nothing] }
71
+ it { expect(subject.new('test', nil).resource_name).to be_nil } unless defined?(Chef::Resource.resource_name)
72
+ it { expect(Array(subject.new('test', nil).action)).to eq [:nothing] }
73
+ it { expect(subject.new('test', nil).allowed_actions).to eq [:nothing] }
74
74
  end # /context with auto:false
75
75
 
76
76
  context 'with a parent' do
@@ -79,7 +79,7 @@ describe Halite::SpecHelper do
79
79
  it { is_expected.to be < Chef::Resource }
80
80
  it { is_expected.to be < Chef::Resource::File }
81
81
  its(:resource_name) { is_expected.to eq :halite_test } if defined?(Chef::Resource.resource_name)
82
- it { expect(subject.new(nil, nil).resource_name).to eq(:halite_test) }
82
+ it { expect(subject.new('test', nil).resource_name).to eq(:halite_test) }
83
83
  end # /context with a parent
84
84
 
85
85
  context 'with a helper-defined parent' do
@@ -89,7 +89,7 @@ describe Halite::SpecHelper do
89
89
  it { is_expected.to be < Chef::Resource }
90
90
  it { is_expected.to be < resource('halite_parent') }
91
91
  its(:resource_name) { is_expected.to eq :halite_test } if defined?(Chef::Resource.resource_name)
92
- it { expect(subject.new(nil, nil).resource_name).to eq(:halite_test) }
92
+ it { expect(subject.new('test', nil).resource_name).to eq(:halite_test) }
93
93
  end # /context with a helper-defined parent
94
94
 
95
95
  context 'with a helper-defined parent in an enclosing context' do
@@ -109,7 +109,7 @@ describe Halite::SpecHelper do
109
109
  :parent
110
110
  end
111
111
  end
112
- subject { resource(:halite_test).new(nil, nil).value }
112
+ subject { resource(:halite_test).new('test', nil).value }
113
113
 
114
114
  context 'sibling' do
115
115
  resource(:halite_parent) do
@@ -157,7 +157,7 @@ describe Halite::SpecHelper do
157
157
  end # /context on the class
158
158
 
159
159
  context 'on the instance' do
160
- subject { super().new(nil, nil) }
160
+ subject { super().new('test', nil) }
161
161
  its(:example_group) { is_expected.to be_truthy }
162
162
  its(:described_class) { is_expected.to eq Halite::SpecHelper }
163
163
  end # /context on the instance
@@ -183,7 +183,7 @@ describe Halite::SpecHelper do
183
183
  end # /context on the class
184
184
 
185
185
  context 'on the instance' do
186
- subject { super().new(nil, nil) }
186
+ subject { super().new(double(name: 'test', cookbook_name: 'test', resource_name: :halite_test), nil) }
187
187
  its(:example_group) { is_expected.to be_truthy }
188
188
  its(:described_class) { is_expected.to eq Halite::SpecHelper }
189
189
  end # /context on the instance
@@ -228,12 +228,34 @@ describe Halite::SpecHelper do
228
228
  it { expect(chef_run.halite_test_poise('test')).to be_a(Chef::Resource) }
229
229
  end # /context without step_into
230
230
  end # /context with a Poise resource
231
+
232
+ context 'with a custom resource' do
233
+ recipe do
234
+ halite_test_custom 'test'
235
+ end
236
+
237
+ context 'with step_into' do
238
+ step_into(:halite_test_custom)
239
+ it { is_expected.to run_halite_test_custom('test') }
240
+ it { is_expected.to run_ruby_block('test') }
241
+ it { expect(chef_run.halite_test_custom('test')).to be_a(Chef::Resource) }
242
+ end # /context with step_into
243
+
244
+ context 'without step_into' do
245
+ it { is_expected.to run_halite_test_custom('test') }
246
+ it { is_expected.to_not run_ruby_block('test') }
247
+ it { expect(chef_run.halite_test_custom('test')).to be_a(Chef::Resource) }
248
+ end # /context without step_into
249
+ end # /context with a custom resource
231
250
  end # /describe #step_into
232
251
 
233
252
  describe 'patcher' do
234
253
  #let(:chefspec_options) { {log_level: :debug} }
235
254
  resource(:halite_test)
236
- subject { resource(:halite_test).new('test', chef_run.run_context).provider_for_action(:run) }
255
+ subject do
256
+ chef_runner.converge
257
+ resource(:halite_test).new('test', chef_runner.run_context).provider_for_action(:run)
258
+ end
237
259
 
238
260
  context 'with a provider in scope' do
239
261
  provider(:halite_test)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: halite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-20 00:00:00.000000000 Z
11
+ date: 2018-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -130,18 +130,31 @@ files:
130
130
  - LICENSE
131
131
  - README.md
132
132
  - Rakefile
133
- - gemfiles/chef-12.0.gemfile
134
- - gemfiles/chef-12.1.gemfile
135
- - gemfiles/chef-12.2.gemfile
136
- - gemfiles/chef-12.3.gemfile
137
- - gemfiles/chef-12.4.0.gemfile
138
- - gemfiles/chef-12.4.gemfile
139
- - gemfiles/chef-12.5.gemfile
140
- - gemfiles/chef-12.6.gemfile
141
- - gemfiles/chef-12.7.gemfile
133
+ - gemfiles/chef-12.16.gemfile
134
+ - gemfiles/chef-12.17.gemfile
135
+ - gemfiles/chef-12.18.gemfile
136
+ - gemfiles/chef-12.19.gemfile
137
+ - gemfiles/chef-12.20.gemfile
138
+ - gemfiles/chef-12.21.gemfile
142
139
  - gemfiles/chef-12.gemfile
143
- - gemfiles/chef-13.7.16.gemfile
140
+ - gemfiles/chef-13.0.gemfile
141
+ - gemfiles/chef-13.1.gemfile
142
+ - gemfiles/chef-13.10.gemfile
143
+ - gemfiles/chef-13.2.gemfile
144
+ - gemfiles/chef-13.3.gemfile
145
+ - gemfiles/chef-13.4.gemfile
146
+ - gemfiles/chef-13.5.gemfile
147
+ - gemfiles/chef-13.6.gemfile
148
+ - gemfiles/chef-13.7.gemfile
149
+ - gemfiles/chef-13.8.gemfile
150
+ - gemfiles/chef-13.9.gemfile
144
151
  - gemfiles/chef-13.gemfile
152
+ - gemfiles/chef-14.0.gemfile
153
+ - gemfiles/chef-14.1.gemfile
154
+ - gemfiles/chef-14.2.gemfile
155
+ - gemfiles/chef-14.3.gemfile
156
+ - gemfiles/chef-14.4.gemfile
157
+ - gemfiles/chef-14.gemfile
145
158
  - gemfiles/master.gemfile
146
159
  - halite.gemspec
147
160
  - lib/berkshelf/halite.rb
@@ -171,6 +184,7 @@ files:
171
184
  - spec/converter/misc_spec.rb
172
185
  - spec/converter_spec.rb
173
186
  - spec/dependencies_spec.rb
187
+ - spec/example_resources/custom.rb
174
188
  - spec/example_resources/poise.rb
175
189
  - spec/example_resources/simple.rb
176
190
  - spec/fixtures/cookbooks/test1/files/halite_gem/test1.rb
@@ -243,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
257
  version: '0'
244
258
  requirements: []
245
259
  rubyforge_project:
246
- rubygems_version: 2.6.13
260
+ rubygems_version: 2.7.7
247
261
  signing_key:
248
262
  specification_version: 4
249
263
  summary: A set of helpers to write Chef cookbooks as Ruby gems.
@@ -254,6 +268,7 @@ test_files:
254
268
  - spec/converter/misc_spec.rb
255
269
  - spec/converter_spec.rb
256
270
  - spec/dependencies_spec.rb
271
+ - spec/example_resources/custom.rb
257
272
  - spec/example_resources/poise.rb
258
273
  - spec/example_resources/simple.rb
259
274
  - spec/fixtures/cookbooks/test1/files/halite_gem/test1.rb
@@ -1,19 +0,0 @@
1
- #
2
- # Copyright 2015, Noah Kantrowitz
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- eval_gemfile File.expand_path('../../Gemfile', __FILE__)
18
-
19
- gem 'chef', '~> 12.4.3'
@@ -1,19 +0,0 @@
1
- #
2
- # Copyright 2015, Noah Kantrowitz
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- eval_gemfile File.expand_path('../../Gemfile', __FILE__)
18
-
19
- gem 'chef', '~> 12.5.1'
@@ -1,19 +0,0 @@
1
- #
2
- # Copyright 2015, Noah Kantrowitz
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- eval_gemfile File.expand_path('../../Gemfile', __FILE__)
18
-
19
- gem 'chef', '~> 12.6.0'
@@ -1,19 +0,0 @@
1
- #
2
- # Copyright 2015, Noah Kantrowitz
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- eval_gemfile File.expand_path('../../Gemfile', __FILE__)
18
-
19
- gem 'chef', '~> 12.7.2'
@@ -1,21 +0,0 @@
1
- #
2
- # Copyright 2015, Noah Kantrowitz
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- eval_gemfile File.expand_path('../../Gemfile', __FILE__)
18
-
19
- # this tests a very specific node_map edge case that existed only in 13.7.16 in
20
- # the released gem line and which affected halite.
21
- gem 'chef', '= 13.7.16'