poise-boiler 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.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +18 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +31 -0
- data/LICENSE +202 -0
- data/README.md +107 -0
- data/Rakefile +33 -0
- data/lib/poise-boiler.rb +17 -0
- data/lib/poise_boiler.rb +28 -0
- data/lib/poise_boiler/error.rb +24 -0
- data/lib/poise_boiler/helpers.rb +26 -0
- data/lib/poise_boiler/helpers/rake.rb +43 -0
- data/lib/poise_boiler/helpers/rake/badges.rb +124 -0
- data/lib/poise_boiler/helpers/rake/core.rb +71 -0
- data/lib/poise_boiler/helpers/rake/travis.rb +132 -0
- data/lib/poise_boiler/helpers/spec_helper.rb +79 -0
- data/lib/poise_boiler/kitchen.rb +96 -0
- data/lib/poise_boiler/rake.rb +18 -0
- data/lib/poise_boiler/rakefile.rb +18 -0
- data/lib/poise_boiler/spec_helper.rb +18 -0
- data/lib/poise_boiler/version.rb +20 -0
- data/poise-boiler.gemspec +69 -0
- data/spec/helpers/badge_spec.rb +100 -0
- data/spec/helpers/travis_spec.rb +50 -0
- data/spec/kitchen_spec.rb +92 -0
- data/spec/rakefile_spec.rb +74 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/spec_helper_spec.rb +74 -0
- metadata +414 -0
@@ -0,0 +1,96 @@
|
|
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 'kitchen'
|
18
|
+
require 'kitchen-sync'
|
19
|
+
|
20
|
+
|
21
|
+
module PoiseBoiler
|
22
|
+
# Helpers for Test-Kitchen and .kitchen.yml configuration.
|
23
|
+
#
|
24
|
+
# @since 1.0.0
|
25
|
+
module Kitchen
|
26
|
+
extend self
|
27
|
+
# Shorthand names for kitchen platforms.
|
28
|
+
#
|
29
|
+
# @see PoiseBoiler::Kitchen.kitchen
|
30
|
+
PLATFORM_ALIASES = {
|
31
|
+
'ubuntu' => %w{ubuntu-12.04 ubuntu-14.04},
|
32
|
+
'rhel' => %w{centos-6 centos-7},
|
33
|
+
'centos' => %w{rhel},
|
34
|
+
'linux' => %w{ubuntu rhel},
|
35
|
+
}
|
36
|
+
|
37
|
+
# Return a YAML string suitable for inclusion in a .kitchen.yml config. This
|
38
|
+
# will include the standard Poise/Halite boilerplate and some default values.
|
39
|
+
#
|
40
|
+
# @param platforms [String, Array<String>] Name(s) of platforms to use by default.
|
41
|
+
# @see PoiseBoiler::Kitchen::PLATFORM_ALIASES
|
42
|
+
# @example .kitchen.yml
|
43
|
+
# #<% require 'poise_boiler' %>
|
44
|
+
# <%= PoiseBoiler.kitchen %>
|
45
|
+
def kitchen(platforms: 'ubuntu-14.04')
|
46
|
+
# SPEC_BLOCK_CI is used to force non-locking behavior inside tests.
|
47
|
+
chef_version = ENV['CHEF_VERSION'] || if ENV['SPEC_BLOCK_CI'] != 'true'
|
48
|
+
# If there isn't a specific override, lock TK to use the same version of Chef as the Gemfile.
|
49
|
+
require 'chef/version'
|
50
|
+
Chef::VERSION
|
51
|
+
end
|
52
|
+
{
|
53
|
+
'chef_versions' => %w{12},
|
54
|
+
'driver' => {
|
55
|
+
'name' => (ENV['TRAVIS'] == 'true' ? 'dummy' : 'vagrant'),
|
56
|
+
'require_chef_omnibus' => chef_version || true,
|
57
|
+
'provision_command' => [
|
58
|
+
# Run some installs at provision so they are cached in the image.
|
59
|
+
# Install Chef (with the correct verison).
|
60
|
+
"curl -L https://chef.io/chef/install.sh | bash -s --" + (chef_version ? " -v #{chef_version}" : '' ),
|
61
|
+
# Install some kitchen-related gems. Normally installed during the verify step but that is idempotent.
|
62
|
+
"env GEM_HOME=/tmp/verifier/gems GEM_PATH=/tmp/verifier/gems GEM_CACHE=/tmp/verifier/gems/cache /opt/chef/embedded/bin/gem install thor busser busser-serverspec serverspec bundler",
|
63
|
+
# Fix directory permissions.
|
64
|
+
"chown -R kitchen /tmp/verifier",
|
65
|
+
],
|
66
|
+
},
|
67
|
+
'platforms' => expand_kitchen_platforms(platforms).map {|p| {'name' => p, 'run_list' => platform_run_list(p)} },
|
68
|
+
}.to_yaml.gsub(/---[ \n]/, '')
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
# Expand aliases from PLATFORM_ALIASES.
|
74
|
+
def expand_kitchen_platforms(platforms)
|
75
|
+
platforms = Array(platforms)
|
76
|
+
last_platforms = []
|
77
|
+
while platforms != last_platforms
|
78
|
+
last_platforms = platforms
|
79
|
+
platforms = platforms.map {|p| PLATFORM_ALIASES[p] || p}.flatten.uniq
|
80
|
+
end
|
81
|
+
platforms
|
82
|
+
end
|
83
|
+
|
84
|
+
# Return the platform-level run list for a given platform.
|
85
|
+
#
|
86
|
+
# @param platform [String] Platform name.
|
87
|
+
# @return [Array<String>]
|
88
|
+
def platform_run_list(platform)
|
89
|
+
if platform.start_with?('debian') || platform.start_with?('ubuntu')
|
90
|
+
%w{apt}
|
91
|
+
else
|
92
|
+
[]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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 'poise_boiler/helpers/rake'
|
18
|
+
::PoiseBoiler::Helpers::Rake.install
|
@@ -0,0 +1,18 @@
|
|
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
|
+
# This is just an alias for rake.rb
|
18
|
+
require 'poise_boiler/rake'
|
@@ -0,0 +1,18 @@
|
|
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 'poise_boiler/helpers/spec_helper'
|
18
|
+
::PoiseBoiler::Helpers::SpecHelper.install
|
@@ -0,0 +1,20 @@
|
|
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
|
+
|
18
|
+
module PoiseBoiler
|
19
|
+
VERSION = '1.0.0'
|
20
|
+
end
|
@@ -0,0 +1,69 @@
|
|
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
|
+
lib = File.expand_path('../lib', __FILE__)
|
18
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
19
|
+
require 'poise_boiler/version'
|
20
|
+
|
21
|
+
Gem::Specification.new do |spec|
|
22
|
+
spec.name = 'poise-boiler'
|
23
|
+
spec.version = PoiseBoiler::VERSION
|
24
|
+
spec.authors = ['Noah Kantrowitz']
|
25
|
+
spec.email = %w{noah@coderanger.net}
|
26
|
+
spec.description = 'Boilerplate-reduction helpers for Poise/Halite-style gemss.'
|
27
|
+
spec.summary = spec.description
|
28
|
+
spec.homepage = 'https://github.com/poise/poise-boiler'
|
29
|
+
spec.license = 'Apache 2.0'
|
30
|
+
spec.metadata['halite_ignore'] = 'true'
|
31
|
+
|
32
|
+
spec.files = `git ls-files`.split($/)
|
33
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
34
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
35
|
+
spec.require_paths = %w{lib}
|
36
|
+
|
37
|
+
# Development gems
|
38
|
+
spec.add_dependency 'addressable', '~> 2.3'
|
39
|
+
spec.add_dependency 'rake', '~> 10.4'
|
40
|
+
spec.add_dependency 'travis', '~> 1.7'
|
41
|
+
spec.add_dependency 'yard', '~> 0.8'
|
42
|
+
spec.add_dependency 'yard-classmethods', '~> 1.0'
|
43
|
+
spec.add_dependency 'halite', '~> 1.0' # This is a circular dependency
|
44
|
+
spec.add_dependency 'mixlib-shellout', '>= 1.4', '< 3.0' # Chef 11 means shellout 1.4 :-(
|
45
|
+
spec.add_dependency 'pry' # Travis depends on old-ass pry, see https://github.com/travis-ci/travis.rb/issues/245
|
46
|
+
|
47
|
+
# Test gems
|
48
|
+
spec.add_dependency 'rspec', '~> 3.2'
|
49
|
+
spec.add_dependency 'rspec-its', '~> 1.2'
|
50
|
+
spec.add_dependency 'chefspec', '~> 4.2'
|
51
|
+
spec.add_dependency 'fuubar', '~> 2.0'
|
52
|
+
spec.add_dependency 'simplecov', '~> 0.9'
|
53
|
+
spec.add_dependency 'foodcritic', '~> 4.0'
|
54
|
+
|
55
|
+
# Integration gems
|
56
|
+
spec.add_dependency 'test-kitchen', '~> 1.3'
|
57
|
+
spec.add_dependency 'kitchen-vagrant'
|
58
|
+
spec.add_dependency 'vagrant-wrapper'
|
59
|
+
spec.add_dependency 'kitchen-docker'
|
60
|
+
spec.add_dependency 'kitchen-sync'
|
61
|
+
spec.add_dependency 'berkshelf', '~> 3.2'
|
62
|
+
|
63
|
+
# Travis gems
|
64
|
+
spec.add_dependency 'codeclimate-test-reporter', '~> 0.4'
|
65
|
+
spec.add_dependency 'codecov', '~> 0.0', '>= 0.0.2'
|
66
|
+
|
67
|
+
# Development dependencies (yo dawg)
|
68
|
+
spec.add_development_dependency 'rspec-command', '~> 1.0'
|
69
|
+
end
|
@@ -0,0 +1,100 @@
|
|
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 PoiseBoiler::Helpers::Rake::Badges do
|
20
|
+
describe '#detect_github' do
|
21
|
+
let(:instance) { described_class.new(gem_name: '', base: '') }
|
22
|
+
subject { instance.send(:detect_github) }
|
23
|
+
|
24
|
+
context 'with normal data' do
|
25
|
+
before do
|
26
|
+
expect(instance).to receive(:git_shell_out).with(%w{name-rev --name-only HEAD}).and_return('master')
|
27
|
+
expect(instance).to receive(:git_shell_out).with(%w{config --get branch.master.remote}).and_return('origin')
|
28
|
+
expect(instance).to receive(:git_shell_out).with(%w{ls-remote --get-url origin}).and_return('git@github.com:poise/example.git')
|
29
|
+
end
|
30
|
+
it { is_expected.to eq 'poise/example' }
|
31
|
+
end # /context with normal data
|
32
|
+
|
33
|
+
context 'with no default remote' do
|
34
|
+
before do
|
35
|
+
expect(instance).to receive(:git_shell_out).with(%w{name-rev --name-only HEAD}).and_return('master')
|
36
|
+
expect(instance).to receive(:git_shell_out).with(%w{config --get branch.master.remote}).and_return('')
|
37
|
+
expect(instance).to receive(:git_shell_out).with(%w{ls-remote --get-url origin}).and_return('git@github.com:poise/example.git')
|
38
|
+
end
|
39
|
+
it { is_expected.to eq 'poise/example' }
|
40
|
+
end # /context with no default remote
|
41
|
+
|
42
|
+
context 'with an HTTP remote' do
|
43
|
+
before do
|
44
|
+
expect(instance).to receive(:git_shell_out).with(%w{name-rev --name-only HEAD}).and_return('master')
|
45
|
+
expect(instance).to receive(:git_shell_out).with(%w{config --get branch.master.remote}).and_return('')
|
46
|
+
expect(instance).to receive(:git_shell_out).with(%w{ls-remote --get-url origin}).and_return('https://github.com/poise/example.git')
|
47
|
+
end
|
48
|
+
it { is_expected.to eq 'poise/example' }
|
49
|
+
end # /context with an HTTP remote
|
50
|
+
end # /describe #detect_github
|
51
|
+
|
52
|
+
describe 'integration' do
|
53
|
+
rakefile "require 'poise_boiler/rakefile'"
|
54
|
+
rake_task 'badges'
|
55
|
+
before do
|
56
|
+
command(%w{git init})
|
57
|
+
command(%w{git remote add origin git@github.com:poise/example.git})
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'non-cookbook' do
|
61
|
+
file 'example.gemspec', <<-EOH
|
62
|
+
Gem::Specification.new do |s|
|
63
|
+
s.name = 'example'
|
64
|
+
s.version = '1.0.0'
|
65
|
+
end
|
66
|
+
EOH
|
67
|
+
its(:stdout) { is_expected.to eq <<-EOH }
|
68
|
+
[](https://travis-ci.org/poise/example)
|
69
|
+
[](https://rubygems.org/gems/example)
|
70
|
+
[](https://codeclimate.com/github/poise/example)
|
71
|
+
[](https://codecov.io/github/poise/example)
|
72
|
+
[](https://gemnasium.com/poise/example)
|
73
|
+
[](https://www.apache.org/licenses/LICENSE-2.0)
|
74
|
+
EOH
|
75
|
+
its(:stderr) { is_expected.to eq '' }
|
76
|
+
its(:exitstatus) { is_expected.to eq 0 }
|
77
|
+
end # /context non-cookbook
|
78
|
+
|
79
|
+
context 'cookbook' do
|
80
|
+
file 'example.gemspec', <<-EOH
|
81
|
+
Gem::Specification.new do |s|
|
82
|
+
s.name = 'example'
|
83
|
+
s.version = '1.0.0'
|
84
|
+
s.add_dependency 'halite'
|
85
|
+
end
|
86
|
+
EOH
|
87
|
+
its(:stdout) { is_expected.to eq <<-EOH }
|
88
|
+
[](https://travis-ci.org/poise/example)
|
89
|
+
[](https://rubygems.org/gems/example)
|
90
|
+
[](https://supermarket.chef.io/cookbooks/example)
|
91
|
+
[](https://codeclimate.com/github/poise/example)
|
92
|
+
[](https://codecov.io/github/poise/example)
|
93
|
+
[](https://gemnasium.com/poise/example)
|
94
|
+
[](https://www.apache.org/licenses/LICENSE-2.0)
|
95
|
+
EOH
|
96
|
+
its(:stderr) { is_expected.to eq '' }
|
97
|
+
its(:exitstatus) { is_expected.to eq 0 }
|
98
|
+
end # /context cookbook
|
99
|
+
end # /describe integration
|
100
|
+
end
|
@@ -0,0 +1,50 @@
|
|
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 PoiseBoiler::Helpers::Rake::Travis do
|
20
|
+
rakefile "require 'poise_boiler/rakefile'"
|
21
|
+
rake_task 'travis'
|
22
|
+
file 'example.gemspec', <<-EOH
|
23
|
+
Gem::Specification.new do |s|
|
24
|
+
s.name = 'example'
|
25
|
+
s.version = '1.0.0'
|
26
|
+
end
|
27
|
+
EOH
|
28
|
+
file '.kitchen.yml', <<-EOH
|
29
|
+
suites: []
|
30
|
+
EOH
|
31
|
+
file 'README.md'
|
32
|
+
|
33
|
+
context 'no secure vars' do
|
34
|
+
environment TRAVIS_SECURE_ENV_VARS: nil
|
35
|
+
|
36
|
+
its(:stdout) { is_expected.to include 'Running task spec' }
|
37
|
+
its(:stdout) { is_expected.to include 'Running task chef:foodcritic' }
|
38
|
+
its(:stdout) { is_expected.to_not include 'Running task travis:integration' }
|
39
|
+
its(:exitstatus) { is_expected.to eq 0 }
|
40
|
+
end # /context no secure vars
|
41
|
+
|
42
|
+
context 'secure vars' do
|
43
|
+
environment TRAVIS_SECURE_ENV_VARS: '1'
|
44
|
+
|
45
|
+
its(:stdout) { is_expected.to include 'Running task spec' }
|
46
|
+
its(:stdout) { is_expected.to include 'Running task chef:foodcritic' }
|
47
|
+
its(:stdout) { is_expected.to include 'Running task travis:integration' }
|
48
|
+
its(:exitstatus) { is_expected.to eq 0 }
|
49
|
+
end # /context secure vars
|
50
|
+
end
|
@@ -0,0 +1,92 @@
|
|
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
|
+
require 'chef/version'
|
19
|
+
|
20
|
+
describe 'poise_boiler/kitchen' do
|
21
|
+
environment SPEC_BLOCK_CI: true
|
22
|
+
file '.kitchen.yml', <<-EOH
|
23
|
+
---
|
24
|
+
#<% require 'poise_boiler' %>
|
25
|
+
<%= PoiseBoiler.kitchen %>
|
26
|
+
|
27
|
+
suites:
|
28
|
+
- name: default
|
29
|
+
EOH
|
30
|
+
|
31
|
+
context 'with defaults' do
|
32
|
+
context 'kitchen list' do
|
33
|
+
command 'kitchen list'
|
34
|
+
its(:stdout) { is_expected.to match(/default-ubuntu-1404\s+(Vagrant|Dummy)\s+ChefSolo\s+(Busser\s+Ssh\s+)?<Not Created>/) }
|
35
|
+
end # /context kitchen list
|
36
|
+
|
37
|
+
context 'kitchen diagnose' do
|
38
|
+
command 'kitchen diagnose'
|
39
|
+
its(:stdout) { is_expected.to match(%r{- curl -L https://chef.io/chef/install.sh | bash -s --$}) }
|
40
|
+
its(:stdout) { is_expected.to include('/opt/chef/embedded/bin/gem install thor busser busser-serverspec serverspec') }
|
41
|
+
its(:stdout) { is_expected.to include('require_chef_omnibus: true') }
|
42
|
+
end # /context kitchen diagnose
|
43
|
+
end # /context with defaults
|
44
|
+
|
45
|
+
context 'with a platform alias' do
|
46
|
+
file '.kitchen.yml', <<-EOH
|
47
|
+
---
|
48
|
+
#<% require 'poise_boiler' %>
|
49
|
+
<%= PoiseBoiler.kitchen(platforms: 'linux') %>
|
50
|
+
|
51
|
+
suites:
|
52
|
+
- name: default
|
53
|
+
EOH
|
54
|
+
command 'kitchen list'
|
55
|
+
its(:stdout) { is_expected.to match(/default-ubuntu-1404\s+(Vagrant|Dummy)\s+ChefSolo\s+(Busser\s+Ssh\s+)?<Not Created>/) }
|
56
|
+
its(:stdout) { is_expected.to match(/default-ubuntu-1204\s+(Vagrant|Dummy)\s+ChefSolo\s+(Busser\s+Ssh\s+)?<Not Created>/) }
|
57
|
+
its(:stdout) { is_expected.to match(/default-centos-6\s+(Vagrant|Dummy)\s+ChefSolo\s+(Busser\s+Ssh\s+)?<Not Created>/) }
|
58
|
+
its(:stdout) { is_expected.to match(/default-centos-7\s+(Vagrant|Dummy)\s+ChefSolo\s+(Busser\s+Ssh\s+)?<Not Created>/) }
|
59
|
+
end # /context with a platform alias
|
60
|
+
|
61
|
+
context 'with $CHEF_VERSION set' do
|
62
|
+
command 'kitchen diagnose'
|
63
|
+
environment CHEF_VERSION: 12
|
64
|
+
its(:stdout) { is_expected.to match(%r{- curl -L https://chef.io/chef/install.sh | bash -s -- -v 12$}) }
|
65
|
+
its(:stdout) { is_expected.to include("require_chef_omnibus: '12'") }
|
66
|
+
end # /context with $CHEF_VERSION set
|
67
|
+
|
68
|
+
context 'with $CI set' do
|
69
|
+
command 'kitchen diagnose'
|
70
|
+
environment CI: true, SPEC_BLOCK_CI: false
|
71
|
+
its(:stdout) { is_expected.to match(%r{- curl -L https://chef.io/chef/install.sh | bash -s -- -v #{Chef::VERSION}$}) }
|
72
|
+
its(:stdout) { is_expected.to include("require_chef_omnibus: #{Chef::VERSION}") }
|
73
|
+
end # /context with $CI set
|
74
|
+
|
75
|
+
context 'with a platform override' do
|
76
|
+
file '.kitchen.yml', <<-EOH
|
77
|
+
---
|
78
|
+
#<% require 'poise_boiler' %>
|
79
|
+
<%= PoiseBoiler.kitchen %>
|
80
|
+
|
81
|
+
platforms:
|
82
|
+
- name: gentoo
|
83
|
+
- name: arch
|
84
|
+
|
85
|
+
suites:
|
86
|
+
- name: default
|
87
|
+
EOH
|
88
|
+
command 'kitchen list'
|
89
|
+
its(:stdout) { is_expected.to match(/default-gentoo\s+(Vagrant|Dummy)\s+ChefSolo\s+(Busser\s+Ssh\s+)?<Not Created>/) }
|
90
|
+
its(:stdout) { is_expected.to match(/default-arch\s+(Vagrant|Dummy)\s+ChefSolo\s+(Busser\s+Ssh\s+)?<Not Created>/) }
|
91
|
+
end # /context with a platform override
|
92
|
+
end
|