metric_fu 4.11.3 → 4.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +69 -0
- data/.travis.yml +0 -1
- data/CONTRIBUTORS +1 -1
- data/Gemfile +23 -20
- data/Guardfile +9 -9
- data/HISTORY.md +10 -1
- data/checksum/metric_fu-4.11.3.gem.sha512 +1 -0
- data/config/rubocop.yml +269 -0
- data/gem_tasks/rubocop.rake +10 -0
- data/lib/metric_fu.rb +11 -9
- data/lib/metric_fu/calculate.rb +0 -1
- data/lib/metric_fu/cli/client.rb +6 -6
- data/lib/metric_fu/cli/helper.rb +22 -13
- data/lib/metric_fu/cli/parser.rb +14 -18
- data/lib/metric_fu/configuration.rb +7 -11
- data/lib/metric_fu/constantize.rb +4 -4
- data/lib/metric_fu/data_structures/line_numbers.rb +10 -11
- data/lib/metric_fu/data_structures/location.rb +12 -14
- data/lib/metric_fu/data_structures/sexp_node.rb +31 -13
- data/lib/metric_fu/environment.rb +29 -31
- data/lib/metric_fu/formatter.rb +4 -6
- data/lib/metric_fu/formatter/html.rb +13 -13
- data/lib/metric_fu/formatter/syntax.rb +5 -7
- data/lib/metric_fu/formatter/yaml.rb +1 -1
- data/lib/metric_fu/gem_run.rb +13 -15
- data/lib/metric_fu/gem_version.rb +9 -11
- data/lib/metric_fu/generator.rb +5 -8
- data/lib/metric_fu/io.rb +13 -15
- data/lib/metric_fu/loader.rb +17 -18
- data/lib/metric_fu/logger.rb +15 -18
- data/lib/metric_fu/logging/mf_debugger.rb +4 -4
- data/lib/metric_fu/metric.rb +11 -12
- data/lib/metric_fu/metrics/cane/generator.rb +10 -9
- data/lib/metric_fu/metrics/cane/grapher.rb +5 -7
- data/lib/metric_fu/metrics/cane/metric.rb +6 -8
- data/lib/metric_fu/metrics/cane/report.html.erb +3 -3
- data/lib/metric_fu/metrics/cane/violations.rb +6 -6
- data/lib/metric_fu/metrics/churn/generator.rb +2 -6
- data/lib/metric_fu/metrics/churn/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/churn/metric.rb +5 -7
- data/lib/metric_fu/metrics/flay/generator.rb +7 -11
- data/lib/metric_fu/metrics/flay/grapher.rb +5 -6
- data/lib/metric_fu/metrics/flay/hotspot.rb +5 -7
- data/lib/metric_fu/metrics/flay/metric.rb +5 -7
- data/lib/metric_fu/metrics/flog/generator.rb +22 -23
- data/lib/metric_fu/metrics/flog/grapher.rb +11 -11
- data/lib/metric_fu/metrics/flog/hotspot.rb +3 -5
- data/lib/metric_fu/metrics/flog/metric.rb +3 -5
- data/lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb +0 -1
- data/lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb +19 -18
- data/lib/metric_fu/metrics/hotspots/analysis/grouping.rb +0 -2
- data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -3
- data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +4 -6
- data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +14 -9
- data/lib/metric_fu/metrics/hotspots/analysis/ranking.rb +4 -5
- data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +1 -3
- data/lib/metric_fu/metrics/hotspots/analysis/record.rb +3 -5
- data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +0 -2
- data/lib/metric_fu/metrics/hotspots/analysis/table.rb +3 -4
- data/lib/metric_fu/metrics/hotspots/generator.rb +3 -6
- data/lib/metric_fu/metrics/hotspots/hotspot.rb +13 -13
- data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +5 -8
- data/lib/metric_fu/metrics/hotspots/metric.rb +1 -3
- data/lib/metric_fu/metrics/hotspots/report.html.erb +1 -1
- data/lib/metric_fu/metrics/rails_best_practices/generator.rb +10 -12
- data/lib/metric_fu/metrics/rails_best_practices/grapher.rb +5 -6
- data/lib/metric_fu/metrics/rails_best_practices/metric.rb +1 -3
- data/lib/metric_fu/metrics/rcov/external_client.rb +1 -3
- data/lib/metric_fu/metrics/rcov/generator.rb +13 -15
- data/lib/metric_fu/metrics/rcov/grapher.rb +6 -7
- data/lib/metric_fu/metrics/rcov/hotspot.rb +5 -7
- data/lib/metric_fu/metrics/rcov/metric.rb +5 -7
- data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +16 -55
- data/lib/metric_fu/metrics/rcov/rcov_line.rb +48 -0
- data/lib/metric_fu/metrics/rcov/report.html.erb +2 -2
- data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +10 -11
- data/lib/metric_fu/metrics/reek/generator.rb +22 -23
- data/lib/metric_fu/metrics/reek/grapher.rb +5 -6
- data/lib/metric_fu/metrics/reek/hotspot.rb +5 -7
- data/lib/metric_fu/metrics/reek/metric.rb +2 -4
- data/lib/metric_fu/metrics/roodi/generator.rb +9 -10
- data/lib/metric_fu/metrics/roodi/grapher.rb +5 -6
- data/lib/metric_fu/metrics/roodi/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/roodi/metric.rb +2 -4
- data/lib/metric_fu/metrics/saikuro/generator.rb +23 -27
- data/lib/metric_fu/metrics/saikuro/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/saikuro/metric.rb +7 -8
- data/lib/metric_fu/metrics/saikuro/parsing_element.rb +6 -8
- data/lib/metric_fu/metrics/saikuro/report.html.erb +1 -1
- data/lib/metric_fu/metrics/saikuro/scratch_file.rb +24 -29
- data/lib/metric_fu/metrics/stats/generator.rb +9 -12
- data/lib/metric_fu/metrics/stats/grapher.rb +8 -9
- data/lib/metric_fu/metrics/stats/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/stats/metric.rb +3 -5
- data/lib/metric_fu/reporter.rb +1 -1
- data/lib/metric_fu/reporting/graphs/graph.rb +8 -12
- data/lib/metric_fu/reporting/graphs/grapher.rb +7 -9
- data/lib/metric_fu/reporting/result.rb +0 -3
- data/lib/metric_fu/run.rb +12 -3
- data/lib/metric_fu/tasks/metric_fu.rake +8 -8
- data/lib/metric_fu/templates/configuration.rb +2 -5
- data/lib/metric_fu/templates/metrics_template.rb +19 -19
- data/lib/metric_fu/templates/report.rb +5 -8
- data/lib/metric_fu/templates/template.rb +20 -24
- data/lib/metric_fu/utility.rb +7 -8
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +31 -32
- data/spec/cli/helper_spec.rb +7 -14
- data/spec/dummy/lib/bad_encoding.rb +1 -1
- data/spec/fixtures/coverage-153.rb +2 -2
- data/spec/fixtures/coverage.rb +2 -2
- data/spec/metric_fu/calculate_spec.rb +3 -3
- data/spec/metric_fu/configuration_spec.rb +70 -82
- data/spec/metric_fu/data_structures/line_numbers_spec.rb +3 -5
- data/spec/metric_fu/data_structures/location_spec.rb +13 -31
- data/spec/metric_fu/formatter/configuration_spec.rb +11 -13
- data/spec/metric_fu/formatter/html_spec.rb +21 -28
- data/spec/metric_fu/formatter/yaml_spec.rb +9 -17
- data/spec/metric_fu/formatter_spec.rb +6 -6
- data/spec/metric_fu/gem_version_spec.rb +3 -5
- data/spec/metric_fu/generator_spec.rb +28 -38
- data/spec/metric_fu/loader_spec.rb +1 -3
- data/spec/metric_fu/metric_spec.rb +17 -21
- data/spec/metric_fu/metrics/cane/configuration_spec.rb +8 -8
- data/spec/metric_fu/metrics/cane/generator_spec.rb +26 -29
- data/spec/metric_fu/metrics/churn/configuration_spec.rb +6 -8
- data/spec/metric_fu/metrics/churn/generator_spec.rb +6 -11
- data/spec/metric_fu/metrics/flay/configuration_spec.rb +6 -8
- data/spec/metric_fu/metrics/flay/generator_spec.rb +36 -37
- data/spec/metric_fu/metrics/flay/grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/flog/configuration_spec.rb +11 -13
- data/spec/metric_fu/metrics/flog/generator_spec.rb +29 -31
- data/spec/metric_fu/metrics/flog/grapher_spec.rb +8 -10
- data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +18 -24
- data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +12 -17
- data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +2 -6
- data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -14
- data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +1 -3
- data/spec/metric_fu/metrics/hotspots/generator_spec.rb +6 -8
- data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +1 -3
- data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +4 -5
- data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +6 -10
- data/spec/metric_fu/metrics/rails_best_practices/generator_spec.rb +2 -3
- data/spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb +3 -3
- data/spec/metric_fu/metrics/rcov/configuration_spec.rb +20 -22
- data/spec/metric_fu/metrics/rcov/generator_spec.rb +6 -10
- data/spec/metric_fu/metrics/rcov/grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/rcov/hotspot_spec.rb +8 -8
- data/spec/metric_fu/metrics/rcov/rcov_line_spec.rb +89 -0
- data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +31 -33
- data/spec/metric_fu/metrics/reek/configuration_spec.rb +6 -6
- data/spec/metric_fu/metrics/reek/generator_spec.rb +19 -20
- data/spec/metric_fu/metrics/reek/grapher_spec.rb +4 -4
- data/spec/metric_fu/metrics/roodi/configuration_spec.rb +7 -9
- data/spec/metric_fu/metrics/roodi/generator_spec.rb +3 -3
- data/spec/metric_fu/metrics/roodi/grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +18 -19
- data/spec/metric_fu/metrics/saikuro/generator_spec.rb +7 -7
- data/spec/metric_fu/metrics/stats/generator_spec.rb +9 -9
- data/spec/metric_fu/metrics/stats/grapher_spec.rb +2 -2
- data/spec/metric_fu/reporter_spec.rb +3 -4
- data/spec/metric_fu/reporting/graphs/graph_spec.rb +1 -4
- data/spec/metric_fu/reporting/graphs/grapher_spec.rb +5 -5
- data/spec/metric_fu/reporting/result_spec.rb +9 -11
- data/spec/metric_fu/run_spec.rb +18 -32
- data/spec/metric_fu/templates/configuration_spec.rb +28 -34
- data/spec/metric_fu/templates/metrics_template_spec.rb +11 -0
- data/spec/metric_fu/templates/report_spec.rb +4 -4
- data/spec/metric_fu/templates/template_spec.rb +62 -48
- data/spec/metric_fu/utility_spec.rb +2 -2
- data/spec/metric_fu_spec.rb +5 -7
- data/spec/shared/configured.rb +9 -11
- data/spec/shared/test_coverage.rb +5 -9
- data/spec/spec_helper.rb +9 -9
- data/spec/support/deferred_garbaged_collection.rb +1 -2
- data/spec/support/matcher_create_file.rb +2 -4
- data/spec/support/matcher_create_files.rb +2 -4
- data/spec/support/suite.rb +3 -3
- data/spec/support/test_fixtures.rb +5 -7
- data/spec/support/timeout.rb +1 -1
- data/spec/support/usage_test.rb +23 -24
- data/spec/usage_test_spec.rb +18 -20
- metadata +12 -2
- metadata.gz.sig +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "saikuro/generator" }
|
3
3
|
|
4
4
|
describe MetricFu::SaikuroGenerator do
|
5
5
|
STUB_TEST_DATA = lambda do |generator|
|
@@ -22,7 +22,7 @@ describe MetricFu::SaikuroGenerator do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should find the filename of a file" do
|
25
|
-
expect(@output[:saikuro][:files].first[:filename]).to eq(
|
25
|
+
expect(@output[:saikuro][:files].first[:filename]).to eq("app/controllers/users_controller.rb")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should find the name of the classes" do
|
@@ -55,16 +55,16 @@ describe MetricFu::SaikuroGenerator do
|
|
55
55
|
|
56
56
|
it "doesn't try to get information if the file does not exist" do
|
57
57
|
expect(@saikuro).to receive(:file_not_exists?).at_least(:once).and_return(true)
|
58
|
-
@saikuro.per_file_info(
|
58
|
+
@saikuro.per_file_info("ignore_me")
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
describe MetricFu::SaikuroScratchFile do
|
63
63
|
describe "getting elements from a Saikuro result file" do
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
it "should parse nested START/END sections" do
|
65
|
+
path = FIXTURE.fixtures_path.join("saikuro_sfiles", "thing.rb_cyclo.html").to_s
|
66
|
+
sfile = MetricFu::SaikuroScratchFile.new path
|
67
|
+
expect(sfile.elements.map(&:complexity).sort).to eql(["0", "0", "2"])
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "stats/generator" }
|
3
3
|
|
4
4
|
describe StatsGenerator do
|
5
5
|
describe "emit method" do
|
6
6
|
it "should gather the raw data" do
|
7
|
-
ENV[
|
7
|
+
ENV["CC_BUILD_ARTIFACTS"] = nil
|
8
8
|
MetricFu.configure.reset
|
9
9
|
allow(File).to receive(:directory?).and_return(true)
|
10
10
|
stats = MetricFu::StatsGenerator.new
|
@@ -12,7 +12,7 @@ describe StatsGenerator do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
#TODO review tested output
|
15
|
+
# TODO review tested output
|
16
16
|
describe "analyze method" do
|
17
17
|
before :each do
|
18
18
|
@lines = <<-HERE.gsub(/^\s*/, "")
|
@@ -34,11 +34,11 @@ describe StatsGenerator do
|
|
34
34
|
Code LOC: 915 Test LOC: 2226 Code to Test Ratio: 1:2.4
|
35
35
|
|
36
36
|
HERE
|
37
|
-
ENV[
|
37
|
+
ENV["CC_BUILD_ARTIFACTS"] = nil
|
38
38
|
MetricFu.configure.reset
|
39
39
|
allow(File).to receive(:directory?).and_return(true)
|
40
40
|
stats = MetricFu::StatsGenerator.new
|
41
|
-
stats.instance_variable_set(
|
41
|
+
stats.instance_variable_set("@output", @lines)
|
42
42
|
@results = stats.analyze
|
43
43
|
end
|
44
44
|
|
@@ -55,7 +55,7 @@ describe StatsGenerator do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should get data on models" do
|
58
|
-
model_data = @results[:lines].find {|line| line[:name] == "Models"}
|
58
|
+
model_data = @results[:lines].find { |line| line[:name] == "Models" }
|
59
59
|
expect(model_data[:classes]).to eq(9)
|
60
60
|
expect(model_data[:methods]).to eq(31)
|
61
61
|
expect(model_data[:loc]).to eq(285)
|
@@ -73,11 +73,11 @@ describe StatsGenerator do
|
|
73
73
|
Code LOC: 0 Test LOC: 0 Code to Test Ratio: 1:NaN
|
74
74
|
|
75
75
|
HERE
|
76
|
-
ENV[
|
76
|
+
ENV["CC_BUILD_ARTIFACTS"] = nil
|
77
77
|
MetricFu.configure.reset
|
78
78
|
allow(File).to receive(:directory?).and_return(true)
|
79
79
|
stats = MetricFu::StatsGenerator.new(MetricFu::Metric.get_metric(:stats).run_options)
|
80
|
-
stats.instance_variable_set(
|
80
|
+
stats.instance_variable_set("@output", lines)
|
81
81
|
@results = stats.analyze
|
82
82
|
expect(@results[:code_to_test_ratio]).to eq(0.0)
|
83
83
|
end
|
@@ -85,7 +85,7 @@ describe StatsGenerator do
|
|
85
85
|
|
86
86
|
describe "to_h method" do
|
87
87
|
it "should put things into a hash" do
|
88
|
-
ENV[
|
88
|
+
ENV["CC_BUILD_ARTIFACTS"] = nil
|
89
89
|
MetricFu.configure.reset
|
90
90
|
allow(File).to receive(:directory?).and_return(true)
|
91
91
|
stats = MetricFu::StatsGenerator.new
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "stats/grapher" }
|
3
3
|
|
4
4
|
describe StatsGrapher do
|
5
5
|
before :each do
|
@@ -61,7 +61,7 @@ describe StatsGrapher do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should update labels with the date" do
|
64
|
-
expect(@stats_grapher.labels).to receive(:update).with(
|
64
|
+
expect(@stats_grapher.labels).to receive(:update).with(0 => "01022003")
|
65
65
|
@stats_grapher.get_metrics(@metrics, @date)
|
66
66
|
end
|
67
67
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.lib_require {
|
2
|
+
MetricFu.lib_require { "reporter" }
|
3
3
|
|
4
4
|
describe MetricFu::Reporter do
|
5
|
-
|
6
5
|
context "given a single formatter" do
|
7
6
|
before do
|
8
|
-
@formatter = double(
|
7
|
+
@formatter = double("formatter")
|
9
8
|
allow(@formatter).to receive(:to_a).and_return([@formatter])
|
10
9
|
@reporter = Reporter.new(@formatter)
|
11
10
|
end
|
@@ -26,7 +25,7 @@ describe MetricFu::Reporter do
|
|
26
25
|
|
27
26
|
context "given multiple formatters" do
|
28
27
|
before do
|
29
|
-
@formatters = [double(
|
28
|
+
@formatters = [double("formatter"), double("formatter")]
|
30
29
|
@reporter = Reporter.new(@formatters)
|
31
30
|
end
|
32
31
|
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.reporting_require {
|
2
|
+
MetricFu.reporting_require { "graphs/graph" }
|
3
3
|
|
4
4
|
describe MetricFu do
|
5
|
-
|
6
5
|
describe "responding to #graph" do
|
7
6
|
it "should return an instance of Graph" do
|
8
7
|
expect(MetricFu.graph).to be_a(Graph)
|
@@ -11,13 +10,11 @@ describe MetricFu do
|
|
11
10
|
end
|
12
11
|
|
13
12
|
describe MetricFu::Graph do
|
14
|
-
|
15
13
|
before(:each) do
|
16
14
|
@graph = MetricFu::Graph.new
|
17
15
|
end
|
18
16
|
|
19
17
|
describe "setting the date on the graph" do
|
20
|
-
|
21
18
|
# TODO better test
|
22
19
|
it "should set the date once for one data point" do
|
23
20
|
metric_file = "metric_fu/tmp/_data/20101105.yml"
|
@@ -9,16 +9,16 @@ describe "Bluff graphers responding to #graph!" do
|
|
9
9
|
end
|
10
10
|
it "should write chart file" do
|
11
11
|
graphs = {}
|
12
|
-
available_graphs = MetricFu::Metric.enabled_metrics.select
|
12
|
+
available_graphs = MetricFu::Metric.enabled_metrics.select(&:has_graph?).map(&:name)
|
13
13
|
available_graphs.each do |graph|
|
14
|
-
grapher_name = graph.to_s.gsub("MetricFu::",
|
15
|
-
grapher_name = grapher_name+"Grapher"
|
14
|
+
grapher_name = graph.to_s.gsub("MetricFu::", "").gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
15
|
+
grapher_name = grapher_name + "Grapher"
|
16
16
|
graphs[graph] = MetricFu.const_get(grapher_name).new
|
17
17
|
end
|
18
18
|
graphs.each do |key, val|
|
19
19
|
val.graph!
|
20
|
-
output_dir = File.expand_path(File.join(MetricFu::Io::FileSystem.directory(
|
21
|
-
expect{ File.read(File.join(output_dir, "#{key.to_s.downcase}.js")) }.not_to raise_error
|
20
|
+
output_dir = File.expand_path(File.join(MetricFu::Io::FileSystem.directory("output_directory")))
|
21
|
+
expect { File.read(File.join(output_dir, "#{key.to_s.downcase}.js")) }.not_to raise_error
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.reporting_require {
|
2
|
+
MetricFu.reporting_require { "result" }
|
3
3
|
|
4
4
|
describe MetricFu do
|
5
|
-
|
6
5
|
describe "#result" do
|
7
6
|
it "should return an instance of Result" do
|
8
7
|
expect(MetricFu.result.instance_of?(Result)).to be(true)
|
@@ -11,14 +10,13 @@ describe MetricFu do
|
|
11
10
|
end
|
12
11
|
|
13
12
|
describe MetricFu::Result do
|
14
|
-
|
15
13
|
before(:each) do
|
16
14
|
@result = MetricFu::Result.new
|
17
15
|
end
|
18
16
|
|
19
17
|
describe "#as_yaml" do
|
20
18
|
it "should call #result_hash" do
|
21
|
-
result_hash = double(
|
19
|
+
result_hash = double("result_hash")
|
22
20
|
expect(result_hash).to receive(:to_yaml)
|
23
21
|
|
24
22
|
expect(@result).to receive(:result_hash).and_return(result_hash)
|
@@ -31,19 +29,19 @@ describe MetricFu::Result do
|
|
31
29
|
|
32
30
|
describe "#add" do
|
33
31
|
it "should add a passed hash to the result_hash instance variable" do
|
34
|
-
result_type = double(
|
35
|
-
allow(result_type).to receive(:to_s).and_return(
|
32
|
+
result_type = double("result_type")
|
33
|
+
allow(result_type).to receive(:to_s).and_return("type")
|
36
34
|
|
37
|
-
result_inst = double(
|
35
|
+
result_inst = double("result_inst")
|
38
36
|
expect(result_type).to receive(:new).and_return(result_inst)
|
39
37
|
|
40
|
-
expect(result_inst).to receive(:generate_result).and_return(
|
38
|
+
expect(result_inst).to receive(:generate_result).and_return(a: "b")
|
41
39
|
expect(result_inst).to receive(:respond_to?).and_return(false)
|
42
40
|
|
43
41
|
expect(MetricFu::Generator).to receive(:get_generator).
|
44
|
-
|
45
|
-
result_hash = double(
|
46
|
-
expect(result_hash).to receive(:merge!).with(
|
42
|
+
with(result_type).and_return(result_type)
|
43
|
+
result_hash = double("result_hash")
|
44
|
+
expect(result_hash).to receive(:merge!).with(a: "b")
|
47
45
|
expect(@result).to receive(:result_hash).and_return(result_hash)
|
48
46
|
expect(@result).to receive(:metric_options_for_result_type).with(result_type)
|
49
47
|
@result.add(result_type)
|
data/spec/metric_fu/run_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "metric_fu/cli/client"
|
3
3
|
|
4
4
|
describe MetricFu do
|
5
5
|
let(:helper) { MetricFu::Cli::Helper.new }
|
@@ -9,21 +9,19 @@ describe MetricFu do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def base_directory
|
12
|
-
directory(
|
12
|
+
directory("base_directory")
|
13
13
|
end
|
14
14
|
|
15
15
|
def output_directory
|
16
|
-
directory(
|
16
|
+
directory("output_directory")
|
17
17
|
end
|
18
18
|
|
19
19
|
def data_directory
|
20
|
-
directory(
|
20
|
+
directory("data_directory")
|
21
21
|
end
|
22
22
|
|
23
23
|
context "given configured metrics, when run" do
|
24
|
-
|
25
24
|
before do
|
26
|
-
|
27
25
|
# TODO: Should probably use some sort of fake metric
|
28
26
|
# to speed up tests. For now, just configuring with a
|
29
27
|
# limited set, so we can test the basic functionality
|
@@ -40,12 +38,11 @@ describe MetricFu do
|
|
40
38
|
# need some help debugging
|
41
39
|
# but tests seem more stable without it.
|
42
40
|
# metric.should_receive(:run_external).and_return('')
|
43
|
-
allow(metric).to receive(:run_external).and_return(
|
41
|
+
allow(metric).to receive(:run_external).and_return("")
|
44
42
|
else
|
45
43
|
metric.enabled = false
|
46
44
|
end
|
47
45
|
end
|
48
|
-
|
49
46
|
end
|
50
47
|
|
51
48
|
it "creates a report yaml file" do
|
@@ -78,22 +75,19 @@ describe MetricFu do
|
|
78
75
|
metric_fu
|
79
76
|
}.to_not create_file("#{output_directory}/index.html")
|
80
77
|
end
|
81
|
-
|
82
78
|
end
|
83
79
|
|
84
80
|
context "with command line formatter" do
|
85
81
|
it "outputs using command line formatter" do
|
86
|
-
expect { metric_fu "--format yaml"}.to create_file("#{base_directory}/report.yml")
|
82
|
+
expect { metric_fu "--format yaml" }.to create_file("#{base_directory}/report.yml")
|
87
83
|
end
|
88
84
|
|
89
85
|
it "doesn't output using formatters not configured" do
|
90
|
-
expect { metric_fu "--format yaml"}.to_not create_file("#{output_directory}/index.html")
|
86
|
+
expect { metric_fu "--format yaml" }.to_not create_file("#{output_directory}/index.html")
|
91
87
|
end
|
92
|
-
|
93
88
|
end
|
94
89
|
|
95
90
|
context "with configured and command line formatter" do
|
96
|
-
|
97
91
|
before do
|
98
92
|
MetricFu::Configuration.run do |config|
|
99
93
|
config.configure_formatter(:html)
|
@@ -101,13 +95,12 @@ describe MetricFu do
|
|
101
95
|
end
|
102
96
|
|
103
97
|
it "outputs using command line formatter" do
|
104
|
-
expect { metric_fu "--format yaml"}.to create_file("#{base_directory}/report.yml")
|
98
|
+
expect { metric_fu "--format yaml" }.to create_file("#{base_directory}/report.yml")
|
105
99
|
end
|
106
100
|
|
107
101
|
it "doesn't output using configured formatter (cli takes precedence)" do
|
108
|
-
expect { metric_fu "--format yaml"}.to_not create_file("#{output_directory}/index.html")
|
102
|
+
expect { metric_fu "--format yaml" }.to_not create_file("#{output_directory}/index.html")
|
109
103
|
end
|
110
|
-
|
111
104
|
end
|
112
105
|
|
113
106
|
context "with configured specified out" do
|
@@ -128,32 +121,28 @@ describe MetricFu do
|
|
128
121
|
metric_fu
|
129
122
|
}.to_not create_file("#{base_directory}/report.yml")
|
130
123
|
end
|
131
|
-
|
132
124
|
end
|
133
125
|
|
134
126
|
context "with command line specified formatter + out" do
|
135
127
|
it "outputs to the specified path" do
|
136
|
-
expect { metric_fu "--format yaml --out customreport.yml"}.to create_file("#{base_directory}/customreport.yml")
|
128
|
+
expect { metric_fu "--format yaml --out customreport.yml" }.to create_file("#{base_directory}/customreport.yml")
|
137
129
|
end
|
138
130
|
|
139
131
|
it "doesn't output to default path" do
|
140
|
-
expect { metric_fu "--format yaml --out customreport.yml"}.to_not create_file("#{base_directory}/report.yml")
|
132
|
+
expect { metric_fu "--format yaml --out customreport.yml" }.to_not create_file("#{base_directory}/report.yml")
|
141
133
|
end
|
142
|
-
|
143
134
|
end
|
144
135
|
|
145
136
|
context "with command line specified out only" do
|
146
137
|
it "outputs to the specified path" do
|
147
|
-
expect { metric_fu "--out customdir --no-open"}.to create_file("#{base_directory}/customdir/index.html")
|
138
|
+
expect { metric_fu "--out customdir --no-open" }.to create_file("#{base_directory}/customdir/index.html")
|
148
139
|
end
|
149
140
|
|
150
141
|
it "doesn't output to default path" do
|
151
|
-
expect { metric_fu "--out customdir --no-open"}.to_not create_file("#{output_directory}/index.html")
|
142
|
+
expect { metric_fu "--out customdir --no-open" }.to_not create_file("#{output_directory}/index.html")
|
152
143
|
end
|
153
|
-
|
154
144
|
end
|
155
145
|
|
156
|
-
|
157
146
|
after do
|
158
147
|
MetricFu::Configuration.run do |config|
|
159
148
|
config.formatters.clear
|
@@ -162,7 +151,6 @@ describe MetricFu do
|
|
162
151
|
end
|
163
152
|
|
164
153
|
context "given other options" do
|
165
|
-
|
166
154
|
it "displays help" do
|
167
155
|
out = metric_fu "--help"
|
168
156
|
expect(out).to include helper.banner
|
@@ -175,14 +163,13 @@ describe MetricFu do
|
|
175
163
|
|
176
164
|
it "errors on unknown flags" do
|
177
165
|
failure = false
|
178
|
-
out = metric_fu "--asdasdasda" do |
|
166
|
+
out = metric_fu "--asdasdasda" do |_message|
|
179
167
|
# swallow the error message
|
180
168
|
failure = true
|
181
169
|
end
|
182
|
-
expect(out).to include
|
170
|
+
expect(out).to include "invalid option"
|
183
171
|
expect(failure).to be_truthy
|
184
172
|
end
|
185
|
-
|
186
173
|
end
|
187
174
|
|
188
175
|
after do
|
@@ -190,7 +177,7 @@ describe MetricFu do
|
|
190
177
|
end
|
191
178
|
|
192
179
|
def metric_fu(options = "--no-open")
|
193
|
-
message =
|
180
|
+
message = ""
|
194
181
|
out = MetricFu::Utility.capture_output {
|
195
182
|
begin
|
196
183
|
argv = Shellwords.shellwords(options)
|
@@ -202,10 +189,9 @@ describe MetricFu do
|
|
202
189
|
message << "#{system_exit.message} #{system_exit.backtrace}"
|
203
190
|
end
|
204
191
|
}
|
205
|
-
if message.start_with?(
|
192
|
+
if message.start_with?("FAILURE")
|
206
193
|
block_given? ? yield(message) : STDERR.puts(message)
|
207
194
|
end
|
208
195
|
out
|
209
196
|
end
|
210
|
-
|
211
197
|
end
|
@@ -4,54 +4,48 @@ require "shared/configured"
|
|
4
4
|
describe MetricFu::Configuration, "for templates" do
|
5
5
|
it_behaves_like "configured" do
|
6
6
|
describe "when there is no CC_BUILD_ARTIFACTS environment variable" do
|
7
|
-
|
8
7
|
before(:each) do
|
9
8
|
ENV["CC_BUILD_ARTIFACTS"] = nil
|
10
9
|
get_new_config
|
11
10
|
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
it "should set @template_class to MetricFu::Templates::MetricsTemplate by default" do
|
21
|
-
expect(template_class).to eq(MetricFu::Templates::MetricsTemplate)
|
22
|
-
end
|
12
|
+
it "should set @template_directory to the lib/templates relative " + "to @metric_fu_root_directory" do
|
13
|
+
expected_template_dir = MetricFu.root.join("lib", "templates").to_s
|
14
|
+
expect(template_directory).to eq(expected_template_dir)
|
15
|
+
end
|
23
16
|
|
24
|
-
|
17
|
+
it "should set @template_class to MetricFu::Templates::MetricsTemplate by default" do
|
18
|
+
expect(template_class).to eq(MetricFu::Templates::MetricsTemplate)
|
19
|
+
end
|
25
20
|
|
26
|
-
|
27
|
-
|
21
|
+
describe "when a templates configuration is given" do
|
22
|
+
before do
|
23
|
+
class DummyTemplate; end
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
@config.templates_configuration do |config|
|
26
|
+
config.template_class = DummyTemplate
|
27
|
+
config.link_prefix = "http:/"
|
28
|
+
config.syntax_highlighting = false
|
29
|
+
config.darwin_txmt_protocol_no_thanks = false
|
30
|
+
end
|
34
31
|
end
|
35
|
-
end
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
it "should set given template_class" do
|
34
|
+
expect(template_class).to eq(DummyTemplate)
|
35
|
+
end
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
it "should set given link_prefix" do
|
38
|
+
expect(MetricFu::Formatter::Templates.option("link_prefix")).to eq("http:/")
|
39
|
+
end
|
44
40
|
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
it "should set given darwin_txmt_protocol_no_thanks" do
|
42
|
+
expect(MetricFu::Formatter::Templates.option("darwin_txmt_protocol_no_thanks")).to be_falsey
|
43
|
+
end
|
48
44
|
|
49
|
-
|
50
|
-
|
45
|
+
it "should set given syntax_highlighting" do
|
46
|
+
expect(MetricFu::Formatter::Templates.option("syntax_highlighting")).to be_falsey
|
47
|
+
end
|
51
48
|
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
49
|
end
|
56
50
|
end
|
57
51
|
end
|