minitest-chef-handler 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/History.txt +6 -0
- data/README.md +18 -0
- data/Rakefile +0 -9
- data/examples/simple-solo/solo.rb +3 -0
- data/gemfile_chef_10 +3 -0
- data/gemfile_chef_11 +4 -0
- data/lib/minitest-chef-handler.rb +5 -5
- data/lib/minitest-chef-handler/lookup.rb +2 -1
- data/minitest-chef-handler.gemspec +1 -1
- data/script/bootstrap +11 -0
- data/script/test +28 -0
- data/spec/minitest-chef-handler/lookup_spec.rb +5 -3
- metadata +6 -9
- data/Gemfile +0 -4
data/.gitignore
CHANGED
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -154,6 +154,24 @@ and be treated like any other error in the Chef execution.
|
|
154
154
|
|
155
155
|
The instructions above have described how to use it in a Chef solo installation. If you want to distribute the handler to your Chef server check either the chef_handler cookbooks in the examples or [minitest-handler-cookbook](https://github.com/btm/minitest-handler-cookbook).
|
156
156
|
|
157
|
+
## Development
|
158
|
+
|
159
|
+
Minitest-chef-handler should work with versions 10.x and versions 11.x of Chef.
|
160
|
+
|
161
|
+
There are just two commands that you need to know to hack on this library.
|
162
|
+
|
163
|
+
1. Load both versions of Chef dependencies:
|
164
|
+
|
165
|
+
```
|
166
|
+
$ script/bootstrap
|
167
|
+
```
|
168
|
+
|
169
|
+
2. Run unit and integration tests agains both versions of Chef:
|
170
|
+
|
171
|
+
```
|
172
|
+
$ script/test
|
173
|
+
```
|
174
|
+
|
157
175
|
## Copyright
|
158
176
|
|
159
177
|
Copyright (c) 2012 David Calavera. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -2,16 +2,7 @@
|
|
2
2
|
require "bundler/gem_tasks"
|
3
3
|
require "rake/testtask"
|
4
4
|
|
5
|
-
desc 'Verify that nothing is broken against the simple solo example'
|
6
|
-
task :test do
|
7
|
-
Dir.chdir('./examples/simple-solo') do
|
8
|
-
sh 'ruby -I../../lib -S chef-solo -c solo.rb -j dna.json'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
5
|
Rake::TestTask.new do |t|
|
13
6
|
t.name = 'spec'
|
14
7
|
t.pattern = 'spec/**/*_spec.rb'
|
15
8
|
end
|
16
|
-
|
17
|
-
task :default => [:spec, :test]
|
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'minitest-chef-handler'
|
2
2
|
|
3
3
|
path = File.expand_path('{test/test_*,spec/*_spec}.rb', File.dirname(__FILE__))
|
4
|
+
cache = File.expand_path('cache', File.dirname(__FILE__))
|
4
5
|
|
5
6
|
report_handlers << MiniTest::Chef::Handler.new(:path => path)
|
6
7
|
cookbook_path File.expand_path('cookbooks', File.dirname(__FILE__))
|
7
8
|
log_location 'chef.log'
|
9
|
+
cache_options({ :path => cache, :skip_expires => true })
|
10
|
+
file_cache_path cache
|
data/gemfile_chef_10
ADDED
data/gemfile_chef_11
ADDED
@@ -28,20 +28,20 @@ module MiniTest
|
|
28
28
|
|
29
29
|
MiniTest::Unit.output = ::Chef::Log
|
30
30
|
|
31
|
-
if @options[:ci_reports]
|
31
|
+
runner = if @options[:ci_reports]
|
32
32
|
ENV['CI_REPORTS'] = @options[:ci_reports]
|
33
|
-
|
33
|
+
CIRunner.new(run_status)
|
34
34
|
else
|
35
|
-
|
35
|
+
Runner.new(run_status)
|
36
36
|
end
|
37
37
|
|
38
|
-
if custom_runner?
|
38
|
+
result = if custom_runner?
|
39
39
|
runner._run(miniunit_options)
|
40
40
|
else
|
41
41
|
runner.run(miniunit_options)
|
42
42
|
end
|
43
43
|
|
44
|
-
if
|
44
|
+
if result.nonzero?
|
45
45
|
::Chef::Client.when_run_completes_successfully do |run_status|
|
46
46
|
error_msg = "MiniTest failed with #{runner.failures} failure(s) and #{runner.errors} error(s).\n"
|
47
47
|
error_msg << runner.report.sort.join("\n")
|
@@ -60,7 +60,8 @@ module MiniTest
|
|
60
60
|
if recipes = run_status.node.run_state[:seen_recipes]
|
61
61
|
recipes.keys
|
62
62
|
else
|
63
|
-
|
63
|
+
# chef 11 - see http://docs.opscode.com/breaking_changes_chef_11.html#node-run-state-replaced
|
64
|
+
run_status.run_context.loaded_recipes
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
12
|
gem.name = "minitest-chef-handler"
|
13
13
|
gem.require_paths = ["lib"]
|
14
|
-
gem.version = '0.6.
|
14
|
+
gem.version = '0.6.8'
|
15
15
|
|
16
16
|
gem.add_dependency('minitest')
|
17
17
|
gem.add_dependency('chef')
|
data/script/bootstrap
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
puts "-> Configuring Bundler with Chef 10 dependency."
|
4
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../gemfile_chef_10', __FILE__)
|
5
|
+
|
6
|
+
system "bundle", "install"
|
7
|
+
|
8
|
+
puts "-> Configuring Bundler with Chef 11 dependency."
|
9
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../gemfile_chef_11', __FILE__)
|
10
|
+
|
11
|
+
system "bundle", "install"
|
data/script/test
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
|
5
|
+
def test_all
|
6
|
+
Bundler.setup(:default)
|
7
|
+
|
8
|
+
system "bundle exec rake spec"
|
9
|
+
|
10
|
+
Dir.chdir('examples/simple-solo') do
|
11
|
+
system "bundle exec ruby -I#{File.expand_path('lib', ROOT)} -S chef-solo -c solo.rb -j dna.json"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
puts '-> Testing with Chef 10'
|
16
|
+
|
17
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('gemfile_chef_10', ROOT)
|
18
|
+
|
19
|
+
require "rubygems"
|
20
|
+
require "bundler/setup"
|
21
|
+
|
22
|
+
test_all
|
23
|
+
|
24
|
+
puts '-> Testing with Chef 11'
|
25
|
+
|
26
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('gemfile_chef_11', ROOT)
|
27
|
+
|
28
|
+
test_all
|
@@ -22,7 +22,8 @@ describe MiniTest::Chef::Lookup do
|
|
22
22
|
|
23
23
|
describe "#used_recipe_names" do
|
24
24
|
before do
|
25
|
-
stubs(:run_status => stub(:node => stub(:run_state => {})
|
25
|
+
stubs(:run_status => stub(:node => stub(:run_state => {}),
|
26
|
+
:run_context => {}))
|
26
27
|
end
|
27
28
|
|
28
29
|
it "uses seen_recipes if run_state is not empty" do
|
@@ -31,8 +32,9 @@ describe MiniTest::Chef::Lookup do
|
|
31
32
|
end
|
32
33
|
|
33
34
|
it "uses run_list if run_state is empty" do
|
34
|
-
|
35
|
-
|
35
|
+
expected = %w(recipe[foo] recipe[bar] role[someone]).map { |i| Chef::RunList::RunListItem.new(i) }
|
36
|
+
run_status.run_context.stubs(:loaded_recipes => expected)
|
37
|
+
used_recipe_names.must_equal expected
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-chef-handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -100,7 +100,6 @@ extensions: []
|
|
100
100
|
extra_rdoc_files: []
|
101
101
|
files:
|
102
102
|
- .gitignore
|
103
|
-
- Gemfile
|
104
103
|
- History.txt
|
105
104
|
- LICENSE
|
106
105
|
- README.md
|
@@ -127,6 +126,8 @@ files:
|
|
127
126
|
- examples/spec_examples/metadata.rb
|
128
127
|
- examples/spec_examples/recipes/default.rb
|
129
128
|
- examples/spec_examples/templates/default/foo.erb
|
129
|
+
- gemfile_chef_10
|
130
|
+
- gemfile_chef_11
|
130
131
|
- lib/minitest-chef-handler.rb
|
131
132
|
- lib/minitest-chef-handler/assertions.rb
|
132
133
|
- lib/minitest-chef-handler/ci_runner.rb
|
@@ -139,6 +140,8 @@ files:
|
|
139
140
|
- lib/minitest-chef-handler/spec.rb
|
140
141
|
- lib/minitest-chef-handler/unit.rb
|
141
142
|
- minitest-chef-handler.gemspec
|
143
|
+
- script/bootstrap
|
144
|
+
- script/test
|
142
145
|
- spec/minitest-chef-handler/assertions_spec.rb
|
143
146
|
- spec/minitest-chef-handler/infections_spec.rb
|
144
147
|
- spec/minitest-chef-handler/lookup_spec.rb
|
@@ -157,18 +160,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
160
|
- - ! '>='
|
158
161
|
- !ruby/object:Gem::Version
|
159
162
|
version: '0'
|
160
|
-
segments:
|
161
|
-
- 0
|
162
|
-
hash: -558242354881873270
|
163
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
164
|
none: false
|
165
165
|
requirements:
|
166
166
|
- - ! '>='
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
|
-
segments:
|
170
|
-
- 0
|
171
|
-
hash: -558242354881873270
|
172
169
|
requirements: []
|
173
170
|
rubyforge_project:
|
174
171
|
rubygems_version: 1.8.23
|
data/Gemfile
DELETED