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
@@ -0,0 +1,11 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe MetricFu::Templates::MetricsTemplate do
|
4
|
+
let(:template) { Templates::MetricsTemplate.new }
|
5
|
+
|
6
|
+
describe "#html_filename" do
|
7
|
+
it "returns the hashed filename ending with .html" do
|
8
|
+
expect(template.html_filename("some_file.rb")).to eq("10580a1fcbe74a931db8210462a584.html")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
MetricFu.lib_require {
|
1
|
+
require "spec_helper"
|
2
|
+
MetricFu.lib_require { "templates/report" }
|
3
3
|
|
4
4
|
describe MetricFu::Templates::Report do
|
5
5
|
# TODO: This test only shows how the code works and that it doesn't blow up.
|
6
6
|
# Perhaps it should test something more specific?
|
7
7
|
it "Reads in a source file, and produces an annotated HTML report" do
|
8
|
-
lines = {"2"=>[{:
|
9
|
-
source_file = File.join(MetricFu.root_dir,
|
8
|
+
lines = { "2" => [{ type: :reek, description: "Bad Param Names" }] }
|
9
|
+
source_file = File.join(MetricFu.root_dir, "spec", "dummy", "lib", "bad_encoding.rb")
|
10
10
|
report = MetricFu::Templates::Report.new(source_file, lines)
|
11
11
|
expect {
|
12
12
|
rendered_report = report.render
|
@@ -1,35 +1,33 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "tempfile"
|
3
|
+
require "erb"
|
4
4
|
|
5
5
|
describe MetricFu::Template do
|
6
|
-
|
7
6
|
before(:each) do
|
8
7
|
@template = Template.new
|
9
8
|
end
|
10
9
|
|
11
10
|
describe "#erbify" do
|
12
11
|
it "should evaluate a erb doc" do
|
13
|
-
section =
|
14
|
-
erb = double(
|
12
|
+
section = "section"
|
13
|
+
erb = double("erb")
|
15
14
|
expect(erb).to receive(:result)
|
16
|
-
expect(@template).to receive(:template).and_return(
|
17
|
-
expect(@template).to receive(:erb_template_source).with(
|
15
|
+
expect(@template).to receive(:template).and_return("foo")
|
16
|
+
expect(@template).to receive(:erb_template_source).with("foo").and_return(erb)
|
18
17
|
@template.send(:erbify, section)
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
21
|
describe "#template_exists? " do
|
23
|
-
|
24
22
|
before(:each) do
|
25
|
-
@section = double(
|
23
|
+
@section = double("section")
|
26
24
|
end
|
27
25
|
|
28
26
|
describe "if the template exists" do
|
29
27
|
it "should return true" do
|
30
|
-
Tempfile.open(
|
28
|
+
Tempfile.open("file") do |file|
|
31
29
|
expect(@template).to receive(:template).with(@section).and_return(file.path)
|
32
|
-
result = @template.send(:template_exists
|
30
|
+
result = @template.send(:template_exists?, @section)
|
33
31
|
expect(result).to be_truthy
|
34
32
|
end
|
35
33
|
end
|
@@ -37,9 +35,9 @@ describe MetricFu::Template do
|
|
37
35
|
|
38
36
|
describe "if the template does not exist" do
|
39
37
|
it "should return false" do
|
40
|
-
path =
|
38
|
+
path = "path"
|
41
39
|
expect(@template).to receive(:template).with(@section).and_return(path)
|
42
|
-
result = @template.send(:template_exists
|
40
|
+
result = @template.send(:template_exists?, @section)
|
43
41
|
expect(result).to be_falsey
|
44
42
|
end
|
45
43
|
end
|
@@ -47,8 +45,8 @@ describe MetricFu::Template do
|
|
47
45
|
|
48
46
|
describe "#create_instance_var" do
|
49
47
|
it "should set an instance variable with the passed contents" do
|
50
|
-
section =
|
51
|
-
contents =
|
48
|
+
section = "section"
|
49
|
+
contents = "contents"
|
52
50
|
@template.send(:create_instance_var, section, contents)
|
53
51
|
expect(@template.instance_variable_get(:@section)).to eq(contents)
|
54
52
|
end
|
@@ -56,9 +54,9 @@ describe MetricFu::Template do
|
|
56
54
|
|
57
55
|
describe "#template" do
|
58
56
|
it "should generate the filename of the template file" do
|
59
|
-
section = double(
|
60
|
-
allow(section).to receive(:to_s).and_return(
|
61
|
-
expect(@template).to receive(:template_directory).and_return(
|
57
|
+
section = double("section")
|
58
|
+
allow(section).to receive(:to_s).and_return("section")
|
59
|
+
expect(@template).to receive(:template_directory).and_return("dir")
|
62
60
|
result = @template.send(:template, section)
|
63
61
|
expect(result).to eq("dir/section.html.erb")
|
64
62
|
end
|
@@ -66,8 +64,8 @@ describe MetricFu::Template do
|
|
66
64
|
|
67
65
|
describe "#output_filename" do
|
68
66
|
it "should generate the filename of the output file" do
|
69
|
-
section = double(
|
70
|
-
expect(section).to receive(:to_s).and_return(
|
67
|
+
section = double("section")
|
68
|
+
expect(section).to receive(:to_s).and_return("section")
|
71
69
|
result = @template.send(:output_filename, section)
|
72
70
|
expect(result).to eq("section.html")
|
73
71
|
end
|
@@ -75,8 +73,8 @@ describe MetricFu::Template do
|
|
75
73
|
|
76
74
|
describe "#inline_css" do
|
77
75
|
it "should return the contents of a css file" do
|
78
|
-
css =
|
79
|
-
dir = File.join(MetricFu.lib_dir,
|
76
|
+
css = "mycss.css"
|
77
|
+
dir = File.join(MetricFu.lib_dir, "templates", css)
|
80
78
|
contents = "css contents"
|
81
79
|
expect(MetricFu::Utility).to receive(:binread).with(dir).and_return(contents)
|
82
80
|
result = @template.send(:inline_css, css)
|
@@ -89,29 +87,29 @@ describe MetricFu::Template do
|
|
89
87
|
before(:each) do
|
90
88
|
config = double("configuration")
|
91
89
|
allow(config).to receive(:osx?).and_return(true)
|
92
|
-
allow(config).to receive(:platform).and_return(
|
93
|
-
allow(config).to receive(:templates_option).with(
|
94
|
-
allow(config).to receive(:templates_option).with(
|
90
|
+
allow(config).to receive(:platform).and_return("universal-darwin-9.0")
|
91
|
+
allow(config).to receive(:templates_option).with("darwin_txmt_protocol_no_thanks").and_return(false)
|
92
|
+
allow(config).to receive(:templates_option).with("link_prefix").and_return(nil)
|
95
93
|
allow(MetricFu).to receive(:configuration).and_return(config)
|
96
94
|
end
|
97
95
|
|
98
96
|
it "should return a textmate protocol link" do
|
99
|
-
expect(@template).to receive(:complete_file_path).with(
|
100
|
-
result = @template.send(:link_to_filename,
|
97
|
+
expect(@template).to receive(:complete_file_path).with("filename").and_return("/expanded/filename")
|
98
|
+
result = @template.send(:link_to_filename, "filename")
|
101
99
|
expect(result).to eql("<a href='txmt://open/?url=file://" \
|
102
100
|
+ "/expanded/filename'>filename</a>")
|
103
101
|
end
|
104
102
|
|
105
103
|
it "should do the right thing with a filename that starts with a slash" do
|
106
|
-
expect(@template).to receive(:complete_file_path).with(
|
107
|
-
result = @template.send(:link_to_filename,
|
104
|
+
expect(@template).to receive(:complete_file_path).with("/filename").and_return("/expanded/filename")
|
105
|
+
result = @template.send(:link_to_filename, "/filename")
|
108
106
|
expect(result).to eql("<a href='txmt://open/?url=file://" \
|
109
107
|
+ "/expanded/filename'>/filename</a>")
|
110
108
|
end
|
111
109
|
|
112
110
|
it "should include a line number" do
|
113
|
-
expect(@template).to receive(:complete_file_path).with(
|
114
|
-
result = @template.send(:link_to_filename,
|
111
|
+
expect(@template).to receive(:complete_file_path).with("filename").and_return("/expanded/filename")
|
112
|
+
result = @template.send(:link_to_filename, "filename", 6)
|
115
113
|
expect(result).to eql("<a href='txmt://open/?url=file://" \
|
116
114
|
+ "/expanded/filename&line=6'>filename:6</a>")
|
117
115
|
end
|
@@ -120,11 +118,11 @@ describe MetricFu::Template do
|
|
120
118
|
before(:each) do
|
121
119
|
config = double("configuration")
|
122
120
|
allow(config).to receive(:osx?).and_return(true)
|
123
|
-
allow(config).to receive(:platform).and_return(
|
124
|
-
allow(config).to receive(:templates_option).with(
|
125
|
-
allow(config).to receive(:templates_option).with(
|
121
|
+
allow(config).to receive(:platform).and_return("universal-darwin-9.0")
|
122
|
+
allow(config).to receive(:templates_option).with("darwin_txmt_protocol_no_thanks").and_return(true)
|
123
|
+
allow(config).to receive(:templates_option).with("link_prefix").and_return("file:/")
|
126
124
|
allow(MetricFu).to receive(:configuration).and_return(config)
|
127
|
-
expect(@template).to receive(:complete_file_path).and_return(
|
125
|
+
expect(@template).to receive(:complete_file_path).and_return("filename")
|
128
126
|
end
|
129
127
|
|
130
128
|
it "should return a file protocol link" do
|
@@ -136,8 +134,8 @@ describe MetricFu::Template do
|
|
136
134
|
|
137
135
|
describe "and given link text" do
|
138
136
|
it "should use the submitted link text" do
|
139
|
-
expect(@template).to receive(:complete_file_path).with(
|
140
|
-
result = @template.send(:link_to_filename,
|
137
|
+
expect(@template).to receive(:complete_file_path).with("filename").and_return("/expanded/filename")
|
138
|
+
result = @template.send(:link_to_filename, "filename", 6, "link content")
|
141
139
|
expect(result).to eql("<a href='txmt://open/?url=file://" \
|
142
140
|
+ "/expanded/filename&line=6'>link content</a>")
|
143
141
|
end
|
@@ -148,9 +146,9 @@ describe MetricFu::Template do
|
|
148
146
|
before(:each) do
|
149
147
|
config = double("configuration")
|
150
148
|
expect(config).to receive(:osx?).and_return(false)
|
151
|
-
allow(config).to receive(:templates_option).with(
|
149
|
+
allow(config).to receive(:templates_option).with("link_prefix").and_return("file:/")
|
152
150
|
allow(MetricFu).to receive(:configuration).and_return(config)
|
153
|
-
expect(@template).to receive(:complete_file_path).and_return(
|
151
|
+
expect(@template).to receive(:complete_file_path).and_return("filename")
|
154
152
|
end
|
155
153
|
|
156
154
|
it "should return a file protocol link" do
|
@@ -162,11 +160,11 @@ describe MetricFu::Template do
|
|
162
160
|
describe "when configured with a link_prefix" do
|
163
161
|
before(:each) do
|
164
162
|
config = double("configuration")
|
165
|
-
allow(config).to receive(:templates_option).with(
|
166
|
-
allow(config).to receive(:templates_option).with(
|
163
|
+
allow(config).to receive(:templates_option).with("darwin_txmt_protocol_no_thanks").and_return(true)
|
164
|
+
allow(config).to receive(:templates_option).with("link_prefix").and_return("http://example.org/files")
|
167
165
|
allow(config).to receive(:osx?).and_return(true)
|
168
166
|
allow(MetricFu).to receive(:configuration).and_return(config)
|
169
|
-
expect(@template).to receive(:complete_file_path).and_return(
|
167
|
+
expect(@template).to receive(:complete_file_path).and_return("filename")
|
170
168
|
end
|
171
169
|
|
172
170
|
it "should return a http protocol link" do
|
@@ -175,6 +173,23 @@ describe MetricFu::Template do
|
|
175
173
|
expect(result).to eq("<a href='http://example.org/files/filename'>filename</a>")
|
176
174
|
end
|
177
175
|
end
|
176
|
+
|
177
|
+
context "given an absolute path" do
|
178
|
+
it "returns a link with that absolute path" do
|
179
|
+
name = "/some/file.rb"
|
180
|
+
result = @template.send(:link_to_filename, name)
|
181
|
+
expect(result).to eq("<a href='file:///some/file.rb'>/some/file.rb</a>")
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
context "given a relative path" do
|
186
|
+
it "returns a link with the absolute path" do
|
187
|
+
name = "./some/file.rb"
|
188
|
+
expected = File.expand_path(name)
|
189
|
+
result = @template.send(:link_to_filename, name)
|
190
|
+
expect(result).to eq("<a href='file://#{expected}'>./some/file.rb</a>")
|
191
|
+
end
|
192
|
+
end
|
178
193
|
end
|
179
194
|
|
180
195
|
describe "#cycle" do
|
@@ -197,23 +212,22 @@ describe MetricFu::Template do
|
|
197
212
|
|
198
213
|
describe "#render_partial" do
|
199
214
|
it "should erbify a partial with the name prefixed with an underscore" do
|
200
|
-
expect(@template).to receive(:erbify).with(
|
201
|
-
@template.send(:render_partial,
|
215
|
+
expect(@template).to receive(:erbify).with("_some_partial")
|
216
|
+
@template.send(:render_partial, "some_partial")
|
202
217
|
end
|
203
218
|
|
204
219
|
it "should set the given instance variables" do
|
205
|
-
variables = {:
|
220
|
+
variables = { answer: 42 }
|
206
221
|
allow(@template).to receive(:erbify)
|
207
222
|
expect(@template).to receive(:create_instance_vars).with(variables)
|
208
|
-
@template.send(:render_partial,
|
223
|
+
@template.send(:render_partial, "some_partial", variables)
|
209
224
|
end
|
210
225
|
end
|
211
226
|
|
212
227
|
describe "#create_instance_vars" do
|
213
228
|
it "should set the given instance variables" do
|
214
|
-
@template.send(:create_instance_vars,
|
229
|
+
@template.send(:create_instance_vars, answer: 42)
|
215
230
|
expect(@template.instance_variable_get(:@answer)).to eq(42)
|
216
231
|
end
|
217
232
|
end
|
218
|
-
|
219
233
|
end
|
data/spec/metric_fu_spec.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe MetricFu do
|
5
|
-
|
6
5
|
specify "the default report_name is the run directory base name" do
|
7
|
-
expect(MetricFu.report_name).to eq(
|
6
|
+
expect(MetricFu.report_name).to eq("dummy")
|
8
7
|
end
|
9
8
|
|
10
9
|
specify "the user can set the report_name" do
|
11
10
|
original_report_name = MetricFu.report_name
|
12
11
|
|
13
|
-
MetricFu.report_name =
|
14
|
-
expect(MetricFu.report_name).to eq(
|
12
|
+
MetricFu.report_name = "override"
|
13
|
+
expect(MetricFu.report_name).to eq("override")
|
15
14
|
|
16
15
|
MetricFu.report_name = original_report_name
|
17
16
|
end
|
@@ -25,11 +24,10 @@ describe MetricFu do
|
|
25
24
|
end
|
26
25
|
|
27
26
|
it "has a global report id" do
|
28
|
-
expect(MetricFu.report_id).to eq(Time.now.strftime(
|
27
|
+
expect(MetricFu.report_id).to eq(Time.now.strftime("%Y%m%d"))
|
29
28
|
end
|
30
29
|
|
31
30
|
it "has a global report fingerprint (corresponding to VCS code state)" do
|
32
31
|
expect(MetricFu.report_fingerprint.to_i - Time.now.to_i).to be_within(0.1).of(0)
|
33
32
|
end
|
34
|
-
|
35
33
|
end
|
data/spec/shared/configured.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
shared_examples
|
2
|
-
|
1
|
+
shared_examples "configured" do
|
3
2
|
def get_new_config
|
4
|
-
ENV[
|
3
|
+
ENV["CC_BUILD_ARTIFACTS"] = nil
|
5
4
|
@config = MetricFu.configuration
|
6
5
|
@config.reset
|
7
6
|
MetricFu.configuration.configure_metric(:rcov) do |rcov|
|
@@ -17,31 +16,30 @@ shared_examples 'configured' do
|
|
17
16
|
end
|
18
17
|
|
19
18
|
def base_directory
|
20
|
-
directory(
|
19
|
+
directory("base_directory")
|
21
20
|
end
|
22
21
|
|
23
22
|
def output_directory
|
24
|
-
directory(
|
23
|
+
directory("output_directory")
|
25
24
|
end
|
26
25
|
|
27
26
|
def scratch_directory
|
28
|
-
directory(
|
27
|
+
directory("scratch_directory")
|
29
28
|
end
|
30
29
|
|
31
30
|
def template_directory
|
32
|
-
directory(
|
31
|
+
directory("template_directory")
|
33
32
|
end
|
34
33
|
|
35
34
|
def template_class
|
36
|
-
MetricFu::Formatter::Templates.option(
|
35
|
+
MetricFu::Formatter::Templates.option("template_class")
|
37
36
|
end
|
38
37
|
|
39
38
|
def metric_fu_root
|
40
|
-
directory(
|
39
|
+
directory("root_directory")
|
41
40
|
end
|
42
41
|
|
43
42
|
def load_metric(metric)
|
44
|
-
load File.join(MetricFu.metrics_dir, metric,
|
43
|
+
load File.join(MetricFu.metrics_dir, metric, "metric.rb")
|
45
44
|
end
|
46
|
-
|
47
45
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
shared_examples "rcov test coverage generator" do |metric_name|
|
2
|
-
|
3
2
|
before do
|
4
3
|
setup_fs
|
5
4
|
MetricFu::Configuration.run do |config|
|
@@ -15,26 +14,25 @@ shared_examples "rcov test coverage generator" do |metric_name|
|
|
15
14
|
|
16
15
|
describe "emit" do
|
17
16
|
before :each do
|
18
|
-
options = {:
|
17
|
+
options = { external: nil }
|
19
18
|
@rcov = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
20
19
|
end
|
21
20
|
|
22
21
|
# TODO: should this be true of this metric?
|
23
22
|
it "should clear out previous output and make output folder" do
|
24
|
-
expect(MetricFu::Utility).to receive(:rm_rf).with(MetricFu::RcovGenerator.metric_directory, :
|
23
|
+
expect(MetricFu::Utility).to receive(:rm_rf).with(MetricFu::RcovGenerator.metric_directory, verbose: false)
|
25
24
|
expect(MetricFu::Utility).to receive(:mkdir_p).with(MetricFu::RcovGenerator.metric_directory)
|
26
25
|
@rcov.reset_output_location
|
27
26
|
end
|
28
|
-
|
29
27
|
end
|
30
28
|
|
31
29
|
def rcov_output
|
32
|
-
FIXTURE.load_file(
|
30
|
+
FIXTURE.load_file("rcov_output.txt")
|
33
31
|
end
|
34
32
|
|
35
33
|
describe "with rcov_output fed into" do
|
36
34
|
before :each do
|
37
|
-
options = {:
|
35
|
+
options = { external: nil }
|
38
36
|
@rcov = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
39
37
|
expect(@rcov).to receive(:load_output).and_return(rcov_output)
|
40
38
|
@files = @rcov.analyze
|
@@ -76,7 +74,7 @@ shared_examples "rcov test coverage generator" do |metric_name|
|
|
76
74
|
end
|
77
75
|
describe "with external configuration option set" do
|
78
76
|
before :each do
|
79
|
-
options = {:
|
77
|
+
options = { external: "coverage/rcov.txt" }
|
80
78
|
@rcov = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
81
79
|
end
|
82
80
|
|
@@ -89,11 +87,9 @@ shared_examples "rcov test coverage generator" do |metric_name|
|
|
89
87
|
expect(@rcov).to receive(:load_output).and_return(rcov_output)
|
90
88
|
@files = @rcov.analyze
|
91
89
|
end
|
92
|
-
|
93
90
|
end
|
94
91
|
|
95
92
|
after do
|
96
93
|
cleanup_fs
|
97
94
|
end
|
98
|
-
|
99
95
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
# add lib to the load path just like rubygems does
|
2
2
|
$:.unshift File.expand_path("../../lib", __FILE__)
|
3
|
-
require
|
3
|
+
require "simplecov"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
5
|
+
require "date"
|
6
|
+
require "test_construct"
|
7
|
+
require "json"
|
8
|
+
require "pry-nav"
|
9
9
|
|
10
|
-
require
|
10
|
+
require "metric_fu"
|
11
11
|
include MetricFu
|
12
12
|
def mf_log(msg); mf_debug(msg); end
|
13
13
|
|
14
14
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
15
15
|
# in spec/support/ and its subdirectories.
|
16
|
-
Dir[MetricFu.root_dir + "/spec/support/**/*.rb"].each {|f| require f}
|
16
|
+
Dir[MetricFu.root_dir + "/spec/support/**/*.rb"].each { |f| require f }
|
17
17
|
|
18
18
|
RSpec.configure do |config|
|
19
19
|
config.filter_run focus: true
|
20
20
|
config.run_all_when_everything_filtered = true
|
21
21
|
config.filter_run_excluding :slow unless ENV["SLOW_SPECS"]
|
22
|
-
config.fail_fast = ENV.include?(
|
22
|
+
config.fail_fast = ENV.include?("FAIL_FAST")
|
23
23
|
config.order = :rand
|
24
24
|
config.color = true
|
25
25
|
config.expect_with :rspec do |expectations|
|
@@ -34,7 +34,7 @@ RSpec.configure do |config|
|
|
34
34
|
# :all every it block
|
35
35
|
|
36
36
|
def run_dir
|
37
|
-
File.expand_path(
|
37
|
+
File.expand_path("dummy", File.dirname(__FILE__))
|
38
38
|
end
|
39
39
|
|
40
40
|
config.before(:suite) do
|