poise 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.kitchen.travis.yml +9 -0
- data/.kitchen.yml +18 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +25 -0
- data/.yardopts +5 -0
- data/Berksfile +26 -0
- data/Berksfile.lock +10 -0
- data/CHANGELOG.md +58 -0
- data/Gemfile +32 -0
- data/LICENSE +202 -0
- data/README.md +198 -0
- data/Rakefile +17 -0
- data/lib/poise.rb +71 -0
- data/lib/poise/error.rb +24 -0
- data/lib/poise/helpers.rb +33 -0
- data/lib/poise/helpers/chefspec_matchers.rb +92 -0
- data/lib/poise/helpers/defined_in.rb +111 -0
- data/lib/poise/helpers/fused.rb +127 -0
- data/lib/poise/helpers/include_recipe.rb +62 -0
- data/lib/poise/helpers/inversion.rb +374 -0
- data/lib/poise/helpers/inversion/options_provider.rb +41 -0
- data/lib/poise/helpers/inversion/options_resource.rb +101 -0
- data/lib/poise/helpers/lazy_default.rb +62 -0
- data/lib/poise/helpers/lwrp_polyfill.rb +96 -0
- data/lib/poise/helpers/notifying_block.rb +78 -0
- data/lib/poise/helpers/option_collector.rb +117 -0
- data/lib/poise/helpers/resource_name.rb +99 -0
- data/lib/poise/helpers/subcontext_block.rb +58 -0
- data/lib/poise/helpers/subresources.rb +29 -0
- data/lib/poise/helpers/subresources/child.rb +217 -0
- data/lib/poise/helpers/subresources/container.rb +165 -0
- data/lib/poise/helpers/subresources/default_containers.rb +73 -0
- data/lib/poise/helpers/template_content.rb +165 -0
- data/lib/poise/provider.rb +55 -0
- data/lib/poise/resource.rb +75 -0
- data/lib/poise/subcontext.rb +27 -0
- data/lib/poise/subcontext/resource_collection.rb +56 -0
- data/lib/poise/subcontext/runner.rb +50 -0
- data/lib/poise/utils.rb +60 -0
- data/lib/poise/utils/resource_provider_mixin.rb +53 -0
- data/lib/poise/version.rb +20 -0
- data/poise.gemspec +38 -0
- data/test/cookbooks/poise_test/attributes/default.rb +17 -0
- data/test/cookbooks/poise_test/libraries/app.rb +43 -0
- data/test/cookbooks/poise_test/libraries/app_config.rb +46 -0
- data/test/cookbooks/poise_test/libraries/inversion.rb +67 -0
- data/test/cookbooks/poise_test/metadata.rb +18 -0
- data/test/cookbooks/poise_test/recipes/default.rb +25 -0
- data/test/cookbooks/poise_test/recipes/inversion.rb +42 -0
- data/test/gemfiles/chef-12.0.gemfile +18 -0
- data/test/gemfiles/chef-12.1.gemfile +18 -0
- data/test/gemfiles/chef-12.2.gemfile +18 -0
- data/test/gemfiles/chef-12.gemfile +18 -0
- data/test/gemfiles/master.gemfile +20 -0
- data/test/integration/default/serverspec/default_spec.rb +35 -0
- data/test/integration/default/serverspec/inversion_spec.rb +43 -0
- data/test/spec/helpers/chefspec_matchers_spec.rb +45 -0
- data/test/spec/helpers/defined_in_spec.rb +62 -0
- data/test/spec/helpers/fused_spec.rb +92 -0
- data/test/spec/helpers/include_recipe_spec.rb +34 -0
- data/test/spec/helpers/inversion/options_resource_spec.rb +212 -0
- data/test/spec/helpers/inversion_spec.rb +273 -0
- data/test/spec/helpers/lazy_default_spec.rb +74 -0
- data/test/spec/helpers/lwrp_polyfill_spec.rb +128 -0
- data/test/spec/helpers/notifying_block_spec.rb +87 -0
- data/test/spec/helpers/option_collector_spec.rb +82 -0
- data/test/spec/helpers/resource_name_spec.rb +39 -0
- data/test/spec/helpers/subcontext_block_spec.rb +94 -0
- data/test/spec/helpers/subresources/child_spec.rb +339 -0
- data/test/spec/helpers/subresources/container_spec.rb +175 -0
- data/test/spec/helpers/template_context_spec.rb +147 -0
- data/test/spec/poise_spec.rb +185 -0
- data/test/spec/provider_spec.rb +28 -0
- data/test/spec/resource_spec.rb +85 -0
- data/test/spec/spec_helper.rb +18 -0
- data/test/spec/utils/resource_provider_mixin_spec.rb +52 -0
- data/test/spec/utils_spec.rb +110 -0
- metadata +190 -0
@@ -0,0 +1,147 @@
|
|
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
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe Poise::Helpers::TemplateContent do
|
20
|
+
resource(:poise_test) do
|
21
|
+
include described_class
|
22
|
+
attribute('', template: true)
|
23
|
+
end
|
24
|
+
provider(:poise_test)
|
25
|
+
recipe do
|
26
|
+
poise_test 'test'
|
27
|
+
end
|
28
|
+
|
29
|
+
# Stub out template rendering
|
30
|
+
let(:required_template_options) { Hash.new }
|
31
|
+
before do
|
32
|
+
@fake_finder = double('fake TemplateFinder')
|
33
|
+
allow(Chef::Provider::TemplateFinder).to receive(:new).and_return(@fake_finder)
|
34
|
+
allow(@fake_finder).to receive(:find)
|
35
|
+
@fake_ctx = double('fake TemplateContext')
|
36
|
+
if required_template_options.empty?
|
37
|
+
allow(Chef::Mixin::Template::TemplateContext).to receive(:new).and_return(@fake_ctx)
|
38
|
+
else
|
39
|
+
expect(Chef::Mixin::Template::TemplateContext).to receive(:new).with(hash_including(required_template_options)).and_return(@fake_ctx)
|
40
|
+
end
|
41
|
+
allow(@fake_ctx).to receive(:[]=)
|
42
|
+
allow(@fake_ctx).to receive(:render_template).and_return('rendered template')
|
43
|
+
# Also fake the cookbook lookup since that won't work in our test setup
|
44
|
+
allow(Poise::Utils).to receive(:find_cookbook_name).and_return('poise')
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with no input' do
|
48
|
+
recipe do
|
49
|
+
poise_test 'test'
|
50
|
+
end
|
51
|
+
|
52
|
+
it { is_expected.to run_poise_test('test').with(content: nil) }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'with a simple template' do
|
56
|
+
recipe do
|
57
|
+
poise_test 'test' do
|
58
|
+
source 'test.erb'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it { is_expected.to run_poise_test('test').with(source: 'test.erb', content: 'rendered template') }
|
63
|
+
|
64
|
+
it 'only runs the template render once' do
|
65
|
+
expect(@fake_ctx).to receive(:render_template).and_return('rendered template').once
|
66
|
+
subject.find_resource('poise_test', 'test').content
|
67
|
+
subject.find_resource('poise_test', 'test').content
|
68
|
+
end
|
69
|
+
end # /context with a template
|
70
|
+
|
71
|
+
context 'with some template variables' do
|
72
|
+
recipe do
|
73
|
+
poise_test 'test' do
|
74
|
+
source 'test.erb'
|
75
|
+
options do
|
76
|
+
one '1'
|
77
|
+
two 2
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
let(:required_template_options) { {'one' => '1', 'two' => 2} }
|
82
|
+
|
83
|
+
it { is_expected.to run_poise_test('test').with(source: 'test.erb', options: required_template_options, content: 'rendered template') }
|
84
|
+
end # /context with some template variables
|
85
|
+
|
86
|
+
context 'with explicit content' do
|
87
|
+
recipe do
|
88
|
+
poise_test 'test' do
|
89
|
+
content 'something explicit'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it { is_expected.to run_poise_test('test').with(content: 'something explicit') }
|
94
|
+
end # /context with explicit content
|
95
|
+
|
96
|
+
context 'with a default template' do
|
97
|
+
resource(:poise_test) do
|
98
|
+
include described_class
|
99
|
+
attribute('', template: true, default_source: 'test.erb')
|
100
|
+
end
|
101
|
+
|
102
|
+
it { is_expected.to run_poise_test('test').with(content: 'rendered template') }
|
103
|
+
end # /context with a default template
|
104
|
+
|
105
|
+
context 'with default content' do
|
106
|
+
resource(:poise_test) do
|
107
|
+
include described_class
|
108
|
+
attribute('', template: true, default: 'default content')
|
109
|
+
end
|
110
|
+
|
111
|
+
it { is_expected.to run_poise_test('test').with(content: 'default content') }
|
112
|
+
end # /context with default content
|
113
|
+
|
114
|
+
context 'with a name prefix' do
|
115
|
+
resource(:poise_test) do
|
116
|
+
include described_class
|
117
|
+
attribute(:config, template: true)
|
118
|
+
end
|
119
|
+
recipe do
|
120
|
+
poise_test 'test' do
|
121
|
+
config_source 'test.erb'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
it { is_expected.to run_poise_test('test').with(config_content: 'rendered template') }
|
126
|
+
end # /context with a name prefix
|
127
|
+
|
128
|
+
context 'with required content' do
|
129
|
+
resource(:poise_test) do
|
130
|
+
include described_class
|
131
|
+
attribute(:config, template: true, required: true)
|
132
|
+
end
|
133
|
+
|
134
|
+
it { expect{chef_run}.to raise_error(Chef::Exceptions::ValidationFailed) }
|
135
|
+
end # /context with required content
|
136
|
+
|
137
|
+
context 'with both source and content' do
|
138
|
+
recipe do
|
139
|
+
poise_test 'test' do
|
140
|
+
source 'test.erb'
|
141
|
+
content 'content'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
it { expect{chef_run}.to raise_error(Chef::Exceptions::ValidationFailed) }
|
146
|
+
end # /context with both source and content
|
147
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013-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
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe Poise do
|
20
|
+
context 'with a Resource' do
|
21
|
+
resource(:poise_test) do
|
22
|
+
include Poise
|
23
|
+
end
|
24
|
+
subject { resource(:poise_test) }
|
25
|
+
|
26
|
+
it { is_expected.to include Poise::Resource }
|
27
|
+
it { is_expected.to include Poise::Helpers::LazyDefault }
|
28
|
+
it { is_expected.to include Poise::Helpers::LWRPPolyfill }
|
29
|
+
it { is_expected.to include Poise::Helpers::LWRPPolyfill::Resource }
|
30
|
+
it { is_expected.to include Poise::Helpers::OptionCollector }
|
31
|
+
it { is_expected.to include Poise::Helpers::ResourceName }
|
32
|
+
it { is_expected.to include Poise::Helpers::TemplateContent }
|
33
|
+
it { is_expected.to include Poise::Helpers::ChefspecMatchers }
|
34
|
+
|
35
|
+
context 'as a function call' do
|
36
|
+
context 'with no arguments' do
|
37
|
+
resource(:poise_test) do
|
38
|
+
include Poise()
|
39
|
+
end
|
40
|
+
|
41
|
+
it { is_expected.to include Poise }
|
42
|
+
it { is_expected.to include Poise::Resource }
|
43
|
+
end # /context with no arguments
|
44
|
+
|
45
|
+
context 'with a parent class' do
|
46
|
+
resource(:poise_test) do
|
47
|
+
include Poise(parent: Chef::Resource::RubyBlock)
|
48
|
+
end
|
49
|
+
|
50
|
+
it { is_expected.to include Poise }
|
51
|
+
it { is_expected.to include Poise::Resource }
|
52
|
+
it { is_expected.to include Poise::Helpers::Subresources::Child }
|
53
|
+
its(:parent_type) { is_expected.to eq Chef::Resource::RubyBlock }
|
54
|
+
its(:parent_optional) { is_expected.to be_falsey }
|
55
|
+
end # /context with a parent class
|
56
|
+
|
57
|
+
context 'with a parent class shortcut' do
|
58
|
+
resource(:poise_test) do
|
59
|
+
include Poise(Chef::Resource::RubyBlock)
|
60
|
+
end
|
61
|
+
|
62
|
+
it { is_expected.to include Poise }
|
63
|
+
it { is_expected.to include Poise::Resource }
|
64
|
+
it { is_expected.to include Poise::Helpers::Subresources::Child }
|
65
|
+
its(:parent_type) { is_expected.to eq Chef::Resource::RubyBlock }
|
66
|
+
its(:parent_optional) { is_expected.to be_falsey }
|
67
|
+
end # /context with a parent class shortcut
|
68
|
+
|
69
|
+
context 'with an optional parent' do
|
70
|
+
resource(:poise_test) do
|
71
|
+
include Poise(parent: Chef::Resource::RubyBlock, parent_optional: true)
|
72
|
+
end
|
73
|
+
|
74
|
+
it { is_expected.to include Poise }
|
75
|
+
it { is_expected.to include Poise::Resource }
|
76
|
+
it { is_expected.to include Poise::Helpers::Subresources::Child }
|
77
|
+
its(:parent_type) { is_expected.to eq Chef::Resource::RubyBlock }
|
78
|
+
its(:parent_optional) { is_expected.to be_truthy }
|
79
|
+
end # /context with an optional parent
|
80
|
+
|
81
|
+
context 'with a container' do
|
82
|
+
resource(:poise_test) do
|
83
|
+
include Poise(container: true)
|
84
|
+
end
|
85
|
+
|
86
|
+
it { is_expected.to include Poise }
|
87
|
+
it { is_expected.to include Poise::Resource }
|
88
|
+
it { is_expected.to include Poise::Helpers::Subresources::Container }
|
89
|
+
end # /context with a container
|
90
|
+
|
91
|
+
context 'with a container namespace' do
|
92
|
+
resource(:poise_test) do
|
93
|
+
include Poise(container: true, container_namespace: true)
|
94
|
+
end
|
95
|
+
|
96
|
+
it { is_expected.to include Poise }
|
97
|
+
it { is_expected.to include Poise::Resource }
|
98
|
+
it { is_expected.to include Poise::Helpers::Subresources::Container }
|
99
|
+
its(:container_namespace) { is_expected.to eq true }
|
100
|
+
end # /context with a container namespace
|
101
|
+
|
102
|
+
context 'with a container namespace as a string' do
|
103
|
+
resource(:poise_test) do
|
104
|
+
include Poise(container: true, container_namespace: 'example')
|
105
|
+
end
|
106
|
+
|
107
|
+
it { is_expected.to include Poise }
|
108
|
+
it { is_expected.to include Poise::Resource }
|
109
|
+
it { is_expected.to include Poise::Helpers::Subresources::Container }
|
110
|
+
its(:container_namespace) { is_expected.to eq 'example' }
|
111
|
+
end # /context with a container namespaceas a string
|
112
|
+
|
113
|
+
context 'with a container namespace as a proc' do
|
114
|
+
resource(:poise_test) do
|
115
|
+
include Poise(container: true, container_namespace: Proc.new { name })
|
116
|
+
end
|
117
|
+
|
118
|
+
it { is_expected.to include Poise }
|
119
|
+
it { is_expected.to include Poise::Resource }
|
120
|
+
it { is_expected.to include Poise::Helpers::Subresources::Container }
|
121
|
+
its(:container_namespace) { is_expected.to be_a Proc }
|
122
|
+
end # /context with a container namespaceas a proc
|
123
|
+
|
124
|
+
context 'with a no container namespace' do
|
125
|
+
resource(:poise_test) do
|
126
|
+
include Poise(container: true, container_namespace: false)
|
127
|
+
end
|
128
|
+
|
129
|
+
it { is_expected.to include Poise }
|
130
|
+
it { is_expected.to include Poise::Resource }
|
131
|
+
it { is_expected.to include Poise::Helpers::Subresources::Container }
|
132
|
+
its(:container_namespace) { is_expected.to eq false }
|
133
|
+
end # /context with no container namespace
|
134
|
+
|
135
|
+
context 'with both a parent and a container' do
|
136
|
+
resource(:poise_test) do
|
137
|
+
include Poise(parent: Chef::Resource::RubyBlock, container: true)
|
138
|
+
end
|
139
|
+
|
140
|
+
it { is_expected.to include Poise }
|
141
|
+
it { is_expected.to include Poise::Resource }
|
142
|
+
it { is_expected.to include Poise::Helpers::Subresources::Child }
|
143
|
+
it { is_expected.to include Poise::Helpers::Subresources::Container }
|
144
|
+
its(:parent_type) { is_expected.to eq Chef::Resource::RubyBlock }
|
145
|
+
its(:parent_optional) { is_expected.to be_falsey }
|
146
|
+
end # /context with both a parent and a container
|
147
|
+
|
148
|
+
context 'with fused' do
|
149
|
+
resource(:poise_test) do
|
150
|
+
include Poise(fused: true)
|
151
|
+
end
|
152
|
+
|
153
|
+
it { is_expected.to include Poise }
|
154
|
+
it { is_expected.to include Poise::Resource }
|
155
|
+
it { is_expected.to include Poise::Helpers::Fused }
|
156
|
+
end # /context with fused
|
157
|
+
end # /context as a function call
|
158
|
+
end # /context for a Resource
|
159
|
+
|
160
|
+
context 'with a Provider' do
|
161
|
+
provider(:poise_test) do
|
162
|
+
include Poise
|
163
|
+
end
|
164
|
+
subject { provider(:poise_test) }
|
165
|
+
|
166
|
+
it { is_expected.to include Poise::Provider }
|
167
|
+
it { is_expected.to include Poise::Helpers::IncludeRecipe }
|
168
|
+
it { is_expected.to include Poise::Helpers::LWRPPolyfill }
|
169
|
+
it { is_expected.to include Poise::Helpers::LWRPPolyfill::Provider }
|
170
|
+
it { is_expected.to include Poise::Helpers::NotifyingBlock }
|
171
|
+
|
172
|
+
context 'as a function call' do
|
173
|
+
provider(:poise_test) do
|
174
|
+
include Poise()
|
175
|
+
end
|
176
|
+
|
177
|
+
it { is_expected.to include Poise }
|
178
|
+
it { is_expected.to include Poise::Provider }
|
179
|
+
end # /context as a function call
|
180
|
+
end # /context for a Provider
|
181
|
+
|
182
|
+
it 'has a fake name when used a function' do
|
183
|
+
expect(Poise().name).to eq 'Poise'
|
184
|
+
end # /it has a fake name when used a function
|
185
|
+
end
|
@@ -0,0 +1,28 @@
|
|
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
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe Poise::Provider do
|
20
|
+
provider(:poise_test) do
|
21
|
+
include described_class
|
22
|
+
end
|
23
|
+
subject { provider(:poise_test) }
|
24
|
+
|
25
|
+
it { is_expected.to include(Poise::Helpers::IncludeRecipe) }
|
26
|
+
it { is_expected.to include(Poise::Helpers::LWRPPolyfill) }
|
27
|
+
it { is_expected.to include(Poise::Helpers::NotifyingBlock) }
|
28
|
+
end
|
@@ -0,0 +1,85 @@
|
|
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
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe Poise::Resource do
|
20
|
+
resource(:poise_test) do
|
21
|
+
include described_class
|
22
|
+
end
|
23
|
+
subject { resource(:poise_test) }
|
24
|
+
|
25
|
+
it { is_expected.to include Poise::Helpers::LazyDefault }
|
26
|
+
it { is_expected.to include Poise::Helpers::LWRPPolyfill }
|
27
|
+
it { is_expected.to include Poise::Helpers::OptionCollector }
|
28
|
+
it { is_expected.to include Poise::Helpers::ResourceName }
|
29
|
+
it { is_expected.to include Poise::Helpers::TemplateContent }
|
30
|
+
it { is_expected.to include Poise::Helpers::ChefspecMatchers }
|
31
|
+
|
32
|
+
describe '#poise_subresource_container' do
|
33
|
+
resource(:poise_test) do
|
34
|
+
include described_class
|
35
|
+
poise_subresource_container
|
36
|
+
end
|
37
|
+
|
38
|
+
it { is_expected.to include Poise::Helpers::Subresources::Container }
|
39
|
+
end # /describe #poise_subresource_container
|
40
|
+
|
41
|
+
describe '#poise_subresource' do
|
42
|
+
context 'with no arguments' do
|
43
|
+
resource(:poise_test) do
|
44
|
+
include described_class
|
45
|
+
poise_subresource
|
46
|
+
end
|
47
|
+
|
48
|
+
it { is_expected.to include Poise::Helpers::Subresources::Child }
|
49
|
+
its(:parent_type) { is_expected.to eq Chef::Resource }
|
50
|
+
its(:parent_optional) { is_expected.to be_falsey }
|
51
|
+
end # /context with no arguments
|
52
|
+
|
53
|
+
context 'with a parent class' do
|
54
|
+
resource(:poise_test) do
|
55
|
+
include described_class
|
56
|
+
poise_subresource(Chef::Resource::RubyBlock)
|
57
|
+
end
|
58
|
+
|
59
|
+
it { is_expected.to include Poise::Helpers::Subresources::Child }
|
60
|
+
its(:parent_type) { is_expected.to eq Chef::Resource::RubyBlock }
|
61
|
+
its(:parent_optional) { is_expected.to be_falsey }
|
62
|
+
end # /context with a parent class
|
63
|
+
|
64
|
+
context 'with an optional parent' do
|
65
|
+
resource(:poise_test) do
|
66
|
+
include described_class
|
67
|
+
poise_subresource(Chef::Resource::RubyBlock, true)
|
68
|
+
end
|
69
|
+
|
70
|
+
it { is_expected.to include Poise::Helpers::Subresources::Child }
|
71
|
+
its(:parent_type) { is_expected.to eq Chef::Resource::RubyBlock }
|
72
|
+
its(:parent_optional) { is_expected.to be_truthy }
|
73
|
+
end # /context with an optional parent
|
74
|
+
end # /describe #poise_subresource
|
75
|
+
|
76
|
+
context 'with fused' do
|
77
|
+
resource(:poise_test) do
|
78
|
+
include described_class
|
79
|
+
poise_fused
|
80
|
+
end
|
81
|
+
|
82
|
+
it { is_expected.to include Poise::Resource }
|
83
|
+
it { is_expected.to include Poise::Helpers::Fused }
|
84
|
+
end # /context with fused
|
85
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013-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
|
+
require 'poise_boiler/spec_helper'
|
18
|
+
require 'poise'
|