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
@@ -2,101 +2,89 @@ require "spec_helper"
|
|
2
2
|
require "shared/configured"
|
3
3
|
|
4
4
|
describe MetricFu::Configuration do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
it_behaves_like "configured" do
|
6
|
+
describe "#is_cruise_control_rb?" do
|
7
|
+
before(:each) { get_new_config }
|
8
|
+
describe "when the CC_BUILD_ARTIFACTS env var is not nil" do
|
9
|
+
before(:each) do
|
10
|
+
ENV["CC_BUILD_ARTIFACTS"] = "is set"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return true" do
|
14
|
+
expect(@config.is_cruise_control_rb?).to be_truthy
|
15
|
+
end
|
16
|
+
|
17
|
+
after(:each) do
|
18
|
+
ENV["CC_BUILD_ARTIFACTS"] = nil
|
19
|
+
FileUtils.rm_rf(File.join(MetricFu.root_dir, "is set"))
|
20
|
+
end
|
15
21
|
end
|
16
22
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
23
|
+
describe "when the CC_BUILD_ARTIFACTS env var is nil" do
|
24
|
+
before(:each) { ENV["CC_BUILD_ARTIFACTS"] = nil }
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
it "should return false" do
|
27
|
+
expect(@config.is_cruise_control_rb?).to be_falsey
|
28
|
+
end
|
24
29
|
end
|
25
|
-
|
26
30
|
end
|
27
31
|
|
28
|
-
describe "
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
describe "#reset" do
|
33
|
+
describe "when there is a CC_BUILD_ARTIFACTS environment variable" do
|
34
|
+
before do
|
35
|
+
ENV["CC_BUILD_ARTIFACTS"] = "foo"
|
36
|
+
@config = MetricFu.configuration
|
37
|
+
@config.reset
|
38
|
+
MetricFu.configure
|
39
|
+
end
|
40
|
+
it "should return the CC_BUILD_ARTIFACTS environment variable" do
|
41
|
+
compare_paths(base_directory, ENV["CC_BUILD_ARTIFACTS"])
|
42
|
+
end
|
43
|
+
after do
|
44
|
+
ENV["CC_BUILD_ARTIFACTS"] = nil
|
45
|
+
FileUtils.rm_rf(File.join(MetricFu.root_dir, "foo"))
|
46
|
+
end
|
33
47
|
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "#reset" do
|
38
48
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
describe "when there is no CC_BUILD_ARTIFACTS environment variable" do
|
50
|
+
before(:each) do
|
51
|
+
ENV["CC_BUILD_ARTIFACTS"] = nil
|
52
|
+
get_new_config
|
53
|
+
end
|
54
|
+
it "should return 'tmp/metric_fu'" do
|
55
|
+
expect(base_directory).to eq(MetricFu.artifact_dir)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should set @metric_fu_root_directory to the base of the "\
|
59
|
+
"metric_fu application" do
|
60
|
+
app_root = File.join(File.dirname(__FILE__), "..", "..")
|
61
|
+
app_root_absolute_path = File.expand_path(app_root)
|
62
|
+
metric_fu_absolute_path = File.expand_path(metric_fu_root)
|
63
|
+
expect(metric_fu_absolute_path).to eq(app_root_absolute_path)
|
64
|
+
expect(MetricFu.root.to_s).to eq(app_root_absolute_path)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should set @scratch_directory to scratch relative "\
|
68
|
+
"to @base_directory" do
|
69
|
+
scratch_dir = MetricFu.scratch_dir
|
70
|
+
expect(scratch_directory).to eq(scratch_dir)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should set @output_directory to output relative "\
|
74
|
+
"to @base_directory" do
|
75
|
+
output_dir = MetricFu.output_dir
|
76
|
+
expect(output_directory).to eq(output_dir)
|
77
|
+
end
|
53
78
|
end
|
54
79
|
end
|
55
80
|
|
56
|
-
describe "
|
81
|
+
describe "#platform" do
|
82
|
+
before(:each) { get_new_config }
|
57
83
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
it "should return 'tmp/metric_fu'" do
|
63
|
-
expect(base_directory).to eq(MetricFu.artifact_dir)
|
84
|
+
it "should return the value of the PLATFORM constant" do
|
85
|
+
this_platform = RUBY_PLATFORM
|
86
|
+
expect(@config.platform).to eq(this_platform)
|
64
87
|
end
|
65
|
-
|
66
|
-
it "should set @metric_fu_root_directory to the base of the "\
|
67
|
-
"metric_fu application" do
|
68
|
-
app_root = File.join(File.dirname(__FILE__), "..", "..")
|
69
|
-
app_root_absolute_path = File.expand_path(app_root)
|
70
|
-
metric_fu_absolute_path = File.expand_path(metric_fu_root)
|
71
|
-
expect(metric_fu_absolute_path).to eq(app_root_absolute_path)
|
72
|
-
expect(MetricFu.root.to_s).to eq(app_root_absolute_path)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should set @scratch_directory to scratch relative "\
|
76
|
-
"to @base_directory" do
|
77
|
-
scratch_dir = MetricFu.scratch_dir
|
78
|
-
expect(scratch_directory).to eq(scratch_dir)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should set @output_directory to output relative "\
|
82
|
-
"to @base_directory" do
|
83
|
-
output_dir = MetricFu.output_dir
|
84
|
-
expect(output_directory).to eq(output_dir)
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
describe "#platform" do
|
92
|
-
|
93
|
-
before(:each) { get_new_config }
|
94
|
-
|
95
|
-
it "should return the value of the PLATFORM constant" do
|
96
|
-
this_platform = RUBY_PLATFORM
|
97
|
-
expect(@config.platform).to eq(this_platform)
|
98
88
|
end
|
99
89
|
end
|
100
|
-
|
101
|
-
end
|
102
90
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.data_structures_require {
|
2
|
+
MetricFu.data_structures_require { "line_numbers" }
|
3
3
|
|
4
4
|
describe MetricFu::LineNumbers do
|
5
5
|
FIXTURE_DATA = ->(paths) {
|
6
|
-
FIXTURE.load_file(
|
6
|
+
FIXTURE.load_file(["line_numbers"].concat(Array(paths)))
|
7
7
|
}
|
8
8
|
describe "in_method?" do
|
9
9
|
it "should know if a line is NOT in a method" do
|
@@ -51,7 +51,7 @@ describe MetricFu::LineNumbers do
|
|
51
51
|
|
52
52
|
it "should work with modules" do
|
53
53
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["module.rb"])
|
54
|
-
expect(ln.method_at_line(4)).to eq(
|
54
|
+
expect(ln.method_at_line(4)).to eq("KickAss#get_beat_up?")
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should work with module surrounding class" do
|
@@ -59,7 +59,5 @@ describe MetricFu::LineNumbers do
|
|
59
59
|
expect(ln.method_at_line(5)).to eq("StuffModule::ThingClass#do_it")
|
60
60
|
# ln.method_at_line(12).should == "StuffModule#blah" #why no work?
|
61
61
|
end
|
62
|
-
|
63
62
|
end
|
64
|
-
|
65
63
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.data_structures_require {
|
2
|
+
MetricFu.data_structures_require { "location" }
|
3
3
|
|
4
4
|
describe MetricFu::Location do
|
5
|
-
|
6
5
|
context "with non-standard Reek method names" do
|
7
6
|
# reek reports the method with :: not # on modules like
|
8
7
|
# module ApplicationHelper \n def signed_in?, convert it so it records correctly
|
@@ -13,33 +12,29 @@ describe MetricFu::Location do
|
|
13
12
|
end
|
14
13
|
|
15
14
|
it "has method name" do
|
16
|
-
expect(@location.method_name).to eq(
|
15
|
+
expect(@location.method_name).to eq("ApplicationHelper#section_link")
|
17
16
|
end
|
18
17
|
|
19
18
|
it "has nil file path" do
|
20
|
-
expect(@location.file_path).to
|
19
|
+
expect(@location.file_path).to eq(nil)
|
21
20
|
end
|
22
21
|
|
23
22
|
it "has class name" do
|
24
|
-
expect(@location.class_name).to
|
23
|
+
expect(@location.class_name).to eq("ApplicationHelper")
|
25
24
|
end
|
26
|
-
|
27
25
|
end
|
28
26
|
|
29
27
|
context "using new" do
|
30
|
-
|
31
28
|
before do
|
32
29
|
@location = Location.new("lib/foo.rb", "Foo", "Foo#some_method")
|
33
30
|
end
|
34
31
|
|
35
32
|
it "should return fully qualified method" do
|
36
|
-
expect(@location.method_name).to eq(
|
33
|
+
expect(@location.method_name).to eq("Foo#some_method")
|
37
34
|
end
|
38
|
-
|
39
35
|
end
|
40
36
|
|
41
37
|
context "using .for with class" do
|
42
|
-
|
43
38
|
before do
|
44
39
|
@location = Location.for("Module::Foo")
|
45
40
|
end
|
@@ -53,58 +48,49 @@ describe MetricFu::Location do
|
|
53
48
|
end
|
54
49
|
|
55
50
|
it "has class_name" do
|
56
|
-
expect(@location.class_name).to eq(
|
51
|
+
expect(@location.class_name).to eq("Foo")
|
57
52
|
end
|
58
|
-
|
59
53
|
end
|
60
54
|
|
61
55
|
context "using .for with method" do
|
62
|
-
|
63
56
|
before do
|
64
57
|
@location = Location.for("Module::Foo#some_method")
|
65
58
|
end
|
66
59
|
|
67
60
|
it "strips module from class name" do
|
68
|
-
expect(@location.class_name).to eq(
|
61
|
+
expect(@location.class_name).to eq("Foo")
|
69
62
|
end
|
70
63
|
|
71
64
|
it "strips module from method name" do
|
72
|
-
expect(@location.method_name).to eq(
|
65
|
+
expect(@location.method_name).to eq("Foo#some_method")
|
73
66
|
end
|
74
67
|
|
75
68
|
it "has nil file_path" do
|
76
69
|
expect(@location.file_path).to be nil
|
77
70
|
end
|
78
|
-
|
79
71
|
end
|
80
72
|
|
81
73
|
context "with class method" do
|
82
|
-
|
83
74
|
it "provides non-qualified name" do
|
84
75
|
location = Location.for("Foo.some_class_method")
|
85
|
-
expect(location.simple_method_name).to eq(
|
76
|
+
expect(location.simple_method_name).to eq(".some_class_method")
|
86
77
|
end
|
87
|
-
|
88
78
|
end
|
89
79
|
|
90
80
|
context "with instance method" do
|
91
|
-
|
92
81
|
it "provides non-qualified name" do
|
93
82
|
location = Location.for("Foo#some_class_method")
|
94
|
-
expect(location.simple_method_name).to eq(
|
83
|
+
expect(location.simple_method_name).to eq("#some_class_method")
|
95
84
|
end
|
96
|
-
|
97
85
|
end
|
98
|
-
|
86
|
+
context "testing equality" do
|
99
87
|
before :each do
|
100
|
-
|
101
|
-
@location1 = MetricFu::Location.get('/some/path','some_class','some_method')
|
88
|
+
@location1 = MetricFu::Location.get("/some/path", "some_class", "some_method")
|
102
89
|
|
103
90
|
# ensure that we get a new object
|
104
|
-
@location2 = MetricFu::Location.new(
|
91
|
+
@location2 = MetricFu::Location.new("/some/path", "some_class", "some_method")
|
105
92
|
end
|
106
93
|
it "should match two locations with the same paths as equal" do
|
107
|
-
|
108
94
|
hsh1 = {}
|
109
95
|
hsh1[@location1] = 1
|
110
96
|
|
@@ -117,12 +103,8 @@ describe MetricFu::Location do
|
|
117
103
|
expect(@location1.eql?(@location2)).to be_truthy
|
118
104
|
end
|
119
105
|
|
120
|
-
|
121
106
|
it "should produce the same hash value given the same paths" do
|
122
|
-
|
123
107
|
expect(@location1.hash).to eq(@location2.hash)
|
124
108
|
end
|
125
|
-
|
126
109
|
end
|
127
|
-
|
128
110
|
end
|
@@ -1,15 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
describe MetricFu::Configuration, 'for formatters' do
|
5
|
-
it_behaves_like 'configured' do
|
1
|
+
require "spec_helper"
|
2
|
+
require "shared/configured"
|
6
3
|
|
4
|
+
describe MetricFu::Configuration, "for formatters" do
|
5
|
+
it_behaves_like "configured" do
|
7
6
|
describe "#configure_formatter" do
|
8
7
|
before(:each) { get_new_config }
|
9
8
|
|
10
9
|
context "given a built-in formatter" do
|
11
10
|
before do
|
12
|
-
@config.configure_formatter(
|
11
|
+
@config.configure_formatter("html")
|
13
12
|
end
|
14
13
|
|
15
14
|
it "adds to the list of formatters" do
|
@@ -19,8 +18,8 @@ describe MetricFu::Configuration, 'for formatters' do
|
|
19
18
|
|
20
19
|
context "given a custom formatter by class name" do
|
21
20
|
before do
|
22
|
-
stub_const(
|
23
|
-
@config.configure_formatter(
|
21
|
+
stub_const("MyCustomFormatter", Class.new { def initialize(*); end })
|
22
|
+
@config.configure_formatter("MyCustomFormatter")
|
24
23
|
end
|
25
24
|
|
26
25
|
it "adds to the list of formatters" do
|
@@ -30,10 +29,10 @@ describe MetricFu::Configuration, 'for formatters' do
|
|
30
29
|
|
31
30
|
context "given multiple formatters" do
|
32
31
|
before do
|
33
|
-
stub_const(
|
34
|
-
@config.configure_formatter(
|
35
|
-
@config.configure_formatter(
|
36
|
-
@config.configure_formatter(
|
32
|
+
stub_const("MyCustomFormatter", Class.new { def initialize(*); end })
|
33
|
+
@config.configure_formatter("html")
|
34
|
+
@config.configure_formatter("yaml")
|
35
|
+
@config.configure_formatter("MyCustomFormatter")
|
37
36
|
end
|
38
37
|
|
39
38
|
it "adds each to the list of formatters" do
|
@@ -41,6 +40,5 @@ describe MetricFu::Configuration, 'for formatters' do
|
|
41
40
|
end
|
42
41
|
end
|
43
42
|
end
|
44
|
-
|
45
43
|
end
|
46
44
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.formatter_require {
|
2
|
+
MetricFu.formatter_require { "html" }
|
3
3
|
|
4
4
|
describe MetricFu::Formatter::HTML do
|
5
|
-
|
6
5
|
before do
|
7
6
|
setup_fs
|
8
7
|
|
@@ -12,14 +11,14 @@ describe MetricFu::Formatter::HTML do
|
|
12
11
|
# for some platforms.
|
13
12
|
config = MetricFu.configuration
|
14
13
|
if config.mri?
|
15
|
-
|
14
|
+
@metric_with_graph = :cane
|
16
15
|
else
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
@metric_with_graph = :stats
|
17
|
+
config.templates_configuration do |c|
|
18
|
+
c.syntax_highlighting = false
|
19
|
+
end
|
21
20
|
end
|
22
|
-
allow(MetricFu::Metric.get_metric(@metric_with_graph)).to receive(:run_external).and_return(
|
21
|
+
allow(MetricFu::Metric.get_metric(@metric_with_graph)).to receive(:run_external).and_return("")
|
23
22
|
@metric_without_graph = :hotspots
|
24
23
|
config.configure_metrics.each do |metric|
|
25
24
|
metric.enabled = true if [@metric_with_graph, @metric_without_graph].include?(metric.name)
|
@@ -34,30 +33,29 @@ describe MetricFu::Formatter::HTML do
|
|
34
33
|
end
|
35
34
|
|
36
35
|
context "In general" do
|
37
|
-
|
38
36
|
it "creates a report yaml file" do
|
39
37
|
# For backward compatibility.
|
40
38
|
expect {
|
41
|
-
|
39
|
+
MetricFu::Formatter::HTML.new.finish
|
42
40
|
}.to create_file("#{directory('base_directory')}/report.yml")
|
43
41
|
end
|
44
42
|
|
45
43
|
it "creates a data yaml file" do
|
46
44
|
# For use with graphs.
|
47
45
|
expect {
|
48
|
-
|
46
|
+
MetricFu::Formatter::HTML.new.finish
|
49
47
|
}.to create_file("#{directory('data_directory')}/#{MetricFu.report_id}.yml")
|
50
48
|
end
|
51
49
|
|
52
50
|
it "creates a report index html file" do
|
53
51
|
expect {
|
54
|
-
|
52
|
+
MetricFu::Formatter::HTML.new.finish
|
55
53
|
}.to create_file("#{directory('output_directory')}/index.html")
|
56
54
|
end
|
57
55
|
|
58
56
|
it "creates templatized html files for each metric" do
|
59
57
|
expect {
|
60
|
-
|
58
|
+
MetricFu::Formatter::HTML.new.finish
|
61
59
|
}.to create_files([
|
62
60
|
"#{directory('output_directory')}/#{@metric_with_graph}.html",
|
63
61
|
"#{directory('output_directory')}/#{@metric_without_graph}.html"
|
@@ -66,46 +64,43 @@ describe MetricFu::Formatter::HTML do
|
|
66
64
|
|
67
65
|
it "copies common javascripts to the output directory" do
|
68
66
|
expect {
|
69
|
-
|
67
|
+
MetricFu::Formatter::HTML.new.finish
|
70
68
|
}.to create_file("#{directory('output_directory')}/highcharts*.js")
|
71
69
|
end
|
72
70
|
|
73
71
|
it "creates graphs for appropriate metrics" do
|
74
72
|
expect {
|
75
|
-
|
73
|
+
MetricFu::Formatter::HTML.new.finish
|
76
74
|
}.to create_files([
|
77
75
|
"#{directory('output_directory')}/#{@metric_with_graph}.js",
|
78
76
|
])
|
79
77
|
end
|
80
78
|
|
81
|
-
|
82
79
|
it "can open the results in the browser" do
|
83
80
|
allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
|
84
81
|
formatter = MetricFu::Formatter::HTML.new
|
85
|
-
path = MetricFu.run_path.join(directory(
|
86
|
-
uri = URI.join(URI.escape("file://#{path}/"),
|
82
|
+
path = MetricFu.run_path.join(directory("output_directory"))
|
83
|
+
uri = URI.join(URI.escape("file://#{path}/"), "index.html")
|
87
84
|
expect(Launchy).to receive(:open).with(uri)
|
88
85
|
formatter.finish
|
89
86
|
formatter.display_results
|
90
87
|
end
|
91
|
-
|
92
88
|
end
|
93
89
|
|
94
90
|
context "given a custom output directory" do
|
95
|
-
|
96
91
|
before do
|
97
|
-
@output =
|
92
|
+
@output = "customdir"
|
98
93
|
end
|
99
94
|
|
100
95
|
it "creates the report index html file in the custom output directory" do
|
101
96
|
expect {
|
102
|
-
|
97
|
+
MetricFu::Formatter::HTML.new(output: @output).finish
|
103
98
|
}.to create_file("#{directory('base_directory')}/#{@output}/index.html")
|
104
99
|
end
|
105
100
|
|
106
101
|
it "creates templatized html files for each metric in the custom output directory" do
|
107
102
|
expect {
|
108
|
-
|
103
|
+
MetricFu::Formatter::HTML.new(output: @output).finish
|
109
104
|
}.to create_files([
|
110
105
|
"#{directory('base_directory')}/#{@output}/#{@metric_with_graph}.html",
|
111
106
|
"#{directory('base_directory')}/#{@output}/#{@metric_without_graph}.html"
|
@@ -114,13 +109,13 @@ describe MetricFu::Formatter::HTML do
|
|
114
109
|
|
115
110
|
it "copies common javascripts to the custom output directory" do
|
116
111
|
expect {
|
117
|
-
|
112
|
+
MetricFu::Formatter::HTML.new(output: @output).finish
|
118
113
|
}.to create_file("#{directory('base_directory')}/#{@output}/highcharts*.js")
|
119
114
|
end
|
120
115
|
|
121
116
|
it "creates graphs for appropriate metrics in the custom output directory " do
|
122
117
|
expect {
|
123
|
-
|
118
|
+
MetricFu::Formatter::HTML.new(output: @output).finish
|
124
119
|
}.to create_file(
|
125
120
|
"#{directory('base_directory')}/#{@output}/#{@metric_with_graph}.js",
|
126
121
|
)
|
@@ -130,16 +125,14 @@ describe MetricFu::Formatter::HTML do
|
|
130
125
|
allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
|
131
126
|
formatter = MetricFu::Formatter::HTML.new(output: @output)
|
132
127
|
path = MetricFu.run_path.join("#{directory('base_directory')}/#{@output}")
|
133
|
-
uri = URI.join(URI.escape("file://#{path}/"),
|
128
|
+
uri = URI.join(URI.escape("file://#{path}/"), "index.html")
|
134
129
|
expect(Launchy).to receive(:open).with(uri)
|
135
130
|
formatter.finish
|
136
131
|
formatter.display_results
|
137
132
|
end
|
138
|
-
|
139
133
|
end
|
140
134
|
|
141
135
|
after do
|
142
136
|
cleanup_fs
|
143
137
|
end
|
144
|
-
|
145
138
|
end
|