minitest-chef-handler 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/lib/minitest-chef-handler.rb +5 -53
- data/lib/minitest-chef-handler/lookup.rb +73 -0
- data/minitest-chef-handler.gemspec +1 -1
- metadata +11 -10
data/History.txt
CHANGED
@@ -7,9 +7,13 @@ require 'minitest-chef-handler/runner'
|
|
7
7
|
require 'minitest-chef-handler/assertions'
|
8
8
|
require 'minitest-chef-handler/infections'
|
9
9
|
|
10
|
+
require 'minitest-chef-handler/lookup'
|
11
|
+
|
10
12
|
module MiniTest
|
11
13
|
module Chef
|
12
14
|
class Handler < ::Chef::Handler
|
15
|
+
include Lookup
|
16
|
+
|
13
17
|
def initialize(options = {})
|
14
18
|
@options = options
|
15
19
|
end
|
@@ -18,7 +22,7 @@ module MiniTest
|
|
18
22
|
# do not run tests if chef failed
|
19
23
|
return if failed?
|
20
24
|
|
21
|
-
require_test_suites
|
25
|
+
require_test_suites(@options.delete(:path))
|
22
26
|
runner = Runner.new(run_status)
|
23
27
|
|
24
28
|
if custom_runner?
|
@@ -34,58 +38,6 @@ module MiniTest
|
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
37
|
-
private
|
38
|
-
|
39
|
-
#
|
40
|
-
# Load the test suites.
|
41
|
-
# If the option "path" is specified we use it to load the tests from it.
|
42
|
-
# The option can be a string or an array of paths.
|
43
|
-
# Otherwise we load the tests according to the recipes seen.
|
44
|
-
#
|
45
|
-
def require_test_suites
|
46
|
-
paths = @options.delete(:path) || seen_recipes_paths
|
47
|
-
Array(paths).each do |path|
|
48
|
-
Dir.glob(path).each {|test_suite| require test_suite}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
# Collect test paths based in the recipes ran.
|
54
|
-
# It loads the tests based in the name of the cookbook and the name of the recipe.
|
55
|
-
# The tests must be under the cookbooks directory.
|
56
|
-
#
|
57
|
-
# Examples:
|
58
|
-
#
|
59
|
-
# If the seen recipes includes the recipe "foo" we try to load tests from:
|
60
|
-
#
|
61
|
-
# cookbooks/foo/tests/default_test.rb
|
62
|
-
# cookbooks/foo/tests/default/*_test.rb
|
63
|
-
#
|
64
|
-
# cookbooks/foo/specs/default_spec.rb
|
65
|
-
# cookbooks/foo/specs/default/*_spec.rb
|
66
|
-
#
|
67
|
-
# If the seen recipes includes the recipe "foo::install" we try to load tests from:
|
68
|
-
#
|
69
|
-
# cookbooks/foo/tests/install_test.rb
|
70
|
-
# cookbooks/foo/tests/install/*_test.rb
|
71
|
-
#
|
72
|
-
# cookbooks/foo/specs/install_spec.rb
|
73
|
-
# cookbooks/foo/specs/install/*_spec.rb
|
74
|
-
#
|
75
|
-
def seen_recipes_paths
|
76
|
-
run_status.node.run_state[:seen_recipes].keys.map do |recipe_name|
|
77
|
-
cookbook_name, recipe_short_name = ::Chef::Recipe.parse_recipe_name(recipe_name)
|
78
|
-
base_path = ::Chef::Config[:cookbook_path]
|
79
|
-
|
80
|
-
file_test_pattern = "%s/%s/tests/%s_test.rb" % [base_path, cookbook_name, recipe_short_name]
|
81
|
-
dir_test_pattern = "%s/%s/tests/%s/*_test.rb" % [base_path, cookbook_name, recipe_short_name]
|
82
|
-
file_spec_pattern = "%s/%s/specs/%s_spec.rb" % [base_path, cookbook_name, recipe_short_name]
|
83
|
-
dir_spec_pattern = "%s/%s/specs/%s/*_spec.rb" % [base_path, cookbook_name, recipe_short_name]
|
84
|
-
|
85
|
-
[file_test_pattern, dir_test_pattern, file_spec_pattern, dir_spec_pattern]
|
86
|
-
end.flatten
|
87
|
-
end
|
88
|
-
|
89
41
|
def miniunit_options
|
90
42
|
options = []
|
91
43
|
options << ['-n', @options[:filter]] if @options[:filter]
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module MiniTest
|
2
|
+
module Chef
|
3
|
+
module Lookup
|
4
|
+
|
5
|
+
# Load the test suites.
|
6
|
+
#
|
7
|
+
# If the option "path" is specified we use it to load the tests from it.
|
8
|
+
# The option can be a string or an array of paths.
|
9
|
+
# Otherwise we load the tests according to the recipes seen.
|
10
|
+
#
|
11
|
+
def require_test_suites(options_path)
|
12
|
+
paths = options_path || seen_recipes_paths
|
13
|
+
Array(paths).each do |path|
|
14
|
+
Dir.glob(path).each {|test_suite| require test_suite}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Collect test paths based in the recipes ran.
|
19
|
+
#
|
20
|
+
# It loads the tests based in the name of the cookbook and the name of the recipe.
|
21
|
+
# The tests must be under the cookbooks directory.
|
22
|
+
#
|
23
|
+
# Examples:
|
24
|
+
#
|
25
|
+
# If the seen recipes includes the recipe "foo" we try to load tests from:
|
26
|
+
#
|
27
|
+
# cookbooks/foo/tests/default_test.rb
|
28
|
+
# cookbooks/foo/tests/default/*_test.rb
|
29
|
+
#
|
30
|
+
# cookbooks/foo/specs/default_spec.rb
|
31
|
+
# cookbooks/foo/specs/default/*_spec.rb
|
32
|
+
#
|
33
|
+
# If the seen recipes includes the recipe "foo::install" we try to load tests from:
|
34
|
+
#
|
35
|
+
# cookbooks/foo/tests/install_test.rb
|
36
|
+
# cookbooks/foo/tests/install/*_test.rb
|
37
|
+
#
|
38
|
+
# cookbooks/foo/specs/install_spec.rb
|
39
|
+
# cookbooks/foo/specs/install/*_spec.rb
|
40
|
+
#
|
41
|
+
def seen_recipes_paths
|
42
|
+
run_status.node.run_state[:seen_recipes].keys.map do |recipe_name|
|
43
|
+
cookbook_name, recipe_short_name = ::Chef::Recipe.parse_recipe_name(recipe_name)
|
44
|
+
base_path = ::Chef::Config[:cookbook_path]
|
45
|
+
|
46
|
+
cookbook_paths = lookup_cookbook(base_path, cookbook_name)
|
47
|
+
|
48
|
+
cookbook_paths.map do |path|
|
49
|
+
file_test_pattern = "%s/tests/%s_test.rb" % [path, recipe_short_name]
|
50
|
+
dir_test_pattern = "%s/tests/%s/*_test.rb" % [path, recipe_short_name]
|
51
|
+
file_spec_pattern = "%s/specs/%s_spec.rb" % [path, recipe_short_name]
|
52
|
+
dir_spec_pattern = "%s/specs/%s/*_spec.rb" % [path, recipe_short_name]
|
53
|
+
|
54
|
+
[file_test_pattern, dir_test_pattern, file_spec_pattern, dir_spec_pattern]
|
55
|
+
end.flatten
|
56
|
+
end.flatten
|
57
|
+
end
|
58
|
+
|
59
|
+
# Internal - look for the right path to the cookbook given one or
|
60
|
+
# several base paths.
|
61
|
+
#
|
62
|
+
# Path: String or Array representing the recipes base paths.
|
63
|
+
# Name: Name of the cookbook
|
64
|
+
#
|
65
|
+
# Returns paths founded for the speficied cookbook.
|
66
|
+
def lookup_cookbook(path, name)
|
67
|
+
path_expr = Array(path).join(',')
|
68
|
+
|
69
|
+
Dir.glob("{%s}/$%s" % [path_expr, name])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -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.5.
|
14
|
+
gem.version = '0.5.3'
|
15
15
|
|
16
16
|
gem.add_dependency('minitest')
|
17
17
|
gem.add_dependency('chef')
|
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.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &70309173979160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70309173979160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: chef
|
27
|
-
requirement: &
|
27
|
+
requirement: &70309173978700 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70309173978700
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70309173978280 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70309173978280
|
47
47
|
description: Run Minitest suites as Chef report handlers
|
48
48
|
email:
|
49
49
|
- david.calavera@gmail.com
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/minitest-chef-handler/assertions.rb
|
84
84
|
- lib/minitest-chef-handler/context.rb
|
85
85
|
- lib/minitest-chef-handler/infections.rb
|
86
|
+
- lib/minitest-chef-handler/lookup.rb
|
86
87
|
- lib/minitest-chef-handler/resources.rb
|
87
88
|
- lib/minitest-chef-handler/runner.rb
|
88
89
|
- lib/minitest-chef-handler/spec.rb
|
@@ -106,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
107
|
version: '0'
|
107
108
|
segments:
|
108
109
|
- 0
|
109
|
-
hash:
|
110
|
+
hash: 3961635280245186970
|
110
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
112
|
none: false
|
112
113
|
requirements:
|
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
116
|
version: '0'
|
116
117
|
segments:
|
117
118
|
- 0
|
118
|
-
hash:
|
119
|
+
hash: 3961635280245186970
|
119
120
|
requirements: []
|
120
121
|
rubyforge_project:
|
121
122
|
rubygems_version: 1.8.11
|