chefspec 8.0.0 → 8.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 888dff160c4e09262e47271fc25e19e24dfa5415f9c17566d5fab2c3b07d3f38
4
- data.tar.gz: a79eacde94a5abdad1ab8e4530ed95d46255323927fbfe9706873aa7d6d99545
3
+ metadata.gz: 74bb24c63b0385dccb22c7a83abcd2350429986bd6de6f1444df2d548d8bb72b
4
+ data.tar.gz: a66b22b4e3f705eea2d2d11fc65e9285cb890aa00f76ab826b47b66d37497678
5
5
  SHA512:
6
- metadata.gz: 76b576b0e8fd51f067bda1eaca73ebb3bd5f49f0ce366ac4c59d84942b2d1437cead58afc7fd1b0c96e7051e656342e2b2ac9e1d2d3c183953ed8fefba15b79f
7
- data.tar.gz: f5ba63555cde2fb189c53ceedfffd46491744605ea50f8927f85502c8ba480455a69ba397cdc27d1ace387509e95b8c5442b10b411ea50b3d18aaf075c0a5b3d
6
+ metadata.gz: 77dd4b42946b4bf2129dba71039fee03a5c1cebf8c9b2026ae4c7b31e443dea9a9a579e78d7b36ba89d75562a6eeaf9d1a701052a143cd2cc26914e15f64a4f7
7
+ data.tar.gz: 4471c363638234ee7e5268db4de027b1d0b749c7ae74eaa9343c0a3f35db9b9ce0eb2c97e6b8a8c57efad75fe3b7500c34c7218a040716dfcf8cd1cba60dc6c8
@@ -90,6 +90,26 @@ module ChefSpec
90
90
  @outputs << block
91
91
  end
92
92
 
93
+ #
94
+ # Change the template for reporting of converage analysis.
95
+ #
96
+ # @param [string] path
97
+ # The template file to use for the output of the report
98
+ #
99
+ # @return [true]
100
+ #
101
+ def set_template(file = 'human.erb')
102
+ [
103
+ ChefSpec.root.join('templates', 'coverage', file),
104
+ File.expand_path(file, Dir.pwd)
105
+ ].each do |temp|
106
+ if File.exist?(temp)
107
+ @template = temp
108
+ return
109
+ end
110
+ end
111
+ raise Error::TemplateNotFound.new(path: file)
112
+ end
93
113
  #
94
114
  # Add a resource to the resource collection. Only new resources are added
95
115
  # and only resources that match the given filter are covered (which is *
@@ -1,3 +1,3 @@
1
1
  module ChefSpec
2
- VERSION = '8.0.0'
2
+ VERSION = '8.0.1'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  require 'chefspec'
2
2
  require 'support/hash'
3
3
 
4
+
5
+ ChefSpec::Coverage.start! do
6
+ set_template 'table.erb'
7
+ end
8
+
4
9
  RSpec.configure do |config|
5
10
  config.expect_with(:rspec) { |c| c.syntax = :expect }
6
11
  config.filter_run(focus: true)
@@ -0,0 +1,22 @@
1
+
2
+ <% if @total == 0 %>
3
+ No Chef resources found, skipping coverage calculation...
4
+ <% else %>
5
+ ChefSpec Coverage report generated...
6
+
7
+ Total Resources: <%= @total %>
8
+ Touched Resources: <%= @touched %>
9
+ Touch Coverage: <%= @coverage %>%
10
+
11
+ <% if @untouched_resources.empty? %>
12
+ You are awesome and so is your test coverage! Have a fantastic day!
13
+
14
+ <% else %>
15
+ Untouched Resources:
16
+
17
+ <% @untouched_resources.each do |resource| %>
18
+ <%= resource.to_s.ljust(32) %> <%= resource.source_file %>:<%= resource.source_line %>
19
+ <% end %>
20
+
21
+ <% end %>
22
+ <% end %>
@@ -0,0 +1,8 @@
1
+ { "resources":[
2
+ <%= @all_resources.map { |resource| resource.to_json }.join(",\n") %>
3
+ ],
4
+ "resource_count": <%= @total %>,
5
+ "resources_touched": <%= @touched %>,
6
+ "resource_coverage": <%= @coverage %>
7
+
8
+ }
@@ -0,0 +1,14 @@
1
+ <%='Touched'.to_s.ljust(8) %> <%='Resource'.to_s.ljust(48) %> File:Line
2
+ <% @all_resources.each do |resource| %>
3
+ <%=resource.touched?.to_s.ljust(8) %> <%= resource.to_s.ljust(48) %> <%= resource.source_file %>:<%= resource.source_line %>
4
+ <% end %>
5
+
6
+ <% if @total == 0 %>
7
+ No Chef resources found, skipping coverage calculation...
8
+ <% else %>
9
+ ChefSpec Coverage report generated...
10
+
11
+ Total Resources: <%= @total %>
12
+ Touched Resources: <%= @touched %>
13
+ Touch Coverage: <%= @coverage %>%
14
+ <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chefspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Crump
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-16 00:00:00.000000000 Z
12
+ date: 2019-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -181,6 +181,9 @@ files:
181
181
  - spec/unit/stubs/search_registry_spec.rb
182
182
  - spec/unit/stubs/search_stub_spec.rb
183
183
  - spec/unit/stubs/stub_spec.rb
184
+ - templates/coverage/human.erb
185
+ - templates/coverage/json.erb
186
+ - templates/coverage/table.erb
184
187
  - templates/errors/cookbook_path_not_found.erb
185
188
  - templates/errors/erb_template_parse_error.erb
186
189
  - templates/errors/gem_load_error.erb