metric_fu 4.10.0 → 4.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -2
- data/.simplecov +42 -0
- data/.travis.yml +7 -6
- data/CONTRIBUTING.md +1 -1
- data/DEV.md +4 -3
- data/Gemfile +29 -7
- data/HISTORY.md +29 -3
- data/README.md +6 -1
- data/Rakefile +33 -11
- data/checksum/metric_fu-4.10.0.gem.sha512 +1 -1
- data/gem_tasks/usage_test.rake +0 -11
- data/lib/metric_fu.rb +12 -0
- data/lib/metric_fu/configuration.rb +1 -5
- data/lib/metric_fu/environment.rb +3 -3
- data/lib/metric_fu/formatter.rb +1 -1
- data/lib/metric_fu/formatter/html.rb +9 -9
- data/lib/metric_fu/gem_run.rb +2 -2
- data/lib/metric_fu/{metrics/generator.rb → generator.rb} +0 -0
- data/lib/metric_fu/loader.rb +30 -23
- data/lib/metric_fu/logger.rb +65 -0
- data/lib/metric_fu/logging/mf_debugger.rb +13 -48
- data/lib/metric_fu/metric.rb +3 -3
- data/lib/metric_fu/metrics/cane/{cane.rb → generator.rb} +0 -0
- data/lib/metric_fu/metrics/cane/{cane_grapher.rb → grapher.rb} +0 -0
- data/lib/metric_fu/metrics/cane/{init.rb → metric.rb} +1 -1
- data/lib/metric_fu/metrics/cane/{template_awesome/cane.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/metrics/churn/{churn.rb → generator.rb} +0 -0
- data/lib/metric_fu/metrics/churn/{churn_hotspot.rb → hotspot.rb} +0 -0
- data/lib/metric_fu/metrics/churn/{init.rb → metric.rb} +0 -0
- data/lib/metric_fu/metrics/churn/{template_awesome/churn.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/metrics/flay/{flay.rb → generator.rb} +16 -2
- data/lib/metric_fu/metrics/flay/{flay_grapher.rb → grapher.rb} +0 -0
- data/lib/metric_fu/metrics/flay/{flay_hotspot.rb → hotspot.rb} +0 -0
- data/lib/metric_fu/metrics/flay/{init.rb → metric.rb} +1 -1
- data/lib/metric_fu/metrics/flay/{template_awesome/flay.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/metrics/flog/{flog.rb → generator.rb} +0 -0
- data/lib/metric_fu/metrics/flog/{flog_grapher.rb → grapher.rb} +0 -0
- data/lib/metric_fu/metrics/flog/{flog_hotspot.rb → hotspot.rb} +0 -0
- data/lib/metric_fu/metrics/flog/{init.rb → metric.rb} +1 -1
- data/lib/metric_fu/metrics/flog/{template_awesome/flog.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/metrics/hotspots/{hotspots.rb → generator.rb} +1 -1
- data/lib/metric_fu/metrics/hotspots/{init.rb → metric.rb} +0 -0
- data/lib/metric_fu/metrics/hotspots/{template_awesome/hotspots.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/metrics/rails_best_practices/{rails_best_practices.rb → generator.rb} +0 -0
- data/lib/metric_fu/metrics/rails_best_practices/{rails_best_practices_grapher.rb → grapher.rb} +0 -0
- data/lib/metric_fu/metrics/rails_best_practices/{init.rb → metric.rb} +1 -1
- data/lib/metric_fu/metrics/rails_best_practices/{template_awesome/rails_best_practices.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/metrics/rcov/{rcov.rb → generator.rb} +0 -0
- data/lib/metric_fu/metrics/rcov/{rcov_grapher.rb → grapher.rb} +0 -0
- data/lib/metric_fu/metrics/rcov/{rcov_hotspot.rb → hotspot.rb} +0 -0
- data/lib/metric_fu/metrics/rcov/{init.rb → metric.rb} +0 -0
- data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +57 -9
- data/lib/metric_fu/metrics/rcov/{template_awesome/rcov.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +13 -2
- data/lib/metric_fu/metrics/reek/{reek.rb → generator.rb} +0 -0
- data/lib/metric_fu/metrics/reek/{reek_grapher.rb → grapher.rb} +0 -0
- data/lib/metric_fu/metrics/reek/{reek_hotspot.rb → hotspot.rb} +1 -1
- data/lib/metric_fu/metrics/reek/{init.rb → metric.rb} +0 -0
- data/lib/metric_fu/metrics/reek/{template_awesome/reek.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/metrics/roodi/{roodi.rb → generator.rb} +0 -0
- data/lib/metric_fu/metrics/roodi/{roodi_grapher.rb → grapher.rb} +0 -0
- data/lib/metric_fu/metrics/roodi/{roodi_hotspot.rb → hotspot.rb} +0 -0
- data/lib/metric_fu/metrics/roodi/{init.rb → metric.rb} +0 -0
- data/lib/metric_fu/metrics/roodi/{template_awesome/roodi.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/metrics/saikuro/{saikuro.rb → generator.rb} +0 -0
- data/lib/metric_fu/metrics/saikuro/{saikuro_hotspot.rb → hotspot.rb} +0 -0
- data/lib/metric_fu/metrics/saikuro/{init.rb → metric.rb} +0 -0
- data/lib/metric_fu/metrics/saikuro/{template_awesome/saikuro.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/metrics/stats/{stats.rb → generator.rb} +1 -1
- data/lib/metric_fu/metrics/stats/{stats_grapher.rb → grapher.rb} +0 -0
- data/lib/metric_fu/metrics/stats/{stats_hotspot.rb → hotspot.rb} +0 -0
- data/lib/metric_fu/metrics/stats/{init.rb → metric.rb} +0 -0
- data/lib/metric_fu/metrics/stats/{template_awesome/stats.html.erb → report.html.erb} +0 -0
- data/lib/metric_fu/{metrics → reporting/graphs}/graph.rb +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/_graph.html.erb +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/_report_footer.html.erb +0 -0
- data/lib/metric_fu/templates/configuration.rb +3 -2
- data/lib/metric_fu/{reporting/templates/awesome → templates}/index.html.erb +1 -1
- data/lib/metric_fu/{reporting/templates → templates}/javascripts/bluff-min.js +0 -0
- data/lib/metric_fu/{reporting/templates → templates}/javascripts/bluff_graph.js +0 -0
- data/lib/metric_fu/{reporting/templates → templates}/javascripts/excanvas.js +0 -0
- data/lib/metric_fu/{reporting/templates → templates}/javascripts/highcharts.js +0 -0
- data/lib/metric_fu/{reporting/templates → templates}/javascripts/highcharts_graph.js +0 -0
- data/lib/metric_fu/{reporting/templates → templates}/javascripts/js-class.js +0 -0
- data/lib/metric_fu/{reporting/templates → templates}/javascripts/standalone-framework.js +0 -0
- data/lib/metric_fu/{reporting/templates → templates}/javascripts/utils.js +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/layout.html.erb +1 -1
- data/lib/metric_fu/templates/metrics_template.rb +68 -0
- data/lib/metric_fu/templates/report.rb +11 -3
- data/lib/metric_fu/{metrics/base_template.rb → templates/template.rb} +8 -24
- data/lib/metric_fu/utility.rb +25 -0
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +2 -0
- data/spec/capture_warnings.rb +48 -0
- data/spec/dummy/lib/bad_encoding.rb +6 -0
- data/spec/fixtures/coverage-153.rb +11 -0
- data/spec/fixtures/rcov_output.txt +135 -0
- data/spec/metric_fu/configuration_spec.rb +4 -265
- data/spec/metric_fu/formatter/configuration_spec.rb +46 -0
- data/spec/metric_fu/formatter/html_spec.rb +17 -25
- data/spec/metric_fu/formatter/yaml_spec.rb +1 -1
- data/spec/metric_fu/{metrics/generator_spec.rb → generator_spec.rb} +0 -0
- data/spec/metric_fu/metrics/cane/configuration_spec.rb +22 -0
- data/spec/metric_fu/metrics/cane/{cane_spec.rb → generator_spec.rb} +1 -1
- data/spec/metric_fu/metrics/churn/configuration_spec.rb +15 -0
- data/spec/metric_fu/metrics/churn/{churn_spec.rb → generator_spec.rb} +1 -1
- data/spec/metric_fu/metrics/flay/configuration_spec.rb +15 -0
- data/spec/metric_fu/metrics/flay/{flay_spec.rb → generator_spec.rb} +2 -2
- data/spec/metric_fu/metrics/flay/{flay_grapher_spec.rb → grapher_spec.rb} +1 -1
- data/spec/metric_fu/metrics/flog/configuration_spec.rb +20 -0
- data/spec/metric_fu/metrics/flog/{flog_spec.rb → generator_spec.rb} +1 -1
- data/spec/metric_fu/metrics/flog/{flog_grapher_spec.rb → grapher_spec.rb} +1 -1
- data/spec/metric_fu/metrics/hotspots/{hotspots_spec.rb → generator_spec.rb} +1 -1
- data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +47 -0
- data/spec/metric_fu/metrics/rails_best_practices/{rails_best_practices_spec.rb → generator_spec.rb} +1 -1
- data/spec/metric_fu/metrics/rails_best_practices/{rails_best_practices_grapher_spec.rb → grapher_spec.rb} +1 -1
- data/spec/metric_fu/metrics/rcov/configuration_spec.rb +30 -0
- data/spec/metric_fu/metrics/rcov/generator_spec.rb +26 -0
- data/spec/metric_fu/metrics/rcov/{rcov_grapher_spec.rb → grapher_spec.rb} +1 -1
- data/spec/metric_fu/metrics/rcov/{rcov_hotspot_spec.rb → hotspot_spec.rb} +2 -2
- data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +40 -12
- data/spec/metric_fu/metrics/reek/configuration_spec.rb +13 -0
- data/spec/metric_fu/metrics/reek/{reek_spec.rb → generator_spec.rb} +1 -1
- data/spec/metric_fu/metrics/reek/{reek_grapher_spec.rb → grapher_spec.rb} +1 -1
- data/spec/metric_fu/metrics/roodi/configuration_spec.rb +16 -0
- data/spec/metric_fu/metrics/roodi/{roodi_spec.rb → generator_spec.rb} +1 -1
- data/spec/metric_fu/metrics/roodi/{roodi_grapher_spec.rb → grapher_spec.rb} +1 -1
- data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +26 -0
- data/spec/metric_fu/metrics/saikuro/{saikuro_spec.rb → generator_spec.rb} +1 -1
- data/spec/metric_fu/metrics/stats/{stats_spec.rb → generator_spec.rb} +1 -1
- data/spec/metric_fu/metrics/stats/{stats_grapher_spec.rb → grapher_spec.rb} +1 -1
- data/spec/metric_fu/{metrics → reporting/graphs}/graph_spec.rb +1 -1
- data/spec/metric_fu/run_spec.rb +1 -1
- data/spec/metric_fu/templates/configuration_spec.rb +57 -0
- data/spec/metric_fu/templates/report_spec.rb +15 -0
- data/spec/metric_fu/{metrics/base_template_spec.rb → templates/template_spec.rb} +0 -0
- data/spec/quality_spec.rb +86 -0
- data/spec/shared/configured.rb +47 -0
- data/spec/shared/test_coverage.rb +99 -0
- data/spec/spec_helper.rb +9 -5
- data/spec/support/helper_methods.rb +3 -2
- data/spec/support/matcher_create_file.rb +2 -2
- data/spec/support/matcher_create_files.rb +2 -2
- data/spec/support/usage_test.rb +24 -7
- data/spec/usage_test_spec.rb +28 -2
- metadata +165 -112
- metadata.gz.sig +0 -0
- data/Gemfile.devtools +0 -39
- data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +0 -62
- data/spec/metric_fu/metrics/rcov/rcov_spec.rb +0 -185
@@ -78,18 +78,15 @@ describe MetricFu::Formatter::HTML do
|
|
78
78
|
])
|
79
79
|
end
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
formatter.finish
|
91
|
-
formatter.display_results
|
92
|
-
end
|
81
|
+
|
82
|
+
it "can open the results in the browser" do
|
83
|
+
allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
|
84
|
+
formatter = MetricFu::Formatter::HTML.new
|
85
|
+
path = MetricFu.run_path.join(directory('output_directory'))
|
86
|
+
uri = URI.join(URI.escape("file://#{path}/"), 'index.html')
|
87
|
+
expect(Launchy).to receive(:open).with(uri)
|
88
|
+
formatter.finish
|
89
|
+
formatter.display_results
|
93
90
|
end
|
94
91
|
|
95
92
|
end
|
@@ -129,19 +126,14 @@ describe MetricFu::Formatter::HTML do
|
|
129
126
|
)
|
130
127
|
end
|
131
128
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
path = MetricFu.run_path.join("#{directory('base_directory')}/#{@output}/index.html")
|
141
|
-
expect(formatter).to receive(:system).with("open #{path}")
|
142
|
-
formatter.finish
|
143
|
-
formatter.display_results
|
144
|
-
end
|
129
|
+
it "can open the results in the browser from the custom output directory" do
|
130
|
+
allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
|
131
|
+
formatter = MetricFu::Formatter::HTML.new(output: @output)
|
132
|
+
path = MetricFu.run_path.join("#{directory('base_directory')}/#{@output}")
|
133
|
+
uri = URI.join(URI.escape("file://#{path}/"), 'index.html')
|
134
|
+
expect(Launchy).to receive(:open).with(uri)
|
135
|
+
formatter.finish
|
136
|
+
formatter.display_results
|
145
137
|
end
|
146
138
|
|
147
139
|
end
|
@@ -53,7 +53,7 @@ describe MetricFu::Formatter::YAML do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "creates a report yaml in the custom stream" do
|
56
|
-
out =
|
56
|
+
out = MetricFu::Utility.capture_output {
|
57
57
|
MetricFu::Formatter::YAML.new(output: @output).finish
|
58
58
|
}
|
59
59
|
expect(out).to include ":#{@metric1}:"
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/configured'
|
3
|
+
|
4
|
+
describe MetricFu::Configuration, 'for cane' do
|
5
|
+
it_behaves_like 'configured' do
|
6
|
+
if MetricFu.configuration.mri?
|
7
|
+
it 'should set @cane to ' +
|
8
|
+
%q(:dirs_to_cane => @code_dirs, :abc_max => 15, :line_length => 80, :no_doc => 'n', :no_readme => 'y') do
|
9
|
+
load_metric 'cane'
|
10
|
+
expect(MetricFu::Metric.get_metric(:cane).run_options).to eq(
|
11
|
+
{
|
12
|
+
:dirs_to_cane => directory('code_dirs'),
|
13
|
+
:filetypes => ["rb"],
|
14
|
+
:abc_max => 15,
|
15
|
+
:line_length => 80,
|
16
|
+
:no_doc => "n",
|
17
|
+
:no_readme => "n"}
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end # end it_behaves
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/configured'
|
3
|
+
|
4
|
+
describe MetricFu::Configuration, 'for churn' do
|
5
|
+
it_behaves_like 'configured' do
|
6
|
+
|
7
|
+
it 'should set @churn to {}' do
|
8
|
+
load_metric 'churn'
|
9
|
+
expect(MetricFu::Metric.get_metric(:churn).run_options).to eq(
|
10
|
+
{ :start_date => %q("1 year ago"), :minimum_churn_count => 10, :ignore_files=>[], :data_directory=> MetricFu::Io::FileSystem.scratch_directory('churn')}
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/configured'
|
3
|
+
|
4
|
+
describe MetricFu::Configuration, 'for flay' do
|
5
|
+
it_behaves_like 'configured' do
|
6
|
+
|
7
|
+
it 'should set @flay to {:dirs_to_flay => @code_dirs}' do
|
8
|
+
load_metric 'flay'
|
9
|
+
expect(MetricFu::Metric.get_metric(:flay).run_options).to eq(
|
10
|
+
{:dirs_to_flay => ['lib'], :minimum_score=>nil}
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require { 'flay/
|
2
|
+
MetricFu.metrics_require { 'flay/generator' }
|
3
3
|
|
4
4
|
describe MetricFu::FlayGenerator do
|
5
5
|
describe "emit method" do
|
6
6
|
it "should look at the dirs" do
|
7
|
-
options = { :dirs_to_flay => ['app', 'lib']
|
7
|
+
options = { :dirs_to_flay => ['app', 'lib'] }
|
8
8
|
allow(File).to receive(:directory?).and_return(true)
|
9
9
|
@flay = MetricFu::FlayGenerator.new(options)
|
10
10
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/configured'
|
3
|
+
|
4
|
+
describe MetricFu::Configuration, 'for flog' do
|
5
|
+
it_behaves_like 'configured' do
|
6
|
+
|
7
|
+
if MetricFu.configuration.mri?
|
8
|
+
it 'should set @flog to {:dirs_to_flog => @code_dirs}' do
|
9
|
+
load_metric 'flog'
|
10
|
+
expect(MetricFu::Metric.get_metric(:flog).run_options).to eq({
|
11
|
+
:all => true,
|
12
|
+
:continue => true,
|
13
|
+
:dirs_to_flog => ["lib"],
|
14
|
+
:quiet => true
|
15
|
+
})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/configured'
|
3
|
+
|
4
|
+
describe MetricFu::Configuration, 'for rails_best_practices' do
|
5
|
+
it_behaves_like 'configured' do
|
6
|
+
|
7
|
+
describe 'if #rails? is true ' do
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@config = MetricFu.configuration
|
11
|
+
allow(@config).to receive(:rails?).and_return(true)
|
12
|
+
@config.reset
|
13
|
+
MetricFu.configure
|
14
|
+
%w(rails_best_practices).each do |metric|
|
15
|
+
load_metric metric
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#set_graphs ' do
|
20
|
+
it 'should set the graphs to include rails_best_practices' do
|
21
|
+
expect(MetricFu::Metric.get_metric(:rails_best_practices).has_graph?).to be_truthy
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should set @rails_best_practices to {}' do
|
26
|
+
load_metric 'rails_best_practices'
|
27
|
+
expect(MetricFu::Metric.get_metric(:rails_best_practices).run_options).to eql({})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
describe 'if #rails? is false ' do
|
33
|
+
before(:each) do
|
34
|
+
get_new_config
|
35
|
+
allow(@config).to receive(:rails?).and_return(false)
|
36
|
+
%w(rails_best_practices).each do |metric|
|
37
|
+
load_metric metric
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should set the registered code_dirs to ["lib"]' do
|
42
|
+
expect(directory('code_dirs')).to eq(['lib'])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/configured'
|
3
|
+
|
4
|
+
describe MetricFu::Configuration, 'for rcov' do
|
5
|
+
it_behaves_like 'configured' do
|
6
|
+
|
7
|
+
it 'should set rcov run_options' do
|
8
|
+
load_metric 'rcov'
|
9
|
+
expect(
|
10
|
+
MetricFu::Metric.get_metric(:rcov).run_options
|
11
|
+
).to eq(
|
12
|
+
{
|
13
|
+
:environment => 'test',
|
14
|
+
:external => nil,
|
15
|
+
:test_files => Dir['{spec,test}/**/*_{spec,test}.rb'],
|
16
|
+
:rcov_opts => [
|
17
|
+
"--sort coverage",
|
18
|
+
"--no-html",
|
19
|
+
"--text-coverage",
|
20
|
+
"--no-color",
|
21
|
+
"--profile",
|
22
|
+
"--exclude-only '.*'",
|
23
|
+
'--include-file "\Aapp,\Alib"',
|
24
|
+
"-Ispec"
|
25
|
+
],
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { 'rcov/generator' }
|
3
|
+
require 'shared/test_coverage'
|
4
|
+
|
5
|
+
describe MetricFu::RcovGenerator, "configured as rcov" do
|
6
|
+
|
7
|
+
it_behaves_like "rcov test coverage generator", :rcov do
|
8
|
+
|
9
|
+
describe "emit" do
|
10
|
+
before :each do
|
11
|
+
options = {:external => nil}
|
12
|
+
@test_coverage = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should set the RAILS_ENV" do
|
16
|
+
expect(MetricFu::Utility).to receive(:rm_rf).with(MetricFu::RcovGenerator.metric_directory, :verbose => false)
|
17
|
+
expect(MetricFu::Utility).to receive(:mkdir_p).with(MetricFu::RcovGenerator.metric_directory)
|
18
|
+
options = {:environment => 'metrics', :external => nil}
|
19
|
+
@test_coverage = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
20
|
+
expect(@test_coverage.command).to include('RAILS_ENV=metrics')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require { 'hotspots/
|
2
|
+
MetricFu.metrics_require { 'hotspots/metric' }
|
3
3
|
MetricFu.metrics_require { 'hotspots/hotspot' }
|
4
4
|
MetricFu.metrics_require { 'hotspots/analysis/record' }
|
5
|
-
MetricFu.metrics_require { 'rcov/
|
5
|
+
MetricFu.metrics_require { 'rcov/hotspot' }
|
6
6
|
|
7
7
|
describe MetricFu::RcovHotspot do
|
8
8
|
describe "map" do
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'simplecov'
|
3
3
|
require 'metric_fu/metrics/rcov/simplecov_formatter'
|
4
|
+
require 'metric_fu/metrics/rcov/generator'
|
4
5
|
|
5
6
|
describe SimpleCov::Formatter::MetricFu do
|
6
7
|
before do
|
@@ -14,8 +15,6 @@ describe SimpleCov::Formatter::MetricFu do
|
|
14
15
|
}
|
15
16
|
)
|
16
17
|
|
17
|
-
# Set to default encoding
|
18
|
-
Encoding.default_internal = nil if defined?(Encoding)
|
19
18
|
end
|
20
19
|
|
21
20
|
it "test_format" do
|
@@ -24,18 +23,47 @@ describe SimpleCov::Formatter::MetricFu do
|
|
24
23
|
expect(File.exists?( @rcov_file )).to be_truthy
|
25
24
|
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
if SimpleCov.running
|
27
|
+
MetricFu.logger.info "Skipping specs while SimpleCov is running"
|
28
|
+
else
|
29
|
+
it "test_create_content" do
|
30
|
+
content = SimpleCov::Formatter::MetricFu::FormatLikeRCov.new(@result).format
|
31
|
+
test = "\="*80
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
expect(content).to match(/#{test}/)
|
34
|
+
expect(content).to match(/!! value \* value/)
|
35
|
+
end
|
36
|
+
|
37
|
+
if defined?(JRUBY_VERSION)
|
38
|
+
STDOUT.puts "Skipping spec 'cause JRuby doesn't do Coverage right"
|
39
|
+
else
|
40
|
+
it 'calculates the same coverage from an RCov report as from SimpleCov' do
|
41
|
+
SimpleCov.start # start coverage
|
42
|
+
require 'fixtures/coverage-153'
|
43
|
+
result = SimpleCov.result # end coverage
|
44
|
+
source_file = result.source_files.first
|
45
|
+
|
46
|
+
|
47
|
+
# formatter ouputs this from simplecov result
|
48
|
+
rcov_text = SimpleCov::Formatter::MetricFu::FormatLikeRCov.new(result).format
|
49
|
+
|
50
|
+
# generator analyzes the rcov text
|
51
|
+
analyzed_rcov_text = MetricFu::RCovFormatCoverage.new(rcov_text).to_h
|
52
|
+
# [:lines, :percent_run, :methods]
|
53
|
+
covered_lines_from_rcov_text = analyzed_rcov_text['./spec/fixtures/coverage-153.rb'][:lines]
|
54
|
+
# https://github.com/colszowka/simplecov/blob/master/lib/simplecov/source_file.rb
|
55
|
+
expect(source_file.coverage.count).to eq(covered_lines_from_rcov_text.count)
|
56
|
+
|
57
|
+
line_coverage_from_rcov_text = covered_lines_from_rcov_text.map{|line| line[:was_run] }
|
58
|
+
expect(source_file.coverage).to eq(line_coverage_from_rcov_text)
|
59
|
+
|
60
|
+
expect(source_file.covered_percent).to eq(MetricFu::RCovFormatCoverage::TestCoverage.percent_run(covered_lines_from_rcov_text))
|
33
61
|
|
34
|
-
|
35
|
-
|
36
|
-
|
62
|
+
source_file.lines.each_with_index do |line, index|
|
63
|
+
expect(line.coverage).to eq(line_coverage_from_rcov_text[index])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
37
67
|
|
38
|
-
expect(content).to match(/#{test}/)
|
39
|
-
expect(content).to match(/!! value \* value/)
|
40
68
|
end
|
41
69
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/configured'
|
3
|
+
|
4
|
+
describe MetricFu::Configuration, 'for reek' do
|
5
|
+
it_behaves_like 'configured' do
|
6
|
+
it 'should set @reek to {:dirs_to_reek => @code_dirs}' do
|
7
|
+
load_metric 'reek'
|
8
|
+
expect(MetricFu::Metric.get_metric(:reek).run_options).to eq(
|
9
|
+
{:config_file_pattern=>nil, :dirs_to_reek => ['lib']}
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|