halite 1.0.0.rc.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +20 -0
- data/.travis.yml +14 -4
- data/.yardopts +7 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +30 -8
- data/LICENSE +202 -202
- data/README.md +104 -2
- data/Rakefile +25 -5
- data/gemfiles/default.gemfile +17 -0
- data/gemfiles/master.gemfile +21 -0
- data/halite.gemspec +21 -10
- data/lib/berkshelf/halite.rb +25 -0
- data/lib/berkshelf/locations/gem.rb +84 -0
- data/lib/halite.rb +34 -4
- data/lib/halite/berkshelf/helper.rb +8 -2
- data/lib/halite/berkshelf/source.rb +9 -1
- data/lib/halite/converter.rb +34 -10
- data/lib/halite/converter/chef.rb +43 -0
- data/lib/halite/converter/libraries.rb +93 -26
- data/lib/halite/converter/metadata.rb +48 -10
- data/lib/halite/converter/misc.rb +43 -0
- data/lib/halite/dependencies.rb +48 -8
- data/lib/halite/error.rb +20 -0
- data/lib/halite/gem.rb +106 -21
- data/lib/halite/helper_base.rb +129 -0
- data/lib/halite/rake_helper.rb +46 -60
- data/lib/halite/rake_tasks.rb +17 -1
- data/lib/halite/spec_helper.rb +403 -54
- data/lib/halite/spec_helper/patcher.rb +130 -0
- data/lib/halite/spec_helper/runner.rb +57 -9
- data/lib/halite/version.rb +19 -1
- data/spec/converter/chef_spec.rb +54 -0
- data/spec/converter/libraries_spec.rb +131 -123
- data/spec/converter/metadata_spec.rb +61 -8
- data/spec/converter/misc_spec.rb +61 -0
- data/spec/converter_spec.rb +21 -6
- data/spec/dependencies_spec.rb +64 -10
- data/spec/example_resources/poise.rb +42 -0
- data/spec/example_resources/simple.rb +48 -0
- data/spec/{data/gems/test1/lib → fixtures/cookbooks/test1/files/halite_gem}/test1.rb +0 -0
- data/spec/{data/gems/test1/lib → fixtures/cookbooks/test1/files/halite_gem}/test1/version.rb +0 -0
- data/spec/fixtures/cookbooks/test1/libraries/default.rb +4 -0
- data/spec/{data/integration_cookbooks → fixtures/cookbooks}/test1/metadata.rb +0 -0
- data/spec/{data/gems/test2/chef → fixtures/cookbooks/test2}/attributes.rb +0 -0
- data/spec/{data/gems/test2/lib → fixtures/cookbooks/test2/files/halite_gem}/test2.rb +0 -0
- data/spec/{data/gems/test2/lib → fixtures/cookbooks/test2/files/halite_gem}/test2/resource.rb +0 -0
- data/spec/{data/gems/test2/lib → fixtures/cookbooks/test2/files/halite_gem}/test2/version.rb +0 -0
- data/spec/fixtures/cookbooks/test2/libraries/default.rb +3 -0
- data/spec/{data/integration_cookbooks → fixtures/cookbooks}/test2/metadata.rb +1 -1
- data/spec/{data/gems/test2/chef → fixtures/cookbooks/test2}/recipes/default.rb +0 -0
- data/spec/{data/gems/test2/chef → fixtures/cookbooks/test2}/templates/default/conf.erb +0 -0
- data/spec/{data/gems/test3/lib → fixtures/cookbooks/test3/files/halite_gem}/test3.rb +0 -0
- data/spec/{data/gems/test3/lib → fixtures/cookbooks/test3/files/halite_gem}/test3/dsl.rb +0 -0
- data/spec/{data/gems/test3/lib → fixtures/cookbooks/test3/files/halite_gem}/test3/version.rb +0 -0
- data/spec/fixtures/cookbooks/test3/libraries/default.rb +4 -0
- data/spec/{data/integration_cookbooks → fixtures/cookbooks}/test3/metadata.rb +0 -0
- data/spec/{data/gems/test3/chef → fixtures/cookbooks/test3}/recipes/default.rb +0 -0
- data/spec/{data → fixtures}/gems/test1/Rakefile +0 -0
- data/spec/fixtures/gems/test1/lib/test1.rb +2 -0
- data/spec/fixtures/gems/test1/lib/test1/version.rb +3 -0
- data/spec/{data → fixtures}/gems/test1/test1.gemspec +0 -0
- data/spec/{data → fixtures}/gems/test2/Rakefile +0 -0
- data/spec/{data/integration_cookbooks/test2 → fixtures/gems/test2/chef}/attributes.rb +0 -0
- data/spec/{data/integration_cookbooks/test2 → fixtures/gems/test2/chef}/recipes/default.rb +0 -0
- data/spec/{data/integration_cookbooks/test2 → fixtures/gems/test2/chef}/templates/default/conf.erb +0 -0
- data/spec/fixtures/gems/test2/lib/test2.rb +4 -0
- data/spec/{data/integration_cookbooks/test2/libraries/test2__resource.rb → fixtures/gems/test2/lib/test2/resource.rb} +1 -2
- data/spec/fixtures/gems/test2/lib/test2/version.rb +3 -0
- data/spec/{data → fixtures}/gems/test2/test2.gemspec +0 -0
- data/spec/{data → fixtures}/gems/test3/Rakefile +0 -0
- data/spec/{data/integration_cookbooks/test3 → fixtures/gems/test3/chef}/recipes/default.rb +0 -0
- data/spec/fixtures/gems/test3/lib/test3.rb +4 -0
- data/spec/{data/integration_cookbooks/test3/libraries/test3__dsl.rb → fixtures/gems/test3/lib/test3/dsl.rb} +1 -2
- data/spec/fixtures/gems/test3/lib/test3/version.rb +3 -0
- data/spec/{data → fixtures}/gems/test3/test3.gemspec +1 -0
- data/spec/gem_spec.rb +41 -31
- data/spec/integration_spec.rb +58 -82
- data/spec/runner_spec.rb +108 -0
- data/spec/spec_helper.rb +19 -26
- data/spec/spec_helper_spec.rb +238 -0
- metadata +124 -151
- data/lib/halite/converter/other.rb +0 -19
- data/lib/halite/converter/readme.rb +0 -20
- data/spec/converter/other_spec.rb +0 -56
- data/spec/converter/readme_spec.rb +0 -55
- data/spec/data/integration_cookbooks/test1/libraries/test1.rb +0 -3
- data/spec/data/integration_cookbooks/test1/libraries/test1__version.rb +0 -4
- data/spec/data/integration_cookbooks/test2/libraries/test2.rb +0 -5
- data/spec/data/integration_cookbooks/test2/libraries/test2__version.rb +0 -4
- data/spec/data/integration_cookbooks/test3/libraries/test3.rb +0 -5
- data/spec/data/integration_cookbooks/test3/libraries/test3__version.rb +0 -4
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/{data/gems/test3/lib → fixtures/cookbooks/test3/files/halite_gem}/test3/version.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/{data/integration_cookbooks/test2 → fixtures/gems/test2/chef}/templates/default/conf.erb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = %q||
|
13
13
|
spec.homepage = ''
|
14
14
|
spec.license = 'Apache 2.0'
|
15
|
+
spec.metadata['halite_entry_point'] = 'test3/dsl'
|
15
16
|
|
16
17
|
spec.files = `cd #{File.expand_path('..', __FILE__)} && git ls-files`.split($/)
|
17
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
data/spec/gem_spec.rb
CHANGED
@@ -1,3 +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
|
+
|
1
17
|
require 'spec_helper'
|
2
18
|
require 'halite/gem'
|
3
19
|
require 'halite/version'
|
@@ -10,22 +26,20 @@ describe Halite::Gem do
|
|
10
26
|
context 'when loading halite' do
|
11
27
|
its(:name) { is_expected.to eq 'halite' }
|
12
28
|
its(:version) { is_expected.to eq Halite::VERSION }
|
13
|
-
its(:
|
14
|
-
its(:files) { is_expected.to include 'halite.gemspec' }
|
15
|
-
its(:files) { is_expected.to include 'lib/halite/gem.rb' }
|
29
|
+
its(:spec) { is_expected.to be_a Gem::Specification }
|
16
30
|
end
|
17
31
|
|
18
32
|
context 'when loading halite with a version' do
|
19
33
|
let(:gem_version) { Halite::VERSION }
|
20
34
|
its(:name) { is_expected.to eq 'halite' }
|
21
35
|
its(:version) { is_expected.to eq Halite::VERSION }
|
22
|
-
its(:
|
36
|
+
its(:spec) { is_expected.to be_a Gem::Specification }
|
23
37
|
end
|
24
38
|
|
25
39
|
context 'when loading rspec' do
|
26
40
|
let(:gem_name) { 'rspec' }
|
27
41
|
its(:name) { is_expected.to eq 'rspec' }
|
28
|
-
its(:
|
42
|
+
its(:spec) { is_expected.to be_a Gem::Specification }
|
29
43
|
its(:is_halite_cookbook?) { is_expected.to be_falsey }
|
30
44
|
end
|
31
45
|
|
@@ -34,12 +48,10 @@ describe Halite::Gem do
|
|
34
48
|
its(:name) { is_expected.to eq 'test1' }
|
35
49
|
its(:version) { is_expected.to eq '1.2.3' }
|
36
50
|
its(:cookbook_name) { is_expected.to eq 'test1' }
|
37
|
-
its(:files) { is_expected.to include 'test1.gemspec' }
|
38
|
-
its(:files) { is_expected.to include 'lib/test1.rb' }
|
39
51
|
its(:license_header) { is_expected.to eq "# coding: utf-8\n# Awesome license\n" }
|
40
52
|
its(:each_library_file) { is_expected.to eq [
|
41
|
-
[File.expand_path('../
|
42
|
-
[File.expand_path('../
|
53
|
+
[File.expand_path('../fixtures/gems/test1/lib/test1.rb', __FILE__), 'test1.rb'],
|
54
|
+
[File.expand_path('../fixtures/gems/test1/lib/test1/version.rb', __FILE__), 'test1/version.rb'],
|
43
55
|
] }
|
44
56
|
its(:cookbook_dependencies) { is_expected.to eq [] }
|
45
57
|
its(:is_halite_cookbook?) { is_expected.to be_truthy }
|
@@ -48,10 +60,10 @@ describe Halite::Gem do
|
|
48
60
|
context 'with no prefixes' do
|
49
61
|
it 'returns all files' do
|
50
62
|
expect(subject.each_file).to eq [
|
51
|
-
[File.expand_path('../
|
52
|
-
[File.expand_path('../
|
53
|
-
[File.expand_path('../
|
54
|
-
[File.expand_path('../
|
63
|
+
[File.expand_path('../fixtures/gems/test1/Rakefile', __FILE__), 'Rakefile'],
|
64
|
+
[File.expand_path('../fixtures/gems/test1/lib/test1.rb', __FILE__), 'lib/test1.rb'],
|
65
|
+
[File.expand_path('../fixtures/gems/test1/lib/test1/version.rb', __FILE__), 'lib/test1/version.rb'],
|
66
|
+
[File.expand_path('../fixtures/gems/test1/test1.gemspec', __FILE__), 'test1.gemspec'],
|
55
67
|
]
|
56
68
|
end
|
57
69
|
end
|
@@ -59,7 +71,7 @@ describe Halite::Gem do
|
|
59
71
|
context 'with a prefix that overlaps a filename' do
|
60
72
|
it 'returns only files in that folder' do
|
61
73
|
expect(subject.each_file('lib/test1')).to eq [
|
62
|
-
[File.expand_path('../
|
74
|
+
[File.expand_path('../fixtures/gems/test1/lib/test1/version.rb', __FILE__), 'version.rb'],
|
63
75
|
]
|
64
76
|
end
|
65
77
|
end
|
@@ -71,29 +83,27 @@ describe Halite::Gem do
|
|
71
83
|
its(:name) { is_expected.to eq 'test2' }
|
72
84
|
its(:version) { is_expected.to eq '4.5.6' }
|
73
85
|
its(:cookbook_name) { is_expected.to eq 'test2' }
|
74
|
-
its(:files) { is_expected.to include 'test2.gemspec' }
|
75
|
-
its(:files) { is_expected.to include 'lib/test2.rb' }
|
76
86
|
its(:license_header) { is_expected.to eq "# coding: utf-8\n" }
|
77
87
|
its(:each_library_file) { is_expected.to eq [
|
78
|
-
[File.expand_path('../
|
79
|
-
[File.expand_path('../
|
80
|
-
[File.expand_path('../
|
88
|
+
[File.expand_path('../fixtures/gems/test2/lib/test2.rb', __FILE__), 'test2.rb'],
|
89
|
+
[File.expand_path('../fixtures/gems/test2/lib/test2/resource.rb', __FILE__), 'test2/resource.rb'],
|
90
|
+
[File.expand_path('../fixtures/gems/test2/lib/test2/version.rb', __FILE__), 'test2/version.rb'],
|
81
91
|
] }
|
82
|
-
its(:cookbook_dependencies) { is_expected.to eq [Halite::Dependencies::Dependency.new('testdep', '>= 0
|
92
|
+
its(:cookbook_dependencies) { is_expected.to eq [Halite::Dependencies::Dependency.new('testdep', '>= 0', :requirements)] }
|
83
93
|
its(:is_halite_cookbook?) { is_expected.to be_truthy }
|
84
94
|
|
85
95
|
describe '#each_file' do
|
86
96
|
context 'with no prefixes' do
|
87
97
|
it 'returns all files' do
|
88
98
|
expect(subject.each_file).to eq [
|
89
|
-
[File.expand_path('../
|
90
|
-
[File.expand_path('../
|
91
|
-
[File.expand_path('../
|
92
|
-
[File.expand_path('../
|
93
|
-
[File.expand_path('../
|
94
|
-
[File.expand_path('../
|
95
|
-
[File.expand_path('../
|
96
|
-
[File.expand_path('../
|
99
|
+
[File.expand_path('../fixtures/gems/test2/Rakefile', __FILE__), 'Rakefile'],
|
100
|
+
[File.expand_path('../fixtures/gems/test2/chef/attributes.rb', __FILE__), 'chef/attributes.rb'],
|
101
|
+
[File.expand_path('../fixtures/gems/test2/chef/recipes/default.rb', __FILE__), 'chef/recipes/default.rb'],
|
102
|
+
[File.expand_path('../fixtures/gems/test2/chef/templates/default/conf.erb', __FILE__), 'chef/templates/default/conf.erb'],
|
103
|
+
[File.expand_path('../fixtures/gems/test2/lib/test2.rb', __FILE__), 'lib/test2.rb'],
|
104
|
+
[File.expand_path('../fixtures/gems/test2/lib/test2/resource.rb', __FILE__), 'lib/test2/resource.rb'],
|
105
|
+
[File.expand_path('../fixtures/gems/test2/lib/test2/version.rb', __FILE__), 'lib/test2/version.rb'],
|
106
|
+
[File.expand_path('../fixtures/gems/test2/test2.gemspec', __FILE__), 'test2.gemspec'],
|
97
107
|
]
|
98
108
|
end
|
99
109
|
end
|
@@ -101,9 +111,9 @@ describe Halite::Gem do
|
|
101
111
|
context 'with a prefix of chef' do
|
102
112
|
it 'returns only files in that folder' do
|
103
113
|
expect(subject.each_file('chef')).to eq [
|
104
|
-
[File.expand_path('../
|
105
|
-
[File.expand_path('../
|
106
|
-
[File.expand_path('../
|
114
|
+
[File.expand_path('../fixtures/gems/test2/chef/attributes.rb', __FILE__), 'attributes.rb'],
|
115
|
+
[File.expand_path('../fixtures/gems/test2/chef/recipes/default.rb', __FILE__), 'recipes/default.rb'],
|
116
|
+
[File.expand_path('../fixtures/gems/test2/chef/templates/default/conf.erb', __FILE__), 'templates/default/conf.erb'],
|
107
117
|
]
|
108
118
|
end
|
109
119
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -1,104 +1,80 @@
|
|
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
|
+
|
1
17
|
require 'spec_helper'
|
2
|
-
require '
|
3
|
-
require 'mixlib/shellout'
|
4
|
-
require 'halite/converter'
|
18
|
+
require 'rspec-command'
|
5
19
|
|
6
20
|
describe 'integration tests' do
|
7
|
-
|
8
|
-
|
9
|
-
example.metadata[:halite_temp_path] = path
|
10
|
-
example.run
|
11
|
-
end
|
12
|
-
end
|
13
|
-
let(:temp_path) do |example|
|
14
|
-
example.metadata[:halite_temp_path]
|
15
|
-
end
|
16
|
-
let(:gem_name) { '' }
|
17
|
-
let(:stub_cookbooks) { [] }
|
21
|
+
include RSpecCommand
|
22
|
+
include RSpecCommand::Rake
|
18
23
|
let(:extra_gems) { [] }
|
19
24
|
let(:recipes) { [] }
|
20
|
-
let(:
|
21
|
-
let(:expect_output) { nil }
|
22
|
-
|
23
|
-
shared_examples 'an integration test' do
|
24
|
-
def directories_match(temp_path, fixture_path)
|
25
|
-
temp_files = Dir[File.join(temp_path, '**', '*')].sort
|
26
|
-
fixture_files = Dir[File.join(fixture_path, '**', '*')].sort
|
27
|
-
expect(temp_files.map {|path| path[temp_path.length..-1] }).to eq fixture_files.map {|path| path[fixture_path.length..-1] }
|
28
|
-
temp_files.zip(fixture_files).each do |temp_file, fixture_file|
|
29
|
-
next unless File.file?(temp_file)
|
30
|
-
expect(IO.read(temp_file)).to eq IO.read(fixture_file)
|
31
|
-
end
|
32
|
-
end
|
25
|
+
let(:expect_output) { }
|
33
26
|
|
34
|
-
|
35
|
-
|
36
|
-
Halite.convert(gem_name, temp_path)
|
37
|
-
|
38
|
-
|
39
|
-
end
|
27
|
+
shared_examples 'an integration test' do |gem_name, version, stub_cookbooks=[]|
|
28
|
+
describe 'Halite.convert' do
|
29
|
+
subject { Halite.convert(gem_name, temp_path) }
|
30
|
+
it { is_expected.to match_fixture("cookbooks/#{gem_name}") }
|
31
|
+
end # /describe Halite.convert
|
40
32
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
# Write out a
|
46
|
-
runner_path = File.join(temp_path, 'runner')
|
47
|
-
Dir.mkdir(runner_path)
|
48
|
-
IO.write(File.join(runner_path, 'metadata.rb'), "name 'runner'\ndepends '#{gem_name}'")
|
49
|
-
Dir.mkdir(File.join(runner_path, 'recipes'))
|
50
|
-
IO.write(File.join(runner_path, 'recipes', 'default.rb'), '')
|
51
|
-
# Write out a stub cookbooks for dependency testing
|
33
|
+
describe 'run it with chef-solo', slow: true do
|
34
|
+
file('solo.rb') { "cookbook_path '#{temp_path}'" }
|
35
|
+
file 'runner/metadata.rb', "name 'runner'\ndepends '#{gem_name}'"
|
36
|
+
file 'runner/recipes/default.rb', ''
|
37
|
+
# Write out a stub cookbooks for dependency testing.
|
52
38
|
stub_cookbooks.each do |(stub_name, stub_version)|
|
53
|
-
|
54
|
-
Dir.mkdir(stub_path)
|
55
|
-
IO.write(File.join(stub_path, 'metadata.rb'), "name '#{stub_name}'\nversion '#{stub_version}'")
|
39
|
+
file "#{stub_name}/metadata.rb", "name '#{stub_name}'\nversion '#{stub_version}'"
|
56
40
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
41
|
+
before do
|
42
|
+
([gem_name] + extra_gems).each do |name|
|
43
|
+
cookbook_path = File.join(temp_path, name)
|
44
|
+
Dir.mkdir(cookbook_path)
|
45
|
+
Halite.convert(name, cookbook_path)
|
46
|
+
end
|
62
47
|
end
|
63
|
-
#
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
48
|
+
command { "chef-solo -l debug -c solo.rb -o #{(['runner']+recipes).map{|r| "recipe[#{r}]"}.join(',')}" }
|
49
|
+
|
50
|
+
it do
|
51
|
+
# Force the command to run at least once.
|
52
|
+
subject
|
53
|
+
Array(expect_output).each do |output|
|
54
|
+
expect(subject.stdout).to include(output), "'#{output}' not found in the output of #{subject.command}:\n#{subject.stdout}"
|
55
|
+
end
|
69
56
|
end
|
70
|
-
end
|
57
|
+
end # /describe run it with chef-solo
|
71
58
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
expect(cmd.error?).to be_falsey, "Running #{cmd.command} failed (#{cmd.exitstatus} #{cmd.error?}):\n#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}"
|
79
|
-
# Check that conversion matches the fixture
|
80
|
-
directories_match(Dir[File.join(temp_path, 'pkg', '*')].first, fixture_path)
|
81
|
-
end
|
82
|
-
end
|
59
|
+
describe 'run rake chef:build' do
|
60
|
+
fixture_file "gems/#{gem_name}"
|
61
|
+
rake_task 'chef:build'
|
62
|
+
it { is_expected.to match_fixture("cookbooks/#{gem_name}", "pkg/#{gem_name}-#{version}") }
|
63
|
+
end # /describe run rake chef:build
|
64
|
+
end # /shared_examples an integration test
|
83
65
|
|
84
66
|
context 'with test1 gem', integration: true do
|
85
|
-
|
86
|
-
|
87
|
-
end
|
67
|
+
it_should_behave_like 'an integration test', 'test1', '1.2.3'
|
68
|
+
end # /context with test1 gem
|
88
69
|
|
89
70
|
context 'with test2 gem', integration: true do
|
90
|
-
|
91
|
-
|
92
|
-
it_should_behave_like 'an integration test'
|
93
|
-
end
|
71
|
+
it_should_behave_like 'an integration test', 'test2', '4.5.6', [['testdep', '1.0.0']]
|
72
|
+
end # /context with test2 gem
|
94
73
|
|
95
74
|
context 'with test3 gem', integration: true do
|
96
|
-
let(:gem_name) { 'test3' }
|
97
75
|
let(:extra_gems) { ['test2'] }
|
98
|
-
let(:stub_cookbooks) { [['testdep', '1.0.0']] }
|
99
76
|
let(:recipes) { ['test3'] }
|
100
77
|
let(:expect_output) { '!!!!!!!!!!test34.5.6' }
|
101
|
-
it_should_behave_like 'an integration test'
|
102
|
-
end
|
103
|
-
|
78
|
+
it_should_behave_like 'an integration test', 'test3', '7.8.9', [['testdep', '1.0.0']]
|
79
|
+
end # /context with test3 gem
|
104
80
|
end
|
data/spec/runner_spec.rb
ADDED
@@ -0,0 +1,108 @@
|
|
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 file is not named spec/spec_helper/runner_spec.rb because that seems confusing.
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
|
21
|
+
require 'halite/spec_helper/runner'
|
22
|
+
|
23
|
+
describe Halite::SpecHelper::Runner do
|
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
|
57
|
+
|
58
|
+
describe '#initialize' do
|
59
|
+
|
60
|
+
context 'with a simple option' do
|
61
|
+
let(:options) { {dry_run: true} }
|
62
|
+
its(:dry_run?) { is_expected.to be_truthy }
|
63
|
+
end # /context with a simple option
|
64
|
+
|
65
|
+
context 'with default_attributes' do
|
66
|
+
let(:options) { {default_attributes: {halite: 'test'}} }
|
67
|
+
it { expect(subject.node.default['halite']).to eq('test') }
|
68
|
+
it { expect(subject.node['halite']).to eq('test') }
|
69
|
+
end # /context with default_attributes
|
70
|
+
|
71
|
+
context 'with normal_attributes' do
|
72
|
+
let(:options) { {normal_attributes: {halite: 'test'}} }
|
73
|
+
it { expect(subject.node.normal['halite']).to eq('test') }
|
74
|
+
it { expect(subject.node['halite']).to eq('test') }
|
75
|
+
end # /context with normal_attributes
|
76
|
+
|
77
|
+
context 'with override_attributes' do
|
78
|
+
let(:options) { {override_attributes: {halite: 'test'}} }
|
79
|
+
it { expect(subject.node.override['halite']).to eq('test') }
|
80
|
+
it { expect(subject.node['halite']).to eq('test') }
|
81
|
+
end # /context with override_attributes
|
82
|
+
end # /describe #initialize
|
83
|
+
|
84
|
+
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
|
92
|
+
|
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
|
107
|
+
end # /describe #converge
|
108
|
+
end
|