poise-javascript 1.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.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.kitchen.travis.yml +9 -0
  4. data/.kitchen.yml +8 -0
  5. data/.travis.yml +21 -0
  6. data/.yardopts +7 -0
  7. data/Berksfile +28 -0
  8. data/CHANGELOG.md +6 -0
  9. data/Gemfile +33 -0
  10. data/LICENSE +201 -0
  11. data/README.md +332 -0
  12. data/Rakefile +17 -0
  13. data/chef/attributes/default.rb +23 -0
  14. data/chef/recipes/default.rb +19 -0
  15. data/lib/poise_javascript.rb +24 -0
  16. data/lib/poise_javascript/cheftie.rb +18 -0
  17. data/lib/poise_javascript/error.rb +23 -0
  18. data/lib/poise_javascript/javascript_command_mixin.rb +56 -0
  19. data/lib/poise_javascript/javascript_providers.rb +40 -0
  20. data/lib/poise_javascript/javascript_providers/base.rb +97 -0
  21. data/lib/poise_javascript/javascript_providers/dummy.rb +77 -0
  22. data/lib/poise_javascript/javascript_providers/iojs.rb +64 -0
  23. data/lib/poise_javascript/javascript_providers/nodejs.rb +64 -0
  24. data/lib/poise_javascript/javascript_providers/scl.rb +79 -0
  25. data/lib/poise_javascript/javascript_providers/system.rb +71 -0
  26. data/lib/poise_javascript/resources.rb +29 -0
  27. data/lib/poise_javascript/resources/javascript_execute.rb +83 -0
  28. data/lib/poise_javascript/resources/javascript_runtime.rb +85 -0
  29. data/lib/poise_javascript/resources/javascript_runtime_test.rb +226 -0
  30. data/lib/poise_javascript/resources/node_package.rb +254 -0
  31. data/lib/poise_javascript/resources/npm_install.rb +94 -0
  32. data/lib/poise_javascript/version.rb +20 -0
  33. data/poise-javascript.gemspec +41 -0
  34. data/test/cookbooks/poise-javascript_test/metadata.rb +18 -0
  35. data/test/cookbooks/poise-javascript_test/recipes/default.rb +49 -0
  36. data/test/gemfiles/chef-12.gemfile +19 -0
  37. data/test/gemfiles/master.gemfile +23 -0
  38. data/test/integration/default/serverspec/default_spec.rb +107 -0
  39. data/test/spec/javascript_command_mixin_spec.rb +59 -0
  40. data/test/spec/javascript_providers/base_spec.rb +89 -0
  41. data/test/spec/javascript_providers/dummy_spec.rb +62 -0
  42. data/test/spec/javascript_providers/iojs_spec.rb +77 -0
  43. data/test/spec/javascript_providers/nodejs_spec.rb +82 -0
  44. data/test/spec/javascript_providers/scl_spec.rb +68 -0
  45. data/test/spec/javascript_providers/system_spec.rb +73 -0
  46. data/test/spec/resources/javascript_execute_spec.rb +67 -0
  47. data/test/spec/resources/node_package_spec.rb +324 -0
  48. data/test/spec/resources/npm_install_spec.rb +118 -0
  49. data/test/spec/spec_helper.rb +19 -0
  50. metadata +169 -0
@@ -0,0 +1,68 @@
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 PoiseJavascript::JavascriptProviders::Scl do
20
+ let(:javascript_version) { '' }
21
+ let(:chefspec_options) { {platform: 'centos', version: '7.0'} }
22
+ let(:default_attributes) { {poise_javascript_version: javascript_version} }
23
+ let(:javascript_runtime) { chef_run.javascript_runtime('test') }
24
+ step_into(:javascript_runtime)
25
+ recipe do
26
+ javascript_runtime 'test' do
27
+ provider :scl
28
+ version node['poise_javascript_version']
29
+ end
30
+ end
31
+
32
+ shared_examples_for 'scl provider' do |pkg|
33
+ it { expect(javascript_runtime.provider_for_action(:install)).to be_a described_class }
34
+ it { expect(javascript_runtime.javascript_binary).to eq File.join('', 'opt', 'rh', pkg, 'root', 'usr', 'bin', 'node') }
35
+ it { is_expected.to install_poise_languages_scl(pkg) }
36
+ it do
37
+ expect_any_instance_of(described_class).to receive(:install_scl_package)
38
+ expect_any_instance_of(described_class).to receive(:install_v8_scl_package)
39
+ run_chef
40
+ end
41
+ it do
42
+ expect_any_instance_of(described_class).to receive(:scl_environment)
43
+ javascript_runtime.javascript_environment
44
+ end
45
+ end
46
+
47
+ context 'with version ""' do
48
+ let(:javascript_version) { '' }
49
+ it_behaves_like 'scl provider', 'nodejs010'
50
+ end # /context with version ""
51
+
52
+ context 'action :uninstall' do
53
+ recipe do
54
+ javascript_runtime 'test' do
55
+ action :uninstall
56
+ provider :scl
57
+ version node['poise_javascript_version']
58
+ end
59
+ end
60
+
61
+ it do
62
+ expect_any_instance_of(described_class).to receive(:uninstall_scl_package)
63
+ expect_any_instance_of(described_class).to receive(:uninstall_v8_scl_package)
64
+ run_chef
65
+ end
66
+ it { expect(javascript_runtime.provider_for_action(:uninstall)).to be_a described_class }
67
+ end # /context action :uninstall
68
+ end
@@ -0,0 +1,73 @@
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 PoiseJavascript::JavascriptProviders::System do
20
+ let(:javascript_version) { '' }
21
+ let(:chefspec_options) { {platform: 'ubuntu', version: '14.04'} }
22
+ let(:default_attributes) { {poise_javascript_version: javascript_version} }
23
+ let(:javascript_runtime) { chef_run.javascript_runtime('test') }
24
+ let(:system_package_candidates) { javascript_runtime.provider_for_action(:install).send(:system_package_candidates, javascript_version) }
25
+ step_into(:javascript_runtime)
26
+ recipe do
27
+ javascript_runtime 'test' do
28
+ provider :system
29
+ version node['poise_javascript_version']
30
+ end
31
+ end
32
+
33
+ shared_examples_for 'system provider' do |candidates, pkg, bin|
34
+ it { expect(javascript_runtime.provider_for_action(:install)).to be_a described_class }
35
+ it { expect(javascript_runtime.javascript_binary).to eq File.join('', 'usr', 'bin', bin) }
36
+ it { expect(system_package_candidates).to eq candidates }
37
+ it { is_expected.to install_poise_languages_system(pkg) }
38
+ it do
39
+ expect_any_instance_of(described_class).to receive(:install_system_packages)
40
+ run_chef
41
+ end
42
+ end
43
+
44
+ context 'on Ubuntu' do
45
+ let(:chefspec_options) { {platform: 'ubuntu', version: '14.04'} }
46
+ it_behaves_like 'system provider', %w{nodejs nodejs-legacy node}, 'nodejs', 'nodejs'
47
+ end # /context on Ubuntu
48
+
49
+ context 'on Gentoo' do
50
+ let(:chefspec_options) { {platform: 'gentoo', version: '2.1' } }
51
+ it_behaves_like 'system provider', %w{nodejs nodejs-legacy node}, 'nodejs', 'node'
52
+ end # /context on Gentoo
53
+
54
+ context 'on CentOS' do
55
+ let(:chefspec_options) { {platform: 'centos', version: '7.0'} }
56
+ it { expect { subject }.to raise_error PoiseLanguages::Error }
57
+ end # /context on CentOS
58
+
59
+ context 'action :uninstall' do
60
+ recipe do
61
+ javascript_runtime 'test' do
62
+ action :uninstall
63
+ provider :system
64
+ end
65
+ end
66
+
67
+ it do
68
+ expect_any_instance_of(described_class).to receive(:uninstall_system_packages)
69
+ run_chef
70
+ end
71
+ it { expect(javascript_runtime.provider_for_action(:uninstall)).to be_a described_class }
72
+ end # /context action :uninstall
73
+ end
@@ -0,0 +1,67 @@
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 PoiseJavascript::Resources::JavascriptExecute do
20
+ describe PoiseJavascript::Resources::JavascriptExecute::Resource do
21
+ recipe do
22
+ javascript_execute 'myapp.js'
23
+ end
24
+
25
+ it { is_expected.to run_javascript_execute('myapp.js') }
26
+ end # /describe PoiseJavascript::Resources::JavascriptExecute::Resource
27
+
28
+ describe PoiseJavascript::Resources::JavascriptExecute::Provider do
29
+ let(:command) { 'myapp.js' }
30
+ let(:environment) { nil }
31
+ let(:javascript) { '/node' }
32
+ let(:parent_javascript) { nil }
33
+ let(:new_resource) do
34
+ double('new_resource',
35
+ command: command,
36
+ environment: environment,
37
+ javascript: javascript,
38
+ parent_javascript: parent_javascript,
39
+ )
40
+ end
41
+ subject { described_class.new(new_resource, nil) }
42
+
43
+ context 'string command' do
44
+ its(:command) { is_expected.to eq '/node myapp.js' }
45
+ its(:environment) { is_expected.to be_nil }
46
+ end # /context string command
47
+
48
+ context 'array command' do
49
+ let(:command) { %w{myapp.js} }
50
+ its(:command) { is_expected.to eq %w{/node myapp.js} }
51
+ its(:environment) { is_expected.to be_nil }
52
+ end # /context array command
53
+
54
+ context 'with a parent' do
55
+ let(:parent_javascript) { double('parent_javascript', javascript_environment: {'PATH' => '/bin'}) }
56
+ its(:command) { is_expected.to eq '/node myapp.js' }
57
+ its(:environment) { is_expected.to eq({'PATH' => '/bin'}) }
58
+ end # /context with a parent
59
+
60
+ context 'with a parent and existing environment' do
61
+ let(:environment) { {'MAN_PATH' => '/man'} }
62
+ let(:parent_javascript) { double('parent_javascript', javascript_environment: {'PATH' => '/bin'}) }
63
+ its(:command) { is_expected.to eq '/node myapp.js' }
64
+ its(:environment) { is_expected.to eq({'PATH' => '/bin', 'MAN_PATH' => '/man'}) }
65
+ end # /context with a parent and existing environment
66
+ end # /describe PoiseJavascript::Resources::JavascriptExecute::Provider
67
+ end
@@ -0,0 +1,324 @@
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 PoiseJavascript::Resources::NodePackage do
20
+ describe PoiseJavascript::Resources::NodePackage::Resource do
21
+ describe 'action :install' do
22
+ recipe do
23
+ node_package 'express' do
24
+ version '1.2.3'
25
+ end
26
+ end
27
+
28
+ it { is_expected.to install_node_package('express').with(version: '1.2.3') }
29
+ end # /describe action :install
30
+
31
+ describe 'action :upgrade' do
32
+ recipe do
33
+ node_package 'express' do
34
+ action :upgrade
35
+ version '1.2.3'
36
+ end
37
+ end
38
+
39
+ it { is_expected.to upgrade_node_package('express').with(version: '1.2.3') }
40
+ end # /describe action :upgrade
41
+
42
+ describe 'action :remove' do
43
+ recipe do
44
+ node_package 'express' do
45
+ action :remove
46
+ version '1.2.3'
47
+ end
48
+ end
49
+
50
+ it { is_expected.to remove_node_package('express').with(version: '1.2.3') }
51
+ end # /describe action :remove
52
+
53
+ describe 'action :purge' do
54
+ recipe do
55
+ node_package 'express' do
56
+ action :purge
57
+ version '1.2.3'
58
+ end
59
+ end
60
+
61
+ it { expect { subject }.to raise_error Chef::Exceptions::ValidationFailed }
62
+ end # /describe action :purge
63
+
64
+ describe 'action :reconfig' do
65
+ recipe do
66
+ node_package 'express' do
67
+ action :reconfig
68
+ version '1.2.3'
69
+ end
70
+ end
71
+
72
+ it { expect { subject }.to raise_error Chef::Exceptions::ValidationFailed }
73
+ end # /describe action :reconfig
74
+
75
+ describe '#response_file' do
76
+ recipe do
77
+ node_package 'express' do
78
+ response_file '/response'
79
+ end
80
+ end
81
+
82
+ it { expect { subject }.to raise_error NoMethodError }
83
+ end # /describe #response_file
84
+
85
+ describe '#response_file_variables' do
86
+ recipe do
87
+ node_package 'express' do
88
+ response_file_variables({})
89
+ end
90
+ end
91
+
92
+ it { expect { subject }.to raise_error NoMethodError }
93
+ end # /describe #response_file_variables
94
+ end # /describe PoiseJavascript::Resources::NodePackage::Resource
95
+
96
+ describe PoiseJavascript::Resources::NodePackage::Provider do
97
+ let(:new_resource) { double('new_resource', path: nil, javascript: '/node', npm_binary: '/npm', user: nil, group: nil) }
98
+ let(:test_provider) { described_class.new(new_resource, nil) }
99
+
100
+ def stub_javascript_shell_out(cmd, ret, **options)
101
+ default_options = {cwd: nil, user: nil, group: nil, environment: {'PATH' => "/:#{ENV['PATH']}"}}
102
+ allow(test_provider).to receive(:javascript_shell_out!).with(cmd, default_options.merge(options)).and_return(double(stdout: ret))
103
+ end
104
+
105
+ describe '#load_current_resource' do
106
+ let(:new_resource) do
107
+ PoiseJavascript::Resources::NodePackage::Resource.new('mypkg', nil)
108
+ end
109
+ subject { test_provider.load_current_resource }
110
+
111
+ it do
112
+ expect(test_provider).to receive(:check_package_versions)
113
+ is_expected.to be_a PoiseJavascript::Resources::NodePackage::Resource
114
+ end
115
+ end # /describe #load_current_resource
116
+
117
+ describe '#check_package_versions' do
118
+ let(:package_name) { }
119
+ let(:current_resource) { PoiseJavascript::Resources::NodePackage::Resource.new(package_name, nil) }
120
+ let(:npm_version) { '2.12.1' }
121
+ let(:npm_list_out) { <<-EOH }
122
+ {
123
+ "dependencies": {
124
+ "bower": {
125
+ "version": "1.3.12",
126
+ "from": "bower@*",
127
+ "resolved": "https://registry.npmjs.org/bower/-/bower-1.3.12.tgz"
128
+ },
129
+ "coffeelint": {
130
+ "version": "1.9.3",
131
+ "from": "coffeelint@*",
132
+ "resolved": "https://registry.npmjs.org/coffeelint/-/coffeelint-1.9.3.tgz"
133
+ },
134
+ "ember-cli": {
135
+ "version": "0.2.7",
136
+ "from": "ember-cli@*",
137
+ "resolved": "https://registry.npmjs.org/ember-cli/-/ember-cli-0.2.7.tgz"
138
+ },
139
+ "gulp": {
140
+ "version": "3.8.11",
141
+ "from": "gulp@*",
142
+ "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.8.11.tgz"
143
+ },
144
+ "npm": {
145
+ "version": "2.12.1",
146
+ "from": "../../../../../../../private/tmp/node20150704-67289-jytzoh/node-v0.12.6/npm_install",
147
+ "resolved": "file:../../../../../../../private/tmp/node20150704-67289-jytzoh/node-v0.12.6/npm_install"
148
+ },
149
+ "phantomjs": {
150
+ "version": "1.9.16",
151
+ "from": "phantomjs@*",
152
+ "resolved": "https://registry.npmjs.org/phantomjs/-/phantomjs-1.9.16.tgz"
153
+ }
154
+ }
155
+ }
156
+ EOH
157
+ subject do
158
+ test_provider.check_package_versions(current_resource)
159
+ {version: current_resource.version, candidate_version: test_provider.candidate_version}
160
+ end
161
+ before do
162
+ allow(test_provider).to receive(:npm_version).and_return(Gem::Version.new(npm_version))
163
+ end
164
+
165
+ context 'with a single package' do
166
+ let(:package_name) { 'express' }
167
+
168
+ before do
169
+ stub_javascript_shell_out(%w{/npm list --json --global --depth 0}, npm_list_out)
170
+ stub_javascript_shell_out(%w{/npm show --json --global express}, '{"version": "1.2.3"}')
171
+ end
172
+
173
+ its([:version]) { is_expected.to be_nil }
174
+ its([:candidate_version]) { is_expected.to eq '1.2.3' }
175
+ end # /context with a single package
176
+
177
+ context 'with an already installed package' do
178
+ let(:package_name) { 'bower' }
179
+
180
+ before do
181
+ stub_javascript_shell_out(%w{/npm list --json --global --depth 0}, npm_list_out)
182
+ stub_javascript_shell_out(%w{/npm outdated --json --global}, <<-EOH)
183
+ {
184
+ "bower": {
185
+ "current": "1.3.12",
186
+ "wanted": "1.5.2",
187
+ "latest": "1.5.2",
188
+ "location": "/usr/local/lib/node_modules/bower"
189
+ }
190
+ }
191
+ EOH
192
+ end
193
+
194
+ its([:version]) { is_expected.to eq '1.3.12' }
195
+ its([:candidate_version]) { is_expected.to eq '1.5.2' }
196
+ end # /context with an already installed package
197
+
198
+ context 'with multiple packages' do
199
+ let(:package_name) { %w{express bower} }
200
+
201
+ before do
202
+ stub_javascript_shell_out(%w{/npm list --json --global --depth 0}, npm_list_out)
203
+ stub_javascript_shell_out(%w{/npm outdated --json --global}, <<-EOH)
204
+ {
205
+ "bower": {
206
+ "current": "1.3.12",
207
+ "wanted": "1.5.2",
208
+ "latest": "1.5.2",
209
+ "location": "/usr/local/lib/node_modules/bower"
210
+ }
211
+ }
212
+ EOH
213
+ stub_javascript_shell_out(%w{/npm show --json --global express}, '{"version": "1.2.3"}')
214
+ end
215
+
216
+ its([:version]) { is_expected.to eq [nil, '1.3.12'] }
217
+ its([:candidate_version]) { is_expected.to eq %w{1.2.3 1.5.2} }
218
+ end # /context with multiple packages
219
+
220
+ context 'with empty outdated' do
221
+ let(:package_name) { 'bower' }
222
+
223
+ before do
224
+ stub_javascript_shell_out(%w{/npm list --json --global --depth 0}, npm_list_out)
225
+ stub_javascript_shell_out(%w{/npm outdated --json --global}, '')
226
+ end
227
+
228
+ its([:version]) { is_expected.to eq '1.3.12' }
229
+ its([:candidate_version]) { is_expected.to eq '1.3.12' }
230
+ end # /context with empty outdated
231
+ end # /describe #check_package_versions
232
+
233
+ describe '#install_package' do
234
+ let(:unsafe_perm) { true }
235
+ let(:source) { nil }
236
+ before do
237
+ allow(new_resource).to receive(:unsafe_perm).and_return(unsafe_perm)
238
+ allow(new_resource).to receive(:source).and_return(source)
239
+ end
240
+
241
+ context 'with a package' do
242
+ it do
243
+ stub_javascript_shell_out(%w{/npm install --json --global --unsafe-perm true express@1.2.3}, '')
244
+ test_provider.install_package('express', '1.2.3')
245
+ end
246
+ end # /context with a package
247
+
248
+ context 'with mutliple packages' do
249
+ it do
250
+ stub_javascript_shell_out(%w{/npm install --json --global --unsafe-perm true express@1.2.3 bower@1.3.12}, '')
251
+ test_provider.install_package(%w{express bower}, %w{1.2.3 1.3.12})
252
+ end
253
+ end # /context with mutliple packages
254
+
255
+ context 'with a source' do
256
+ let(:source) { 'git@example.com'}
257
+ it do
258
+ stub_javascript_shell_out(%w{/npm install --json --global --unsafe-perm true git@example.com}, '')
259
+ test_provider.install_package('express', '1.2.3')
260
+ end
261
+ end # /context with a source
262
+
263
+ context 'with unsafe_perm false' do
264
+ let(:unsafe_perm) { false }
265
+ it do
266
+ stub_javascript_shell_out(%w{/npm install --json --global --unsafe-perm false express@1.2.3}, '')
267
+ test_provider.install_package('express', '1.2.3')
268
+ end
269
+ end # /context with unsafe_perm false
270
+
271
+ context 'with unsafe_perm nil' do
272
+ let(:unsafe_perm) { nil }
273
+ it do
274
+ stub_javascript_shell_out(%w{/npm install --json --global express@1.2.3}, '')
275
+ test_provider.install_package('express', '1.2.3')
276
+ end
277
+ end # /context with unsafe_perm nil
278
+ end # /describe #install_package
279
+
280
+ describe '#remove_package' do
281
+ # Side effectsssss.
282
+ it do
283
+ stub_javascript_shell_out(%w{/npm uninstall --json --global express}, 'something that is not JSON')
284
+ test_provider.remove_package('express', '1.2.3')
285
+ end
286
+ end # /describe #remove_package
287
+
288
+ describe '#npm_version' do
289
+ let(:npm_version_output) { '' }
290
+ subject { test_provider.send(:npm_version).to_s }
291
+ before do
292
+ allow(test_provider).to receive(:javascript_shell_out!).with(%w{/npm version}).and_return(double('shell_out', stdout: npm_version_output))
293
+ end
294
+
295
+ context 'with empty output' do
296
+ it { expect { subject }.to raise_error PoiseJavascript::Error }
297
+ end # /context with empty output
298
+
299
+ context 'with expected output' do
300
+ let(:npm_version_output) { <<-EOH }
301
+ { npm: '2.12.1',
302
+ http_parser: '2.3',
303
+ modules: '14',
304
+ node: '0.12.6',
305
+ openssl: '1.0.1o',
306
+ uv: '1.6.1',
307
+ v8: '3.28.71.19',
308
+ zlib: '1.2.8' }
309
+ EOH
310
+ it { is_expected.to eq '2.12.1' }
311
+ end # /context with expected output
312
+ end # /describe #npm_version
313
+
314
+ describe '#npm_version?' do
315
+ let(:version_req) { '>= 1.0.0'}
316
+ subject { test_provider.send(:npm_version?, version_req) }
317
+ before do
318
+ allow(test_provider).to receive(:npm_version).and_return(Gem::Version.new('1.0.0'))
319
+ end
320
+
321
+ it { is_expected.to be true }
322
+ end # /describe #npm_version?
323
+ end # /describe PoiseJavascript::Resources::NodePackage::Provider
324
+ end