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
@@ -39,7 +39,7 @@ describe MetricFu::Generator do
|
|
39
39
|
describe "#create_metric_dir_if_missing " do
|
40
40
|
describe "when the metric_dir exists " do
|
41
41
|
it 'should not call mkdir_p on FileUtils' do
|
42
|
-
File.stub
|
42
|
+
File.stub(:directory?).and_return(true)
|
43
43
|
FileUtils.should_not_receive(:mkdir_p)
|
44
44
|
@concrete_class.create_metric_dir_if_missing
|
45
45
|
end
|
@@ -47,7 +47,7 @@ describe MetricFu::Generator do
|
|
47
47
|
|
48
48
|
describe "when the metric_dir does not exist " do
|
49
49
|
it 'should call mkdir_p on FileUtils' do
|
50
|
-
File.stub
|
50
|
+
File.stub(:directory?).and_return(false)
|
51
51
|
FileUtils.should_receive(:mkdir_p)
|
52
52
|
@concrete_class.create_metric_dir_if_missing
|
53
53
|
end
|
@@ -57,7 +57,7 @@ describe MetricFu::Generator do
|
|
57
57
|
describe "#create_output_dir_if_missing" do
|
58
58
|
describe "when the output_dir exists " do
|
59
59
|
it 'should not call mkdir_p on FileUtils' do
|
60
|
-
File.stub
|
60
|
+
File.stub(:directory?).and_return(true)
|
61
61
|
FileUtils.should_not_receive(:mkdir_p)
|
62
62
|
@concrete_class.create_output_dir_if_missing
|
63
63
|
end
|
@@ -65,7 +65,7 @@ describe MetricFu::Generator do
|
|
65
65
|
|
66
66
|
describe "when the output_dir does not exist " do
|
67
67
|
it 'should call mkdir_p on FileUtils' do
|
68
|
-
File.stub
|
68
|
+
File.stub(:directory?).and_return(false)
|
69
69
|
FileUtils.should_receive(:mkdir_p)
|
70
70
|
@concrete_class.create_output_dir_if_missing
|
71
71
|
end
|
@@ -74,22 +74,22 @@ describe MetricFu::Generator do
|
|
74
74
|
|
75
75
|
describe '#metric_directory' do
|
76
76
|
it 'should return the results of ConcreteClass#metric_directory' do
|
77
|
-
ConcreteClass.stub
|
77
|
+
ConcreteClass.stub(:metric_directory).and_return('foo')
|
78
78
|
@concrete_class.metric_directory.should == 'foo'
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
describe 'ConcreteClass#
|
82
|
+
describe 'ConcreteClass#generate_result' do
|
83
83
|
it 'should create a new instance of ConcreteClass' do
|
84
84
|
ConcreteClass.should_receive(:new).and_return(@concrete_class)
|
85
|
-
@concrete_class.should_receive(:
|
86
|
-
ConcreteClass.
|
85
|
+
@concrete_class.should_receive(:generate_result).and_return(true)
|
86
|
+
ConcreteClass.generate_result
|
87
87
|
end
|
88
88
|
|
89
|
-
it 'should call #
|
89
|
+
it 'should call #generate_result on the new ConcreteClass' do
|
90
90
|
ConcreteClass.should_receive(:new).and_return(@concrete_class)
|
91
|
-
@concrete_class.should_receive(:
|
92
|
-
ConcreteClass.
|
91
|
+
@concrete_class.should_receive(:generate_result).and_return(true)
|
92
|
+
ConcreteClass.generate_result
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -112,50 +112,50 @@ describe MetricFu::Generator do
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
describe "#
|
115
|
+
describe "#generate_result" do
|
116
116
|
it 'should raise an error when calling #emit' do
|
117
117
|
@abstract_class = MetricFu::Generator.new
|
118
|
-
lambda { @abstract_class.
|
118
|
+
lambda { @abstract_class.generate_result }.should raise_error
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'should call #analyze' do
|
122
122
|
@abstract_class = MetricFu::Generator.new
|
123
|
-
lambda { @abstract_class.
|
123
|
+
lambda { @abstract_class.generate_result }.should raise_error
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'should call #to_h' do
|
127
127
|
@abstract_class = MetricFu::Generator.new
|
128
|
-
lambda { @abstract_class.
|
128
|
+
lambda { @abstract_class.generate_result }.should raise_error
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
describe "#
|
132
|
+
describe "#generate_result (in a concrete class)" do
|
133
133
|
|
134
134
|
%w[emit analyze].each do |meth|
|
135
135
|
it "should call #before_#{meth}" do
|
136
136
|
@concrete_class.should_receive("before_#{meth}")
|
137
|
-
@concrete_class.
|
137
|
+
@concrete_class.generate_result
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should call ##{meth}" do
|
141
141
|
@concrete_class.should_receive("#{meth}")
|
142
|
-
@concrete_class.
|
142
|
+
@concrete_class.generate_result
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should call #after_#{meth}" do
|
146
146
|
@concrete_class.should_receive("after_#{meth}")
|
147
|
-
@concrete_class.
|
147
|
+
@concrete_class.generate_result
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
151
|
it "should call #before_to_h" do
|
152
152
|
@concrete_class.should_receive("before_to_h")
|
153
|
-
@concrete_class.
|
153
|
+
@concrete_class.generate_result
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should call #to_h" do
|
157
157
|
@concrete_class.should_receive(:to_h)
|
158
|
-
@concrete_class.
|
158
|
+
@concrete_class.generate_result
|
159
159
|
end
|
160
160
|
|
161
161
|
end
|
@@ -31,18 +31,18 @@ describe MetricFu::Graph do
|
|
31
31
|
|
32
32
|
describe "setting the date on the graph" do
|
33
33
|
before(:each) do
|
34
|
-
@graph.stub
|
34
|
+
@graph.stub(:mf_log)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should set the date once for one data point" do
|
38
38
|
Dir.should_receive(:[]).and_return(["metric_fu/tmp/_data/20101105.yml"])
|
39
39
|
File.should_receive(:join)
|
40
40
|
File.should_receive(:open).and_return("Metrics")
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
double_grapher = double
|
42
|
+
double_grapher.should_receive(:get_metrics).with("Metrics", "11/5")
|
43
|
+
double_grapher.should_receive(:graph!)
|
44
44
|
|
45
|
-
@graph.clazz = [
|
45
|
+
@graph.clazz = [double_grapher]
|
46
46
|
@graph.generate
|
47
47
|
end
|
48
48
|
|
@@ -50,11 +50,11 @@ describe MetricFu::Graph do
|
|
50
50
|
Dir.should_receive(:[]).and_return(["/some/kind/of/weird/directory/somebody/configured/_data/20101105.yml"])
|
51
51
|
File.should_receive(:join)
|
52
52
|
File.should_receive(:open).and_return("Metrics")
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
double_grapher = double
|
54
|
+
double_grapher.should_receive(:get_metrics).with("Metrics", "11/5")
|
55
|
+
double_grapher.should_receive(:graph!)
|
56
56
|
|
57
|
-
@graph.clazz = [
|
57
|
+
@graph.clazz = [double_grapher]
|
58
58
|
@graph.generate
|
59
59
|
end
|
60
60
|
end
|
@@ -5,26 +5,26 @@ describe MetricFu::Rcov do
|
|
5
5
|
before :each do
|
6
6
|
MetricFu.configure
|
7
7
|
MetricFu.run_rcov
|
8
|
-
File.stub
|
8
|
+
File.stub(:directory?).and_return(true)
|
9
9
|
@rcov = MetricFu::Rcov.new('base_dir')
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "emit" do
|
13
13
|
before :each do
|
14
|
-
@rcov.stub
|
14
|
+
@rcov.stub(:mf_log)
|
15
15
|
MetricFu.rcov[:external] = nil
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should clear out previous output and make output folder" do
|
19
|
-
@rcov.stub
|
19
|
+
@rcov.stub(:`)
|
20
20
|
FileUtils.should_receive(:rm_rf).with(MetricFu::Rcov.metric_directory, :verbose => false)
|
21
21
|
Dir.should_receive(:mkdir).with(MetricFu::Rcov.metric_directory)
|
22
22
|
@rcov.emit
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should set the RAILS_ENV" do
|
26
|
-
FileUtils.stub
|
27
|
-
Dir.stub
|
26
|
+
FileUtils.stub(:rm_rf)
|
27
|
+
Dir.stub(:mkdir)
|
28
28
|
MetricFu.rcov[:environment] = "metrics"
|
29
29
|
@rcov.should_receive(:`).with(/RAILS_ENV=metrics/)
|
30
30
|
@rcov.emit
|
@@ -36,7 +36,7 @@ describe MetricFu::Rcov do
|
|
36
36
|
MetricFu.rcov[:external] = nil
|
37
37
|
File.should_receive(:open).
|
38
38
|
with(MetricFu::Rcov.metric_directory + '/rcov.txt').
|
39
|
-
and_return(
|
39
|
+
and_return(double("io", :read => RCOV_OUTPUT))
|
40
40
|
@files = @rcov.analyze
|
41
41
|
end
|
42
42
|
|
@@ -65,7 +65,7 @@ describe MetricFu::Rcov do
|
|
65
65
|
end
|
66
66
|
describe "with external configuration option set" do
|
67
67
|
before :each do
|
68
|
-
@rcov.stub
|
68
|
+
@rcov.stub(:mf_log)
|
69
69
|
MetricFu.rcov[:external] = "coverage/rcov.txt"
|
70
70
|
end
|
71
71
|
|
@@ -77,7 +77,7 @@ describe MetricFu::Rcov do
|
|
77
77
|
it "should open the external rcov analysis file" do
|
78
78
|
File.should_receive(:open).
|
79
79
|
with(MetricFu.rcov[:external]).
|
80
|
-
and_return(
|
80
|
+
and_return(double("io", :read => RCOV_OUTPUT))
|
81
81
|
@files = @rcov.analyze
|
82
82
|
end
|
83
83
|
|
@@ -32,7 +32,7 @@ LinkTargetsController#authorize_user calls current_user.role multiple times (Dup
|
|
32
32
|
NewlineController#some_method calls current_user.<< "new line\n" multiple times (Duplication)
|
33
33
|
HERE
|
34
34
|
MetricFu::Configuration.run {}
|
35
|
-
File.stub
|
35
|
+
File.stub(:directory?).and_return(true)
|
36
36
|
reek = MetricFu::Reek.new
|
37
37
|
reek.instance_variable_set(:@output, @lines)
|
38
38
|
@matches = reek.analyze
|
@@ -4,9 +4,9 @@ describe Saikuro do
|
|
4
4
|
describe "to_h method" do
|
5
5
|
before :all do
|
6
6
|
MetricFu::Configuration.run {}
|
7
|
-
File.stub
|
7
|
+
File.stub(:directory?).and_return(true)
|
8
8
|
saikuro = MetricFu::Saikuro.new
|
9
|
-
saikuro.stub
|
9
|
+
saikuro.stub(:metric_directory).and_return("#{resources_path}/saikuro")
|
10
10
|
saikuro.analyze
|
11
11
|
@output = saikuro.to_h
|
12
12
|
end
|
@@ -37,9 +37,9 @@ describe Saikuro do
|
|
37
37
|
describe "per_file_info method" do
|
38
38
|
before :all do
|
39
39
|
MetricFu::Configuration.run {}
|
40
|
-
File.stub
|
40
|
+
File.stub(:directory?).and_return(true)
|
41
41
|
@saikuro = MetricFu::Saikuro.new
|
42
|
-
@saikuro.stub
|
42
|
+
@saikuro.stub(:metric_directory).and_return("#{resources_path}/saikuro")
|
43
43
|
@saikuro.analyze
|
44
44
|
@output = @saikuro.to_h
|
45
45
|
end
|
@@ -53,7 +53,7 @@ describe Saikuro do
|
|
53
53
|
describe "format_directories method" do
|
54
54
|
it "should format the directories" do
|
55
55
|
MetricFu::Configuration.run {}
|
56
|
-
File.stub
|
56
|
+
File.stub(:directory?).and_return(true)
|
57
57
|
saikuro = MetricFu::Saikuro.new
|
58
58
|
|
59
59
|
MetricFu.saikuro[:input_directory] = ["app", "lib"]
|
@@ -5,7 +5,7 @@ describe Stats do
|
|
5
5
|
it "should gather the raw data" do
|
6
6
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
7
7
|
MetricFu.configure.reset
|
8
|
-
File.stub
|
8
|
+
File.stub(:directory?).and_return(true)
|
9
9
|
stats = MetricFu::Stats.new
|
10
10
|
stats.should_receive(:`).with("mf-stats > tmp/metric_fu/scratch/stats/stats.txt")
|
11
11
|
stats.emit
|
@@ -35,9 +35,9 @@ describe Stats do
|
|
35
35
|
HERE
|
36
36
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
37
37
|
MetricFu.configure.reset
|
38
|
-
File.stub
|
38
|
+
File.stub(:directory?).and_return(true)
|
39
39
|
stats = MetricFu::Stats.new
|
40
|
-
File.should_receive(:open).and_return(
|
40
|
+
File.should_receive(:open).and_return(double("file", :read => @lines))
|
41
41
|
@results = stats.analyze
|
42
42
|
end
|
43
43
|
|
@@ -68,7 +68,7 @@ describe Stats do
|
|
68
68
|
it "should put things into a hash" do
|
69
69
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
70
70
|
MetricFu.configure.reset
|
71
|
-
File.stub
|
71
|
+
File.stub(:directory?).and_return(true)
|
72
72
|
stats = MetricFu::Stats.new
|
73
73
|
stats.instance_variable_set(:@stats, "the_stats")
|
74
74
|
stats.to_h[:stats].should == "the_stats"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe MetricFu::Reporter do
|
4
|
+
|
5
|
+
context 'given a single formatter' do
|
6
|
+
before do
|
7
|
+
@formatter = double('formatter')
|
8
|
+
@formatter.stub(:to_a).and_return([@formatter])
|
9
|
+
@reporter = Reporter.new(@formatter)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'notifies the formatter' do
|
13
|
+
@formatter.should_receive(:start)
|
14
|
+
@formatter.should_receive(:finish)
|
15
|
+
@reporter.start
|
16
|
+
@reporter.finish
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'only sends notifications when supported by formatter' do
|
20
|
+
@formatter.stub(:respond_to?).with(:display_results).and_return(false)
|
21
|
+
@formatter.should_not_receive(:display_results)
|
22
|
+
@reporter.display_results
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'given multiple formatters' do
|
27
|
+
before do
|
28
|
+
@formatters = [double('formatter'), double('formatter')]
|
29
|
+
@reporter = Reporter.new(@formatters)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'notifies all formatters' do
|
33
|
+
@formatters.each do |formatter|
|
34
|
+
formatter.should_receive(:start)
|
35
|
+
formatter.should_receive(:finish)
|
36
|
+
end
|
37
|
+
@reporter.start
|
38
|
+
@reporter.finish
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -41,7 +41,7 @@ describe "Gchart graphers" do
|
|
41
41
|
grapher = FlayGchartGrapher.new
|
42
42
|
expected = {
|
43
43
|
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
44
|
-
:title => URI.
|
44
|
+
:title => URI.encode("Flay: duplication"),
|
45
45
|
:axis_with_labels => 'x,y',
|
46
46
|
:format => 'file',
|
47
47
|
:filename => File.join(MetricFu.output_directory, 'flay.png'),
|
@@ -56,7 +56,7 @@ describe "Gchart graphers" do
|
|
56
56
|
grapher = FlogGchartGrapher.new
|
57
57
|
expected = {
|
58
58
|
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
59
|
-
:title => URI.
|
59
|
+
:title => URI.encode("Flog: code complexity"),
|
60
60
|
:stacked => false,
|
61
61
|
:bar_colors => MetricFu::GchartGrapher::COLORS[0..1],
|
62
62
|
:legend => ['average', 'top 5% average'],
|
@@ -75,7 +75,7 @@ describe "Gchart graphers" do
|
|
75
75
|
grapher = RcovGchartGrapher.new
|
76
76
|
expected = {
|
77
77
|
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
78
|
-
:title => URI.
|
78
|
+
:title => URI.encode("Rcov: code coverage"),
|
79
79
|
:max_value => 101,
|
80
80
|
:axis_with_labels => 'x,y',
|
81
81
|
:axis_labels => [grapher.labels.values, [0,20,40,60,80,100]],
|
@@ -92,7 +92,7 @@ describe "Gchart graphers" do
|
|
92
92
|
grapher = ReekGchartGrapher.new
|
93
93
|
expected = {
|
94
94
|
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
95
|
-
:title => URI.
|
95
|
+
:title => URI.encode("Reek: code smells"),
|
96
96
|
:stacked => false,
|
97
97
|
:bar_colors => MetricFu::GchartGrapher::COLORS,
|
98
98
|
:axis_with_labels => 'x,y',
|
@@ -109,7 +109,7 @@ describe "Gchart graphers" do
|
|
109
109
|
grapher = RoodiGchartGrapher.new
|
110
110
|
expected = {
|
111
111
|
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
112
|
-
:title => URI.
|
112
|
+
:title => URI.encode("Roodi: potential design problems"),
|
113
113
|
:axis_with_labels => 'x,y',
|
114
114
|
:format => 'file',
|
115
115
|
:filename => File.join(MetricFu.output_directory, 'roodi.png'),
|
@@ -124,7 +124,7 @@ describe "Gchart graphers" do
|
|
124
124
|
grapher = StatsGchartGrapher.new
|
125
125
|
expected = {
|
126
126
|
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
127
|
-
:title => URI.
|
127
|
+
:title => URI.encode("Stats: LOC & LOT"),
|
128
128
|
:bar_colors => MetricFu::GchartGrapher::COLORS[0..1],
|
129
129
|
:legend => ['Lines of code', 'Lines of test'],
|
130
130
|
:custom => "chdlp=t",
|
@@ -142,7 +142,7 @@ describe "Gchart graphers" do
|
|
142
142
|
grapher = RailsBestPracticesGchartGrapher.new
|
143
143
|
expected = {
|
144
144
|
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
145
|
-
:title => URI.
|
145
|
+
:title => URI.encode("Rails Best Practices: design problems"),
|
146
146
|
:bar_colors => MetricFu::GchartGrapher::COLORS[0..1],
|
147
147
|
:legend => ['Problems'],
|
148
148
|
:custom => "chdlp=t",
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe MetricFu do
|
4
|
+
|
5
|
+
describe "#result" do
|
6
|
+
it 'should return an instance of Result' do
|
7
|
+
MetricFu.result.instance_of?(Result).should be(true)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe MetricFu::Result do
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
@result = MetricFu::Result.new
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#as_yaml" do
|
19
|
+
it 'should call #result_hash' do
|
20
|
+
result_hash = double('result_hash')
|
21
|
+
result_hash.should_receive(:to_yaml)
|
22
|
+
|
23
|
+
@result.should_receive(:result_hash).and_return(result_hash)
|
24
|
+
@result.as_yaml
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#result_hash" do
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#add" do
|
32
|
+
it 'should add a passed hash to the result_hash instance variable' do
|
33
|
+
result_type = double('result_type')
|
34
|
+
result_type.stub(:to_s).and_return('type')
|
35
|
+
|
36
|
+
result_inst = double('result_inst')
|
37
|
+
result_type.should_receive(:new).and_return(result_inst)
|
38
|
+
|
39
|
+
result_inst.should_receive(:generate_result).and_return({:a => 'b'})
|
40
|
+
result_inst.should_receive(:respond_to?).and_return(false)
|
41
|
+
|
42
|
+
MetricFu.should_receive(:send).with(result_type).and_return({})
|
43
|
+
MetricFu.should_receive(:const_get).
|
44
|
+
with('Type').and_return(result_type)
|
45
|
+
result_hash = double('result_hash')
|
46
|
+
result_hash.should_receive(:merge!).with({:a => 'b'})
|
47
|
+
@result.should_receive(:result_hash).and_return(result_hash)
|
48
|
+
@result.add(result_type)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|