metric_fu 4.2.1 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.metrics +19 -1
- data/.travis.yml +2 -2
- data/Gemfile +2 -1
- data/HISTORY.md +24 -0
- data/README.md +60 -1
- data/TODO.md +1 -0
- data/bin/mf-saikuro +8 -0
- data/checksum/metric_fu-4.3.0.gem.sha512 +1 -0
- data/gemfiles/Gemfile.travis +9 -0
- data/lib/metric_fu.rb +1 -1
- data/lib/metric_fu/cli/client.rb +2 -2
- data/lib/metric_fu/cli/helper.rb +3 -3
- data/lib/metric_fu/cli/parser.rb +37 -16
- data/lib/metric_fu/configuration.rb +9 -1
- data/lib/metric_fu/constantize.rb +57 -0
- data/lib/metric_fu/data_structures/line_numbers.rb +19 -3
- data/lib/metric_fu/data_structures/location.rb +8 -3
- data/lib/metric_fu/formatter.rb +24 -0
- data/lib/metric_fu/formatter/html.rb +91 -0
- data/lib/metric_fu/formatter/yaml.rb +18 -0
- data/lib/metric_fu/initial_requires.rb +0 -1
- data/lib/metric_fu/io.rb +69 -0
- data/lib/metric_fu/load_files.rb +5 -2
- data/lib/metric_fu/logging/mf_debugger.rb +23 -0
- data/lib/metric_fu/metrics/base_template.rb +10 -4
- data/lib/metric_fu/metrics/cane/cane.rb +2 -1
- data/lib/metric_fu/metrics/cane/cane_bluff_grapher.rb +10 -9
- data/lib/metric_fu/metrics/cane/cane_gchart_grapher.rb +25 -0
- data/lib/metric_fu/metrics/flay/flay_bluff_grapher.rb +10 -9
- data/lib/metric_fu/metrics/flay/flay_gchart_grapher.rb +14 -11
- data/lib/metric_fu/metrics/flog/flog_bluff_grapher.rb +11 -10
- data/lib/metric_fu/metrics/flog/flog_gchart_grapher.rb +22 -15
- data/lib/metric_fu/metrics/generator.rb +10 -10
- data/lib/metric_fu/metrics/graph.rb +2 -2
- data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +3 -3
- data/lib/metric_fu/metrics/hotspots/hotspot.rb +4 -3
- data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +19 -10
- data/lib/metric_fu/metrics/hotspots/hotspots.rb +1 -1
- data/lib/metric_fu/metrics/hotspots/template_awesome/hotspots.html.erb +45 -45
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_bluff_grapher.rb +10 -9
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_gchart_grapher.rb +21 -15
- data/lib/metric_fu/metrics/rcov/rcov.rb +1 -1
- data/lib/metric_fu/metrics/rcov/rcov_bluff_grapher.rb +10 -9
- data/lib/metric_fu/metrics/rcov/rcov_gchart_grapher.rb +13 -8
- data/lib/metric_fu/metrics/reek/reek_bluff_grapher.rb +9 -13
- data/lib/metric_fu/metrics/reek/reek_gchart_grapher.rb +22 -17
- data/lib/metric_fu/metrics/roodi/roodi_bluff_grapher.rb +10 -9
- data/lib/metric_fu/metrics/roodi/roodi_gchart_grapher.rb +14 -11
- data/lib/metric_fu/metrics/saikuro/saikuro.rb +5 -34
- data/lib/metric_fu/metrics/stats/stats.rb +2 -1
- data/lib/metric_fu/metrics/stats/stats_bluff_grapher.rb +11 -10
- data/lib/metric_fu/metrics/stats/stats_gchart_grapher.rb +21 -14
- data/lib/metric_fu/reporter.rb +37 -0
- data/lib/metric_fu/reporting/graphs/engines/bluff.rb +20 -0
- data/lib/metric_fu/reporting/graphs/engines/gchart.rb +41 -3
- data/lib/metric_fu/reporting/graphs/grapher.rb +9 -2
- data/lib/metric_fu/reporting/result.rb +51 -0
- data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +8 -8
- data/lib/metric_fu/run.rb +34 -39
- data/lib/metric_fu/version.rb +1 -1
- data/lib/metric_fu_requires.rb +50 -33
- data/metric_fu.gemspec +30 -39
- data/spec/cli/helper_spec.rb +15 -0
- data/spec/metric_fu/configuration_spec.rb +40 -2
- data/spec/metric_fu/formatter/html_spec.rb +134 -0
- data/spec/metric_fu/formatter/yaml_spec.rb +59 -0
- data/spec/metric_fu/formatter_spec.rb +49 -0
- data/spec/metric_fu/metrics/base_template_spec.rb +23 -23
- data/spec/metric_fu/metrics/cane/cane_spec.rb +2 -2
- data/spec/metric_fu/metrics/churn/churn_spec.rb +1 -1
- data/spec/metric_fu/metrics/flay/flay_spec.rb +4 -4
- data/spec/metric_fu/metrics/flog/flog_spec.rb +7 -7
- data/spec/metric_fu/metrics/generator_spec.rb +21 -21
- data/spec/metric_fu/metrics/graph_spec.rb +9 -9
- data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +1 -1
- data/spec/metric_fu/metrics/rcov/rcov_spec.rb +8 -8
- data/spec/metric_fu/metrics/reek/reek_spec.rb +1 -1
- data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +5 -5
- data/spec/metric_fu/metrics/stats/stats_spec.rb +4 -4
- data/spec/metric_fu/reporter_spec.rb +41 -0
- data/spec/metric_fu/reporting/graphs/engines/gchart_spec.rb +7 -7
- data/spec/metric_fu/reporting/result_spec.rb +51 -0
- data/spec/run_spec.rb +167 -27
- data/spec/spec_helper.rb +1 -0
- data/spec/support/matcher_create_file.rb +7 -2
- data/spec/support/matcher_create_files.rb +41 -0
- data/spec/support/suite.rb +32 -0
- metadata +27 -6
- data/lib/metric_fu/reporting/report.rb +0 -111
- data/spec/metric_fu/reporting/report_spec.rb +0 -148
@@ -0,0 +1,134 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'fakefs/safe'
|
3
|
+
|
4
|
+
describe MetricFu::Formatter::HTML do
|
5
|
+
|
6
|
+
before do
|
7
|
+
setup_fs
|
8
|
+
|
9
|
+
# TODO: Use mock metrics?
|
10
|
+
# Right now, have to select from metrics
|
11
|
+
# based on platform, resulting in slow specs
|
12
|
+
# for some platforms.
|
13
|
+
@metric_with_graph = MetricFu.configuration.mri? ? :cane : :flay
|
14
|
+
@metric_without_graph = :hotspots
|
15
|
+
MetricFu.result.add(@metric_with_graph) # metric w/ graph
|
16
|
+
MetricFu.result.add(@metric_without_graph) # metric w/out graph
|
17
|
+
end
|
18
|
+
|
19
|
+
context "In general" do
|
20
|
+
|
21
|
+
it "creates a report yaml file" do
|
22
|
+
# For backward compatibility.
|
23
|
+
expect {
|
24
|
+
MetricFu::Formatter::HTML.new.finish
|
25
|
+
}.to create_file("#{MetricFu.base_directory}/report.yml")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "creates a data yaml file" do
|
29
|
+
# For use with graphs.
|
30
|
+
expect {
|
31
|
+
MetricFu::Formatter::HTML.new.finish
|
32
|
+
}.to create_file("#{MetricFu.data_directory}/#{Time.now.strftime("%Y%m%d")}.yml")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "creates a report index html file" do
|
36
|
+
expect {
|
37
|
+
MetricFu::Formatter::HTML.new.finish
|
38
|
+
}.to create_file("#{MetricFu.output_directory}/index.html")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "creates templatized html files for each metric" do
|
42
|
+
expect {
|
43
|
+
MetricFu::Formatter::HTML.new.finish
|
44
|
+
}.to create_files([
|
45
|
+
"#{MetricFu.output_directory}/#{@metric_with_graph}.html",
|
46
|
+
"#{MetricFu.output_directory}/#{@metric_without_graph}.html"
|
47
|
+
])
|
48
|
+
end
|
49
|
+
|
50
|
+
it "copies common javascripts to the output directory" do
|
51
|
+
expect {
|
52
|
+
MetricFu::Formatter::HTML.new.finish
|
53
|
+
}.to create_file("#{MetricFu.output_directory}/bluff*.js")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "creates graphs for appropriate metrics" do
|
57
|
+
expect {
|
58
|
+
MetricFu::Formatter::HTML.new.finish
|
59
|
+
}.to create_files([
|
60
|
+
"#{MetricFu.output_directory}/#{@metric_with_graph}.js",
|
61
|
+
])
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when on OS X' do
|
65
|
+
before do
|
66
|
+
MetricFu.configuration.stub(:platform).and_return('darwin')
|
67
|
+
end
|
68
|
+
|
69
|
+
it "can open the results in the browser" do
|
70
|
+
formatter = MetricFu::Formatter::HTML.new
|
71
|
+
formatter.should_receive(:system).with("open #{Pathname.pwd.join(MetricFu.output_directory).join('index.html')}")
|
72
|
+
formatter.finish
|
73
|
+
formatter.display_results
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
context "given a custom output directory" do
|
80
|
+
|
81
|
+
before do
|
82
|
+
@output = 'customdir'
|
83
|
+
end
|
84
|
+
|
85
|
+
it "creates the report index html file in the custom output directory" do
|
86
|
+
expect {
|
87
|
+
MetricFu::Formatter::HTML.new(output: @output).finish
|
88
|
+
}.to create_file("#{MetricFu.base_directory}/#{@output}/index.html")
|
89
|
+
end
|
90
|
+
|
91
|
+
it "creates templatized html files for each metric in the custom output directory" do
|
92
|
+
expect {
|
93
|
+
MetricFu::Formatter::HTML.new(output: @output).finish
|
94
|
+
}.to create_files([
|
95
|
+
"#{MetricFu.base_directory}/#{@output}/#{@metric_with_graph}.html",
|
96
|
+
"#{MetricFu.base_directory}/#{@output}/#{@metric_without_graph}.html"
|
97
|
+
])
|
98
|
+
end
|
99
|
+
|
100
|
+
it "copies common javascripts to the custom output directory" do
|
101
|
+
expect {
|
102
|
+
MetricFu::Formatter::HTML.new(output: @output).finish
|
103
|
+
}.to create_file("#{MetricFu.base_directory}/#{@output}/bluff*.js")
|
104
|
+
end
|
105
|
+
|
106
|
+
it "creates graphs for appropriate metrics in the custom output directory " do
|
107
|
+
expect {
|
108
|
+
MetricFu::Formatter::HTML.new(output: @output).finish
|
109
|
+
}.to create_file(
|
110
|
+
"#{MetricFu.base_directory}/#{@output}/#{@metric_with_graph}.js",
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'when on OS X' do
|
115
|
+
before do
|
116
|
+
MetricFu.configuration.stub(:platform).and_return('darwin')
|
117
|
+
end
|
118
|
+
|
119
|
+
it "can open the results in the browser from the custom output directory" do
|
120
|
+
formatter = MetricFu::Formatter::HTML.new(output: @output)
|
121
|
+
path = Pathname.pwd.join("#{MetricFu.base_directory}/#{@output}/index.html")
|
122
|
+
formatter.should_receive(:system).with("open #{path}")
|
123
|
+
formatter.finish
|
124
|
+
formatter.display_results
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
after do
|
131
|
+
cleanup_fs
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'fakefs/safe'
|
3
|
+
|
4
|
+
describe MetricFu::Formatter::YAML do
|
5
|
+
|
6
|
+
before do
|
7
|
+
setup_fs
|
8
|
+
|
9
|
+
@metric1 = MetricFu.configuration.mri? ? :cane : :flay
|
10
|
+
@metric2 = :hotspots
|
11
|
+
MetricFu.result.add(@metric1)
|
12
|
+
MetricFu.result.add(@metric2)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "In general" do
|
16
|
+
|
17
|
+
it "creates a report yaml file" do
|
18
|
+
expect {
|
19
|
+
MetricFu::Formatter::YAML.new.finish
|
20
|
+
}.to create_file("#{MetricFu.base_directory}/report.yml")
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
context "given a custom output file" do
|
26
|
+
|
27
|
+
before do
|
28
|
+
@output = "customreport.yml"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "creates a report yaml file to the custom output path" do
|
32
|
+
expect {
|
33
|
+
MetricFu::Formatter::YAML.new(output: @output).finish
|
34
|
+
}.to create_file("#{MetricFu.base_directory}/customreport.yml")
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
context "given a custom output stream" do
|
40
|
+
|
41
|
+
before do
|
42
|
+
@output = $stdout
|
43
|
+
end
|
44
|
+
|
45
|
+
it "creates a report yaml in the custom stream" do
|
46
|
+
out = MfDebugger::Logger.capture_output {
|
47
|
+
MetricFu::Formatter::YAML.new(output: @output).finish
|
48
|
+
}
|
49
|
+
out.should include ":#{@metric1}:"
|
50
|
+
out.should include ":#{@metric2}:"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
after do
|
56
|
+
cleanup_fs
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe MetricFu::Formatter do
|
4
|
+
describe "formatter class loading" do
|
5
|
+
context 'given a built-in formatter (string)' do
|
6
|
+
subject { MetricFu::Formatter.class_for('html') }
|
7
|
+
|
8
|
+
it 'returns the formatter class' do
|
9
|
+
subject.should eq(MetricFu::Formatter::HTML)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'given a built-in formatter (symbol)' do
|
14
|
+
subject { MetricFu::Formatter.class_for(:yaml) }
|
15
|
+
|
16
|
+
it 'returns the formatter class' do
|
17
|
+
subject.should eq(MetricFu::Formatter::YAML)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'given an unknown built-in formatter' do
|
22
|
+
subject { MetricFu::Formatter.class_for(:unknown) }
|
23
|
+
|
24
|
+
it 'raises an error' do
|
25
|
+
lambda{ subject }.should raise_error(NameError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'given a custom formatter that exists' do
|
30
|
+
subject { MetricFu::Formatter.class_for('MyCustomFormatter') }
|
31
|
+
|
32
|
+
before do
|
33
|
+
stub_const('MyCustomFormatter', Class.new() { def initialize(*);end })
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns the formatter class' do
|
37
|
+
subject.should eq(MyCustomFormatter)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'given a custom formatter that doesnt exist' do
|
42
|
+
subject { MetricFu::Formatter.class_for('MyNonExistentCustomFormatter') }
|
43
|
+
|
44
|
+
it 'raises an error' do
|
45
|
+
lambda{ subject }.should raise_error(NameError)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -10,8 +10,8 @@ describe MetricFu::Template do
|
|
10
10
|
describe "#erbify" do
|
11
11
|
it 'should evaluate a erb doc' do
|
12
12
|
section = 'section'
|
13
|
-
File.stub
|
14
|
-
erb =
|
13
|
+
File.stub(:read).and_return('foo')
|
14
|
+
erb = double('erb')
|
15
15
|
erb.should_receive(:result)
|
16
16
|
ERB.should_receive(:new).with('foo').and_return(erb)
|
17
17
|
@template.should_receive(:template).and_return('foo')
|
@@ -22,7 +22,7 @@ describe MetricFu::Template do
|
|
22
22
|
describe "#template_exists? " do
|
23
23
|
|
24
24
|
before(:each) do
|
25
|
-
@section =
|
25
|
+
@section = double('section')
|
26
26
|
@template.should_receive(:template).
|
27
27
|
with(@section).and_return(@section)
|
28
28
|
end
|
@@ -55,8 +55,8 @@ describe MetricFu::Template do
|
|
55
55
|
|
56
56
|
describe "#template" do
|
57
57
|
it 'should generate the filename of the template file' do
|
58
|
-
section =
|
59
|
-
section.
|
58
|
+
section = double('section')
|
59
|
+
section.stub(:to_s).and_return('section')
|
60
60
|
@template.should_receive(:template_directory).and_return('dir')
|
61
61
|
result = @template.send(:template, section)
|
62
62
|
result.should == "dir/section.html.erb"
|
@@ -65,7 +65,7 @@ describe MetricFu::Template do
|
|
65
65
|
|
66
66
|
describe "#output_filename" do
|
67
67
|
it 'should generate the filename of the output file' do
|
68
|
-
section =
|
68
|
+
section = double('section')
|
69
69
|
section.should_receive(:to_s).and_return('section')
|
70
70
|
result = @template.send(:output_filename, section)
|
71
71
|
result.should == "section.html"
|
@@ -76,7 +76,7 @@ describe MetricFu::Template do
|
|
76
76
|
it 'should return the contents of a css file' do
|
77
77
|
css = 'mycss.css'
|
78
78
|
@template.should_receive(:template_directory).and_return('dir')
|
79
|
-
io =
|
79
|
+
io = double('io', :read => "css contents")
|
80
80
|
@template.should_receive(:open).and_yield(io)
|
81
81
|
result = @template.send(:inline_css, css)
|
82
82
|
result.should == 'css contents'
|
@@ -86,11 +86,11 @@ describe MetricFu::Template do
|
|
86
86
|
describe "#link_to_filename " do
|
87
87
|
describe "when on OS X" do
|
88
88
|
before(:each) do
|
89
|
-
config =
|
90
|
-
config.stub
|
91
|
-
config.stub
|
92
|
-
config.stub
|
93
|
-
MetricFu.stub
|
89
|
+
config = double("configuration")
|
90
|
+
config.stub(:platform).and_return('universal-darwin-9.0')
|
91
|
+
config.stub(:darwin_txmt_protocol_no_thanks).and_return(false)
|
92
|
+
config.stub(:link_prefix).and_return(nil)
|
93
|
+
MetricFu.stub(:configuration).and_return(config)
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'should return a textmate protocol link' do
|
@@ -116,11 +116,11 @@ describe MetricFu::Template do
|
|
116
116
|
|
117
117
|
describe "but no thanks for txtmt" do
|
118
118
|
before(:each) do
|
119
|
-
config =
|
120
|
-
config.stub
|
121
|
-
config.stub
|
122
|
-
config.stub
|
123
|
-
MetricFu.stub
|
119
|
+
config = double("configuration")
|
120
|
+
config.stub(:platform).and_return('universal-darwin-9.0')
|
121
|
+
config.stub(:darwin_txmt_protocol_no_thanks).and_return(true)
|
122
|
+
config.stub(:link_prefix).and_return(nil)
|
123
|
+
MetricFu.stub(:configuration).and_return(config)
|
124
124
|
@template.should_receive(:complete_file_path).and_return('filename')
|
125
125
|
end
|
126
126
|
|
@@ -143,11 +143,11 @@ describe MetricFu::Template do
|
|
143
143
|
|
144
144
|
describe "when on other platforms" do
|
145
145
|
before(:each) do
|
146
|
-
config =
|
146
|
+
config = double("configuration")
|
147
147
|
config.should_receive(:platform).and_return('other')
|
148
|
-
config.stub
|
149
|
-
config.stub
|
150
|
-
MetricFu.stub
|
148
|
+
config.stub(:link_prefix).and_return(nil)
|
149
|
+
config.stub(:darwin_txmt_protocol_no_thanks).and_return(false)
|
150
|
+
MetricFu.stub(:configuration).and_return(config)
|
151
151
|
@template.should_receive(:complete_file_path).and_return('filename')
|
152
152
|
end
|
153
153
|
|
@@ -159,9 +159,9 @@ describe MetricFu::Template do
|
|
159
159
|
end
|
160
160
|
describe "when configured with a link_prefix" do
|
161
161
|
before(:each) do
|
162
|
-
config =
|
162
|
+
config = double("configuration")
|
163
163
|
config.should_receive(:link_prefix).and_return('http://example.org/files')
|
164
|
-
MetricFu.stub
|
164
|
+
MetricFu.stub(:configuration).and_return(config)
|
165
165
|
@template.should_receive(:complete_file_path).and_return('filename')
|
166
166
|
end
|
167
167
|
|
@@ -62,7 +62,7 @@ describe Cane do
|
|
62
62
|
describe "parse cane empty output" do
|
63
63
|
before :each do
|
64
64
|
MetricFu::Configuration.run {}
|
65
|
-
File.stub
|
65
|
+
File.stub(:directory?).and_return(true)
|
66
66
|
@cane = MetricFu::Cane.new('base_dir')
|
67
67
|
@cane.instance_variable_set(:@output, '')
|
68
68
|
end
|
@@ -80,7 +80,7 @@ describe Cane do
|
|
80
80
|
before :each do
|
81
81
|
lines = sample_cane_output
|
82
82
|
MetricFu::Configuration.run {}
|
83
|
-
File.stub
|
83
|
+
File.stub(:directory?).and_return(true)
|
84
84
|
@cane = MetricFu::Cane.new('base_dir')
|
85
85
|
@cane.instance_variable_set(:@output, lines)
|
86
86
|
end
|
@@ -7,7 +7,7 @@ describe Flay do
|
|
7
7
|
config.add_metric(:flay)
|
8
8
|
config.configure_metric(:flay, { :dirs_to_flay => ['app', 'lib'], :filetypes => ['rb'] })
|
9
9
|
}
|
10
|
-
File.stub
|
10
|
+
File.stub(:directory?).and_return(true)
|
11
11
|
@flay = MetricFu::Flay.new('base_dir')
|
12
12
|
|
13
13
|
@flay.should_receive(:`).with("mf-flay app lib")
|
@@ -19,7 +19,7 @@ describe Flay do
|
|
19
19
|
config.add_metric(:flay)
|
20
20
|
config.configure_metric(:flay, { :dirs_to_flay => [], :minimum_score => 99 })
|
21
21
|
}
|
22
|
-
File.stub
|
22
|
+
File.stub(:directory?).and_return(true)
|
23
23
|
@flay = MetricFu::Flay.new('base_dir')
|
24
24
|
|
25
25
|
@flay.should_receive(:`).with("mf-flay --mass 99 ")
|
@@ -44,7 +44,7 @@ Total score (lower is better) = 246
|
|
44
44
|
app/controllers/primary_sites_controller.rb:89
|
45
45
|
HERE
|
46
46
|
MetricFu::Configuration.run {}
|
47
|
-
File.stub
|
47
|
+
File.stub(:directory?).and_return(true)
|
48
48
|
@flay = MetricFu::Flay.new('base_dir')
|
49
49
|
@flay.instance_variable_set(:@output, lines)
|
50
50
|
end
|
@@ -88,7 +88,7 @@ Total score (lower is better) = 246
|
|
88
88
|
"app/controllers/bookmarklet_integration_controller.rb:17"]]
|
89
89
|
|
90
90
|
MetricFu::Configuration.run {}
|
91
|
-
File.stub
|
91
|
+
File.stub(:directory?).and_return(true)
|
92
92
|
flay = MetricFu::Flay.new('base_dir')
|
93
93
|
flay.instance_variable_set(:@matches, lines)
|
94
94
|
@results = flay.to_h
|
@@ -3,7 +3,7 @@ describe Flog do
|
|
3
3
|
if MetricFu.configuration.mri?
|
4
4
|
before :each do
|
5
5
|
MetricFu::Configuration.run {}
|
6
|
-
File.stub
|
6
|
+
File.stub(:directory?).and_return(true)
|
7
7
|
@flog = MetricFu::Flog.new('base_dir')
|
8
8
|
end
|
9
9
|
|
@@ -11,7 +11,7 @@ describe Flog do
|
|
11
11
|
it "should look for files and flog them" do
|
12
12
|
Dir.should_receive(:glob).with("lib/**/*.rb").and_return(["found/file.rb"])
|
13
13
|
::Flog.should_receive(:parse_options).with(["--all"]).and_return("options")
|
14
|
-
::Flog.should_receive(:new).with("options").and_return(flogger =
|
14
|
+
::Flog.should_receive(:new).with("options").and_return(flogger = double('flogger'))
|
15
15
|
flogger.should_receive(:flog).with(["found/file.rb"])
|
16
16
|
@flog.emit
|
17
17
|
end
|
@@ -22,7 +22,7 @@ describe Flog do
|
|
22
22
|
first_full_method_name = "ClassName#first_method_name"
|
23
23
|
second_full_method_name = "ClassName#second_method_name"
|
24
24
|
|
25
|
-
flogger =
|
25
|
+
flogger = double('flogger', :calls => {first_full_method_name => {:branch => 11.1, :puts => 1.1},
|
26
26
|
second_full_method_name => {:branch => 22.2, :puts => 2.2}},
|
27
27
|
:method_locations => {first_full_method_name => '/file/location.rb:11',
|
28
28
|
second_full_method_name => '/file/location.rb:22'},
|
@@ -53,11 +53,11 @@ describe Flog do
|
|
53
53
|
|
54
54
|
describe "to_h method" do
|
55
55
|
it "should make-a nice hash" do
|
56
|
-
flogger =
|
56
|
+
flogger = double('flogger', :total => 111.1, :average => 7.3)
|
57
57
|
@flog.instance_variable_set(:@flogger, flogger)
|
58
|
-
method_containers = {:ignore_me_1 =>
|
59
|
-
:ignore_me_2 =>
|
60
|
-
:ignore_me_3 =>
|
58
|
+
method_containers = {:ignore_me_1 => double('container_1', :highest_score => 11.1, :to_h => 'container_1'),
|
59
|
+
:ignore_me_2 => double('container_2', :highest_score => 33.3, :to_h => 'container_2'),
|
60
|
+
:ignore_me_3 => double('container_3', :highest_score => 22.2, :to_h => 'container_3')}
|
61
61
|
@flog.instance_variable_set(:@method_containers, method_containers)
|
62
62
|
|
63
63
|
expected = {:flog => { :total => 111.1,
|