poise-javascript 1.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 +11 -0
- data/.kitchen.travis.yml +9 -0
- data/.kitchen.yml +8 -0
- data/.travis.yml +21 -0
- data/.yardopts +7 -0
- data/Berksfile +28 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +33 -0
- data/LICENSE +201 -0
- data/README.md +332 -0
- data/Rakefile +17 -0
- data/chef/attributes/default.rb +23 -0
- data/chef/recipes/default.rb +19 -0
- data/lib/poise_javascript.rb +24 -0
- data/lib/poise_javascript/cheftie.rb +18 -0
- data/lib/poise_javascript/error.rb +23 -0
- data/lib/poise_javascript/javascript_command_mixin.rb +56 -0
- data/lib/poise_javascript/javascript_providers.rb +40 -0
- data/lib/poise_javascript/javascript_providers/base.rb +97 -0
- data/lib/poise_javascript/javascript_providers/dummy.rb +77 -0
- data/lib/poise_javascript/javascript_providers/iojs.rb +64 -0
- data/lib/poise_javascript/javascript_providers/nodejs.rb +64 -0
- data/lib/poise_javascript/javascript_providers/scl.rb +79 -0
- data/lib/poise_javascript/javascript_providers/system.rb +71 -0
- data/lib/poise_javascript/resources.rb +29 -0
- data/lib/poise_javascript/resources/javascript_execute.rb +83 -0
- data/lib/poise_javascript/resources/javascript_runtime.rb +85 -0
- data/lib/poise_javascript/resources/javascript_runtime_test.rb +226 -0
- data/lib/poise_javascript/resources/node_package.rb +254 -0
- data/lib/poise_javascript/resources/npm_install.rb +94 -0
- data/lib/poise_javascript/version.rb +20 -0
- data/poise-javascript.gemspec +41 -0
- data/test/cookbooks/poise-javascript_test/metadata.rb +18 -0
- data/test/cookbooks/poise-javascript_test/recipes/default.rb +49 -0
- data/test/gemfiles/chef-12.gemfile +19 -0
- data/test/gemfiles/master.gemfile +23 -0
- data/test/integration/default/serverspec/default_spec.rb +107 -0
- data/test/spec/javascript_command_mixin_spec.rb +59 -0
- data/test/spec/javascript_providers/base_spec.rb +89 -0
- data/test/spec/javascript_providers/dummy_spec.rb +62 -0
- data/test/spec/javascript_providers/iojs_spec.rb +77 -0
- data/test/spec/javascript_providers/nodejs_spec.rb +82 -0
- data/test/spec/javascript_providers/scl_spec.rb +68 -0
- data/test/spec/javascript_providers/system_spec.rb +73 -0
- data/test/spec/resources/javascript_execute_spec.rb +67 -0
- data/test/spec/resources/node_package_spec.rb +324 -0
- data/test/spec/resources/npm_install_spec.rb +118 -0
- data/test/spec/spec_helper.rb +19 -0
- metadata +169 -0
@@ -0,0 +1,19 @@
|
|
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.0'
|
@@ -0,0 +1,23 @@
|
|
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', github: 'chef/chef'
|
20
|
+
gem 'halite', github: 'poise/halite'
|
21
|
+
gem 'poise', github: 'poise/poise'
|
22
|
+
gem 'poise-boiler', github: 'poise/poise-boiler'
|
23
|
+
gem 'poise-languages', github: 'poise/poise-languages'
|
@@ -0,0 +1,107 @@
|
|
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 'serverspec'
|
18
|
+
set :backend, :exec
|
19
|
+
|
20
|
+
# Set up the shared example for javascript_runtime_test.
|
21
|
+
RSpec.shared_examples 'a javascript_runtime_test' do |javascript_name, version=nil|
|
22
|
+
let(:javascript_name) { javascript_name }
|
23
|
+
let(:javascript_path) { File.join('', 'root', "javascript_test_#{javascript_name}") }
|
24
|
+
# Helper for all the file checks.
|
25
|
+
def self.assert_file(rel_path, should_exist=true, &block)
|
26
|
+
describe rel_path do
|
27
|
+
subject { file(File.join(javascript_path, rel_path)) }
|
28
|
+
# Do nothing for nil.
|
29
|
+
if should_exist == true
|
30
|
+
it { is_expected.to be_a_file }
|
31
|
+
elsif should_exist == false
|
32
|
+
it { is_expected.to_not exist }
|
33
|
+
end
|
34
|
+
instance_eval(&block) if block
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'javascript_runtime' do
|
39
|
+
assert_file('version') do
|
40
|
+
its(:content) { is_expected.to start_with version } if version
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'npm_install' do
|
45
|
+
assert_file('sentinel_npm_install_one')
|
46
|
+
assert_file('sentinel_npm_install_two', false)
|
47
|
+
assert_file('require_express') do
|
48
|
+
its(:content) { is_expected.to eq '4.13.3' }
|
49
|
+
end
|
50
|
+
assert_file('require_handlebars', false)
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'node_package' do
|
54
|
+
assert_file('sentinel_test1_express_one')
|
55
|
+
assert_file('sentinel_test1_express_two', false)
|
56
|
+
assert_file('sentinel_test1_multi')
|
57
|
+
assert_file('sentinel_test1_multi_overlap')
|
58
|
+
assert_file('sentinel_test1_bower', false)
|
59
|
+
assert_file('require_node_package_express') do
|
60
|
+
its(:content) { is_expected.to_not eq '' }
|
61
|
+
end
|
62
|
+
assert_file('require_gulp') do
|
63
|
+
its(:content) { is_expected.to_not eq '' }
|
64
|
+
end
|
65
|
+
assert_file('require_less') do
|
66
|
+
its(:content) { is_expected.to_not eq '' }
|
67
|
+
end
|
68
|
+
assert_file('require_bower') do
|
69
|
+
its(:content) { is_expected.to_not eq '' }
|
70
|
+
end
|
71
|
+
assert_file('require_yo') do
|
72
|
+
its(:content) { is_expected.to eq '1.4.5' }
|
73
|
+
end unless File.exist?(File.join('', 'root', "javascript_test_#{javascript_name}", 'no_yo'))
|
74
|
+
assert_file('require_forever') do
|
75
|
+
its(:content) { is_expected.to eq '0.13.0' }
|
76
|
+
end
|
77
|
+
|
78
|
+
assert_file('sentinel_test2_express')
|
79
|
+
|
80
|
+
assert_file('sentinel_grunt_one')
|
81
|
+
assert_file('sentinel_grunt_two', false)
|
82
|
+
assert_file('require_grunt-cli', false)
|
83
|
+
assert_file('grunt_version') do
|
84
|
+
its(:content) { is_expected.to start_with 'grunt-cli v' }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'nodejs' do
|
90
|
+
it_should_behave_like 'a javascript_runtime_test', 'nodejs'
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'node 0.10' do
|
94
|
+
it_should_behave_like 'a javascript_runtime_test', 'nodejs-0.10', 'v0.10'
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'iojs' do
|
98
|
+
it_should_behave_like 'a javascript_runtime_test', 'iojs'
|
99
|
+
end
|
100
|
+
|
101
|
+
describe 'system provider', unless: File.exist?('/no_system') do
|
102
|
+
it_should_behave_like 'a javascript_runtime_test', 'system'
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'scl provider', unless: File.exist?('/no_scl') do
|
106
|
+
it_should_behave_like 'a javascript_runtime_test', 'scl'
|
107
|
+
end
|
@@ -0,0 +1,59 @@
|
|
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::JavascriptCommandMixin do
|
20
|
+
describe PoiseJavascript::JavascriptCommandMixin::Resource do
|
21
|
+
resource(:poise_test) do
|
22
|
+
include described_class
|
23
|
+
end
|
24
|
+
provider(:poise_test)
|
25
|
+
subject { resource(:poise_test).new('test', nil) }
|
26
|
+
|
27
|
+
it { is_expected.to respond_to :parent_javascript }
|
28
|
+
it { is_expected.to respond_to :javascript }
|
29
|
+
it { expect(subject.respond_to?(:javascript_from_parent, true)).to be true }
|
30
|
+
|
31
|
+
describe '#npm_binary' do
|
32
|
+
context 'with a parent' do
|
33
|
+
recipe do
|
34
|
+
javascript_runtime 'test' do
|
35
|
+
provider :dummy
|
36
|
+
end
|
37
|
+
poise_test 'test'
|
38
|
+
end
|
39
|
+
|
40
|
+
it { is_expected.to run_poise_test('test').with(npm_binary: '/npm') }
|
41
|
+
end # /context with a parent
|
42
|
+
|
43
|
+
context 'without a parent' do
|
44
|
+
recipe do
|
45
|
+
poise_test 'test' do
|
46
|
+
extend RSpec::Matchers
|
47
|
+
extend RSpec::Mocks::ExampleMethods
|
48
|
+
expect(PoiseLanguages::Utils).to receive(:which).with('node').and_return('/something/node')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it { is_expected.to run_poise_test('test').with(npm_binary: '/something/npm') }
|
53
|
+
end # /context without a parent
|
54
|
+
end # /describe #npm_binary
|
55
|
+
end # /describe PoiseJavascript::JavascriptCommandMixin::Resource
|
56
|
+
|
57
|
+
describe PoiseJavascript::JavascriptCommandMixin::Provider do
|
58
|
+
end # /describe PoiseJavascript::JavascriptCommandMixin::Provider
|
59
|
+
end
|
@@ -0,0 +1,89 @@
|
|
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::Base do
|
20
|
+
# Literally only here for coverage.
|
21
|
+
step_into(:javascript_runtime)
|
22
|
+
provider(:poise_test, parent: described_class) do
|
23
|
+
provides(:poise_test)
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'install_javascript' do
|
27
|
+
recipe do
|
28
|
+
javascript_runtime 'test' do
|
29
|
+
provider :poise_test
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it { expect { subject }.to raise_error NotImplementedError }
|
34
|
+
end # /describe install_javascript
|
35
|
+
|
36
|
+
describe 'uninstall_javascript' do
|
37
|
+
recipe do
|
38
|
+
javascript_runtime 'test' do
|
39
|
+
action :uninstall
|
40
|
+
provider :poise_test
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it { expect { subject }.to raise_error NotImplementedError }
|
45
|
+
end # /describe uninstall_javascript
|
46
|
+
|
47
|
+
describe '#javascript_binary' do
|
48
|
+
recipe(subject: false) do
|
49
|
+
javascript_runtime 'test' do
|
50
|
+
action :nothing
|
51
|
+
provider :poise_test
|
52
|
+
end
|
53
|
+
end
|
54
|
+
subject { chef_run.javascript_runtime('test').javascript_binary }
|
55
|
+
|
56
|
+
it { expect { subject }.to raise_error NotImplementedError }
|
57
|
+
end # /describe #javascript_binary
|
58
|
+
|
59
|
+
describe '#javascript_environment' do
|
60
|
+
recipe(subject: false) do
|
61
|
+
javascript_runtime 'test' do
|
62
|
+
action :nothing
|
63
|
+
provider :poise_test
|
64
|
+
end
|
65
|
+
end
|
66
|
+
subject { chef_run.javascript_runtime('test').javascript_environment }
|
67
|
+
|
68
|
+
it { is_expected.to eq({}) }
|
69
|
+
end # /describe #javascript_environment
|
70
|
+
|
71
|
+
describe '#npm_binary' do
|
72
|
+
provider(:poise_test2, parent: described_class) do
|
73
|
+
provides(:poise_test2)
|
74
|
+
|
75
|
+
def javascript_binary
|
76
|
+
'/usr/bin/node'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
recipe(subject: false) do
|
80
|
+
javascript_runtime 'test' do
|
81
|
+
action :nothing
|
82
|
+
provider :poise_test2
|
83
|
+
end
|
84
|
+
end
|
85
|
+
subject { chef_run.javascript_runtime('test').npm_binary }
|
86
|
+
|
87
|
+
it { is_expected.to eq '/usr/bin/npm' }
|
88
|
+
end # /describe #npm_binary
|
89
|
+
end
|
@@ -0,0 +1,62 @@
|
|
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::Dummy do
|
20
|
+
let(:javascript_runtime) { chef_run.javascript_runtime('test') }
|
21
|
+
step_into(:javascript_runtime)
|
22
|
+
recipe do
|
23
|
+
javascript_runtime 'test' do
|
24
|
+
provider :dummy
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#javascript_binary' do
|
29
|
+
subject { javascript_runtime.javascript_binary }
|
30
|
+
|
31
|
+
it { is_expected.to eq '/node' }
|
32
|
+
end # /describe #javascript_binary
|
33
|
+
|
34
|
+
describe '#javascript_environment' do
|
35
|
+
subject { javascript_runtime.javascript_environment }
|
36
|
+
|
37
|
+
it { is_expected.to eq({}) }
|
38
|
+
end # /describe #javascript_environment
|
39
|
+
|
40
|
+
describe '#npm_binary' do
|
41
|
+
subject { javascript_runtime.npm_binary }
|
42
|
+
|
43
|
+
it { is_expected.to eq '/npm' }
|
44
|
+
end # /describe #npm_binary
|
45
|
+
|
46
|
+
describe 'action :install' do
|
47
|
+
# Just make sure it doesn't error.
|
48
|
+
it { run_chef }
|
49
|
+
end # /describe action :install
|
50
|
+
|
51
|
+
describe 'action :uninstall' do
|
52
|
+
recipe do
|
53
|
+
javascript_runtime 'test' do
|
54
|
+
action :uninstall
|
55
|
+
provider :dummy
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Just make sure it doesn't error.
|
60
|
+
it { run_chef }
|
61
|
+
end # /describe action :uninstall
|
62
|
+
end
|
@@ -0,0 +1,77 @@
|
|
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::IOJS do
|
20
|
+
let(:javascript_version) { nil }
|
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
|
+
step_into(:javascript_runtime)
|
25
|
+
recipe do
|
26
|
+
javascript_runtime 'test' do
|
27
|
+
version node['poise_javascript_version']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
shared_examples_for 'iojs provider' do |base, url|
|
32
|
+
it { expect(javascript_runtime.provider_for_action(:install)).to be_a described_class }
|
33
|
+
it { is_expected.to install_poise_languages_static(File.join('', 'opt', base)).with(source: url) }
|
34
|
+
it { expect(javascript_runtime.javascript_binary).to eq File.join('', 'opt', base, 'bin', 'iojs') }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'with version iojs' do
|
38
|
+
let(:javascript_version) { 'iojs' }
|
39
|
+
it_behaves_like 'iojs provider', 'iojs-3.2.0', 'https://iojs.org/dist/v3.2.0/iojs-v3.2.0-linux-x64.tar.gz'
|
40
|
+
end # /context with version iojs
|
41
|
+
|
42
|
+
context 'with version iojs-2' do
|
43
|
+
let(:javascript_version) { 'iojs-2' }
|
44
|
+
it_behaves_like 'iojs provider', 'iojs-2.5.0', 'https://iojs.org/dist/v2.5.0/iojs-v2.5.0-linux-x64.tar.gz'
|
45
|
+
end # /context with version iojs-2
|
46
|
+
|
47
|
+
context 'with version iojs-2.4.0' do
|
48
|
+
let(:javascript_version) { 'iojs-2.4.0' }
|
49
|
+
it_behaves_like 'iojs provider', 'iojs-2.4.0', 'https://iojs.org/dist/v2.4.0/iojs-v2.4.0-linux-x64.tar.gz'
|
50
|
+
end # /context with version iojs-2.4.0
|
51
|
+
|
52
|
+
context 'with version 3' do
|
53
|
+
let(:javascript_version) { '3' }
|
54
|
+
it_behaves_like 'iojs provider', 'iojs-3.2.0', 'https://iojs.org/dist/v3.2.0/iojs-v3.2.0-linux-x64.tar.gz'
|
55
|
+
end # /context with version 3
|
56
|
+
|
57
|
+
context 'with 32-bit OS' do
|
58
|
+
recipe do
|
59
|
+
node.automatic['kernel']['machine'] = 'i686'
|
60
|
+
javascript_runtime 'test' do
|
61
|
+
version 'iojs'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
it_behaves_like 'iojs provider', 'iojs-3.2.0', 'https://iojs.org/dist/v3.2.0/iojs-v3.2.0-linux-x86.tar.gz'
|
65
|
+
end # /context with 32-bit OS
|
66
|
+
|
67
|
+
context 'action :uninstall' do
|
68
|
+
recipe do
|
69
|
+
javascript_runtime 'test' do
|
70
|
+
version 'iojs'
|
71
|
+
action :uninstall
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it { is_expected.to uninstall_poise_languages_static('/opt/iojs-3.2.0') }
|
76
|
+
end # /context action :uninstall
|
77
|
+
end
|
@@ -0,0 +1,82 @@
|
|
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::NodeJS do
|
20
|
+
let(:javascript_version) { nil }
|
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
|
+
step_into(:javascript_runtime)
|
25
|
+
recipe do
|
26
|
+
javascript_runtime 'test' do
|
27
|
+
version node['poise_javascript_version']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
shared_examples_for 'nodejs provider' do |base, url|
|
32
|
+
it { expect(javascript_runtime.provider_for_action(:install)).to be_a described_class }
|
33
|
+
it { is_expected.to install_poise_languages_static(File.join('', 'opt', base)).with(source: url) }
|
34
|
+
it { expect(javascript_runtime.javascript_binary).to eq File.join('', 'opt', base, 'bin', 'node') }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'with version ""' do
|
38
|
+
let(:javascript_version) { '' }
|
39
|
+
it_behaves_like 'nodejs provider', 'nodejs-4.1.1', 'https://nodejs.org/dist/v4.1.1/node-v4.1.1-linux-x64.tar.gz'
|
40
|
+
end # /context with version ""
|
41
|
+
|
42
|
+
context 'with version nodejs' do
|
43
|
+
let(:javascript_version) { 'nodejs' }
|
44
|
+
it_behaves_like 'nodejs provider', 'nodejs-4.1.1', 'https://nodejs.org/dist/v4.1.1/node-v4.1.1-linux-x64.tar.gz'
|
45
|
+
end # /context with version nodejs
|
46
|
+
|
47
|
+
context 'with version nodejs-0.10' do
|
48
|
+
let(:javascript_version) { 'nodejs-0.10' }
|
49
|
+
it_behaves_like 'nodejs provider', 'nodejs-0.10.40', 'https://nodejs.org/dist/v0.10.40/node-v0.10.40-linux-x64.tar.gz'
|
50
|
+
end # /context with version nodejs-0.10
|
51
|
+
|
52
|
+
context 'with version nodejs-0.10.30' do
|
53
|
+
let(:javascript_version) { 'nodejs-0.10.30' }
|
54
|
+
it_behaves_like 'nodejs provider', 'nodejs-0.10.30', 'https://nodejs.org/dist/v0.10.30/node-v0.10.30-linux-x64.tar.gz'
|
55
|
+
end # /context with version nodejs-0.10.30
|
56
|
+
|
57
|
+
context 'with version 0.12' do
|
58
|
+
let(:javascript_version) { '0.12' }
|
59
|
+
it_behaves_like 'nodejs provider', 'nodejs-0.12.7', 'https://nodejs.org/dist/v0.12.7/node-v0.12.7-linux-x64.tar.gz'
|
60
|
+
end # /context with version 0.12
|
61
|
+
|
62
|
+
context 'with 32-bit OS' do
|
63
|
+
recipe do
|
64
|
+
node.automatic['kernel']['machine'] = 'i686'
|
65
|
+
javascript_runtime 'test' do
|
66
|
+
version ''
|
67
|
+
end
|
68
|
+
end
|
69
|
+
it_behaves_like 'nodejs provider', 'nodejs-4.1.1', 'https://nodejs.org/dist/v4.1.1/node-v4.1.1-linux-x86.tar.gz'
|
70
|
+
end # /context with 32-bit OS
|
71
|
+
|
72
|
+
context 'action :uninstall' do
|
73
|
+
recipe do
|
74
|
+
javascript_runtime 'test' do
|
75
|
+
version ''
|
76
|
+
action :uninstall
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it { is_expected.to uninstall_poise_languages_static('/opt/nodejs-4.1.1') }
|
81
|
+
end # /context action :uninstall
|
82
|
+
end
|