nielsm-metric_fu 1.1.1 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +46 -0
- data/Rakefile +4 -7
- data/TODO +0 -4
- data/lib/base/base_template.rb +1 -2
- data/lib/base/configuration.rb +9 -35
- data/lib/base/generator.rb +9 -1
- data/lib/base/graph.rb +5 -3
- data/lib/base/report.rb +3 -3
- data/lib/generators/churn.rb +15 -72
- data/lib/generators/flay.rb +3 -2
- data/lib/generators/flog.rb +33 -6
- data/lib/generators/rcov.rb +32 -37
- data/lib/generators/reek.rb +28 -1
- data/lib/generators/roodi.rb +2 -1
- data/lib/generators/saikuro.rb +53 -40
- data/lib/generators/stats.rb +29 -13
- data/lib/graphs/engines/bluff.rb +86 -0
- data/lib/graphs/engines/gchart.rb +118 -0
- data/lib/graphs/flay_grapher.rb +6 -20
- data/lib/graphs/flog_grapher.rb +25 -22
- data/lib/graphs/grapher.rb +11 -0
- data/lib/graphs/rcov_grapher.rb +2 -16
- data/lib/graphs/reek_grapher.rb +12 -24
- data/lib/graphs/roodi_grapher.rb +6 -20
- data/lib/metric_fu.rb +13 -6
- data/lib/templates/awesome/awesome_template.rb +7 -0
- data/lib/templates/awesome/churn.html.erb +39 -0
- data/lib/templates/awesome/css/buttons.css +82 -0
- data/lib/templates/awesome/{default.css → css/default.css} +16 -0
- data/lib/templates/awesome/css/integrity.css +335 -0
- data/lib/templates/awesome/css/reset.css +7 -0
- data/lib/templates/awesome/flay.html.erb +8 -1
- data/lib/templates/awesome/flog.html.erb +8 -1
- data/lib/templates/awesome/layout.html.erb +7 -4
- data/lib/templates/awesome/rcov.html.erb +7 -1
- data/lib/templates/awesome/reek.html.erb +7 -1
- data/lib/templates/awesome/roodi.html.erb +7 -1
- data/lib/templates/javascripts/bluff-min.js +1 -0
- data/lib/templates/javascripts/excanvas.js +35 -0
- data/lib/templates/javascripts/js-class.js +1 -0
- data/spec/base/configuration_spec.rb +21 -54
- data/spec/base/generator_spec.rb +63 -0
- data/spec/base/graph_spec.rb +24 -0
- data/spec/generators/churn_spec.rb +16 -125
- data/spec/generators/flay_spec.rb +11 -5
- data/spec/generators/flog_spec.rb +19 -0
- data/spec/generators/reek_spec.rb +65 -0
- data/spec/graphs/engines/bluff_spec.rb +16 -0
- data/spec/graphs/engines/gchart_spec.rb +108 -0
- data/spec/graphs/flay_grapher_spec.rb +37 -0
- data/spec/graphs/flog_grapher_spec.rb +40 -10
- data/spec/graphs/rcov_grapher_spec.rb +37 -0
- data/spec/graphs/reek_grapher_spec.rb +46 -0
- data/spec/graphs/roodi_grapher_spec.rb +37 -0
- data/spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html +0 -0
- data/spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html +0 -0
- data/spec/resources/saikuro/index_cyclo.html +0 -0
- data/spec/resources/saikuro_sfiles/thing.rb_cyclo.html +1 -0
- data/spec/resources/yml/20090630.yml +7844 -0
- data/spec/spec.opts +2 -4
- data/spec/spec_helper.rb +2 -23
- data/tasks/metric_fu.rake +1 -1
- metadata +72 -14
- data/vendor/_fonts/monaco.ttf +0 -0
- data/vendor/saikuro/saikuro.rb +0 -1214
@@ -5,19 +5,25 @@ describe Flay do
|
|
5
5
|
MetricFu::Flay.stub!(:verify_dependencies!).and_return(true)
|
6
6
|
end
|
7
7
|
describe "emit method" do
|
8
|
-
|
8
|
+
it "should look at the dirs" do
|
9
9
|
MetricFu::Configuration.run {|config| config.flay = { :dirs_to_flay => ['app', 'lib'] } }
|
10
10
|
File.stub!(:directory?).and_return(true)
|
11
|
-
@flay = MetricFu::Flay.new('base_dir')
|
12
|
-
|
13
|
-
end
|
11
|
+
@flay = MetricFu::Flay.new('base_dir')
|
14
12
|
|
15
|
-
it "should look at the dirs" do
|
16
13
|
Dir.should_receive(:[]).with(File.join("app", "**/*.rb")).and_return("path/to/app")
|
17
14
|
Dir.should_receive(:[]).with(File.join("lib", "**/*.rb")).and_return("path/to/lib")
|
18
15
|
@flay.should_receive(:`).with("flay path/to/app path/to/lib")
|
19
16
|
output = @flay.emit
|
20
17
|
end
|
18
|
+
|
19
|
+
it "should limit flay scores by the minimum_score" do
|
20
|
+
MetricFu::Configuration.run {|config| config.flay = { :dirs_to_flay => [], :minimum_score => 99 } }
|
21
|
+
File.stub!(:directory?).and_return(true)
|
22
|
+
@flay = MetricFu::Flay.new('base_dir')
|
23
|
+
|
24
|
+
@flay.should_receive(:`).with("flay --mass 99 ")
|
25
|
+
output = @flay.emit
|
26
|
+
end
|
21
27
|
end
|
22
28
|
|
23
29
|
describe "analyze method" do
|
@@ -184,6 +184,7 @@ describe Flog do
|
|
184
184
|
File.stub!(:directory?).and_return(true)
|
185
185
|
flog = MetricFu::Flog.new('base_dir')
|
186
186
|
flog.should_receive(:open).and_return(@text)
|
187
|
+
flog.stub!(:is_file_current?).and_return(true)
|
187
188
|
Dir.should_receive(:glob).and_return(["tmp/metric_fu/scratch/flog/app/controllers/user_controller.txt"])
|
188
189
|
flog.analyze
|
189
190
|
@flog_hash = flog.to_h
|
@@ -206,6 +207,24 @@ describe Flog do
|
|
206
207
|
end
|
207
208
|
end
|
208
209
|
|
210
|
+
describe "to_h function ignore files not current" do
|
211
|
+
before :each do
|
212
|
+
MetricFu::Configuration.run {}
|
213
|
+
File.stub!(:directory?).and_return(true)
|
214
|
+
flog = MetricFu::Flog.new('base_dir')
|
215
|
+
flog.should_receive(:open).and_return(@text)
|
216
|
+
flog.stub!(:is_file_current?).and_return(false)
|
217
|
+
Dir.should_receive(:glob).and_return(["tmp/metric_fu/scratch/flog/app/controllers/user_controller.txt"])
|
218
|
+
flog.analyze
|
219
|
+
@flog_hash = flog.to_h
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should put the total in the hash" do
|
223
|
+
@flog_hash.should == {:flog=>{:total=>0, :pages=>[], :average=>0}}
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
|
209
228
|
describe "to_h function with zero total" do
|
210
229
|
it "should not blow up" do
|
211
230
|
MetricFu::Configuration.run {}
|
@@ -58,3 +58,68 @@ NewlineController#some_method calls current_user.<< "new line\n" multiple times
|
|
58
58
|
end
|
59
59
|
|
60
60
|
end
|
61
|
+
|
62
|
+
describe Reek do
|
63
|
+
before :each do
|
64
|
+
MetricFu::Reek.stub!(:verify_dependencies!).and_return(true)
|
65
|
+
MetricFu::Configuration.run {}
|
66
|
+
@reek = MetricFu::Reek.new
|
67
|
+
@lines11 = <<-HERE
|
68
|
+
"app/controllers/activity_reports_controller.rb" -- 4 warnings:
|
69
|
+
ActivityReportsController#authorize_user calls current_user.primary_site_ids multiple times (Duplication)
|
70
|
+
ActivityReportsController#authorize_user calls params[id] multiple times (Duplication)
|
71
|
+
ActivityReportsController#authorize_user calls params[primary_site_id] multiple times (Duplication)
|
72
|
+
ActivityReportsController#authorize_user has approx 6 statements (Long Method)
|
73
|
+
|
74
|
+
"app/controllers/application.rb" -- 1 warnings:
|
75
|
+
ApplicationController#start_background_task/block/block is nested (Nested Iterators)
|
76
|
+
|
77
|
+
"app/controllers/link_targets_controller.rb" -- 1 warnings:
|
78
|
+
LinkTargetsController#authorize_user calls current_user.role multiple times (Duplication)
|
79
|
+
|
80
|
+
"app/controllers/newline_controller.rb" -- 1 warnings:
|
81
|
+
NewlineController#some_method calls current_user.<< "new line\n" multiple times (Duplication)
|
82
|
+
HERE
|
83
|
+
@lines12 = <<-HERE
|
84
|
+
app/controllers/activity_reports_controller.rb -- 4 warnings (+3 masked):
|
85
|
+
ActivityReportsController#authorize_user calls current_user.primary_site_ids multiple times (Duplication)
|
86
|
+
ActivityReportsController#authorize_user calls params[id] multiple times (Duplication)
|
87
|
+
ActivityReportsController#authorize_user calls params[primary_site_id] multiple times (Duplication)
|
88
|
+
ActivityReportsController#authorize_user has approx 6 statements (Long Method)
|
89
|
+
app/controllers/application.rb -- 1 warnings:
|
90
|
+
ApplicationController#start_background_task/block/block is nested (Nested Iterators)
|
91
|
+
app/controllers/link_targets_controller.rb -- 1 warnings (+1 masked):
|
92
|
+
LinkTargetsController#authorize_user calls current_user.role multiple times (Duplication)
|
93
|
+
app/controllers/newline_controller.rb -- 1 warnings:
|
94
|
+
NewlineController#some_method calls current_user.<< "new line\n" multiple times (Duplication)
|
95
|
+
HERE
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'with Reek 1.1 output format' do
|
99
|
+
it 'reports 1.1 style when the output is empty' do
|
100
|
+
@reek.instance_variable_set(:@output, "")
|
101
|
+
@reek.should_not be_reek_12
|
102
|
+
end
|
103
|
+
it 'detects 1.1 format output' do
|
104
|
+
@reek.instance_variable_set(:@output, @lines11)
|
105
|
+
@reek.should_not be_reek_12
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'massages empty output to be unchanged' do
|
109
|
+
@reek.instance_variable_set(:@output, "")
|
110
|
+
@reek.massage_for_reek_12.should be_empty
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'with Reek 1.2 output format' do
|
115
|
+
it 'detects 1.2 format output' do
|
116
|
+
@reek.instance_variable_set(:@output, @lines12)
|
117
|
+
@reek.should be_reek_12
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'correctly massages 1.2 output' do
|
121
|
+
@reek.instance_variable_set(:@output, @lines12)
|
122
|
+
@reek.massage_for_reek_12.should == @lines11
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe "Bluff graphers responding to #graph!" do
|
4
|
+
it "should write chart file" do
|
5
|
+
MetricFu.configuration
|
6
|
+
graphs = {}
|
7
|
+
MetricFu::AVAILABLE_GRAPHS.each do |graph|
|
8
|
+
graphs[graph] = MetricFu.const_get("#{graph.to_s.capitalize}BluffGrapher").new
|
9
|
+
end
|
10
|
+
graphs.each do |key, val|
|
11
|
+
val.graph!
|
12
|
+
output_dir = File.expand_path(File.join(MetricFu.output_directory))
|
13
|
+
lambda{ File.open(File.join(output_dir, "#{key.to_s.downcase}.js")) }.should_not raise_error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
describe MetricFu::GchartGrapher do
|
3
|
+
describe "determine_y_axis_scale" do
|
4
|
+
it "should set defaults when empty array" do
|
5
|
+
grapher = Object.new.extend(MetricFu::GchartGrapher)
|
6
|
+
grapher.determine_y_axis_scale([])
|
7
|
+
grapher.instance_variable_get(:@max_value).should == 10
|
8
|
+
grapher.instance_variable_get(:@yaxis).should == [0, 2, 4, 6, 8, 10]
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should set max value of the graph above largest value" do
|
12
|
+
grapher = Object.new.extend(MetricFu::GchartGrapher)
|
13
|
+
grapher.determine_y_axis_scale([19])
|
14
|
+
grapher.instance_variable_get(:@max_value).should == 20
|
15
|
+
|
16
|
+
grapher.determine_y_axis_scale([20])
|
17
|
+
grapher.instance_variable_get(:@max_value).should == 25
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Gchart graphers" do
|
23
|
+
before :each do
|
24
|
+
MetricFu.configuration
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "FlayGchartGrapher graph! method" do
|
28
|
+
it "should set static values for graph" do
|
29
|
+
grapher = FlayGchartGrapher.new
|
30
|
+
expected = {
|
31
|
+
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
32
|
+
:title => URI.escape("Flay: duplication"),
|
33
|
+
:axis_with_labels => 'x,y',
|
34
|
+
:format => 'file',
|
35
|
+
:filename => File.join(MetricFu.output_directory, 'flay.png'),
|
36
|
+
}
|
37
|
+
Gchart.should_receive(:line).with(hash_including(expected))
|
38
|
+
grapher.graph!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "FlogGchartGrapher graph! method" do
|
43
|
+
it "should set static values for graph" do
|
44
|
+
grapher = FlogGchartGrapher.new
|
45
|
+
expected = {
|
46
|
+
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
47
|
+
:title => URI.escape("Flog: code complexity"),
|
48
|
+
:stacked => false,
|
49
|
+
:bar_colors => MetricFu::GchartGrapher::COLORS[0..1],
|
50
|
+
:legend => ['average', 'top 5%25 average'],
|
51
|
+
:axis_with_labels => 'x,y',
|
52
|
+
:format => 'file',
|
53
|
+
:filename => File.join(MetricFu.output_directory, 'flog.png'),
|
54
|
+
}
|
55
|
+
Gchart.should_receive(:line).with(hash_including(expected))
|
56
|
+
grapher.graph!
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "RcovGchartGrapher graph! method" do
|
61
|
+
it "should set static values for graph" do
|
62
|
+
grapher = RcovGchartGrapher.new
|
63
|
+
expected = {
|
64
|
+
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
65
|
+
:title => URI.escape("Rcov: code coverage"),
|
66
|
+
:max_value => 101,
|
67
|
+
:axis_with_labels => 'x,y',
|
68
|
+
:axis_labels => [grapher.labels.values, [0,20,40,60,80,100]],
|
69
|
+
:format => 'file',
|
70
|
+
:filename => File.join(MetricFu.output_directory, 'rcov.png'),
|
71
|
+
}
|
72
|
+
Gchart.should_receive(:line).with(hash_including(expected))
|
73
|
+
grapher.graph!
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "ReekGchartGrapher graph! method" do
|
78
|
+
it "should set static values for graph" do
|
79
|
+
grapher = ReekGchartGrapher.new
|
80
|
+
expected = {
|
81
|
+
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
82
|
+
:title => URI.escape("Reek: code smells"),
|
83
|
+
:stacked => false,
|
84
|
+
:bar_colors => MetricFu::GchartGrapher::COLORS,
|
85
|
+
:axis_with_labels => 'x,y',
|
86
|
+
:format => 'file',
|
87
|
+
:filename => File.join(MetricFu.output_directory, 'reek.png'),
|
88
|
+
}
|
89
|
+
Gchart.should_receive(:line).with(hash_including(expected))
|
90
|
+
grapher.graph!
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "RoodiGchartGrapher graph! method" do
|
95
|
+
it "should set static values for graph" do
|
96
|
+
grapher = RoodiGchartGrapher.new
|
97
|
+
expected = {
|
98
|
+
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
99
|
+
:title => URI.escape("Roodi: potential design problems"),
|
100
|
+
:axis_with_labels => 'x,y',
|
101
|
+
:format => 'file',
|
102
|
+
:filename => File.join(MetricFu.output_directory, 'roodi.png'),
|
103
|
+
}
|
104
|
+
Gchart.should_receive(:line).with(hash_including(expected))
|
105
|
+
grapher.graph!
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe FlayGrapher do
|
4
|
+
before :each do
|
5
|
+
@flay_grapher = MetricFu::FlayGrapher.new
|
6
|
+
MetricFu.configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should respond to flay_score and labels" do
|
10
|
+
@flay_grapher.should respond_to(:flay_score)
|
11
|
+
@flay_grapher.should respond_to(:labels)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "responding to #initialize" do
|
15
|
+
it "should initialise flay_score and labels" do
|
16
|
+
@flay_grapher.flay_score.should == []
|
17
|
+
@flay_grapher.labels.should == {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "responding to #get_metrics" do
|
22
|
+
before(:each) do
|
23
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml")))
|
24
|
+
@date = "1/2"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should push 476 to flay_score" do
|
28
|
+
@flay_grapher.flay_score.should_receive(:push).with(476)
|
29
|
+
@flay_grapher.get_metrics(@metrics, @date)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should update labels with the date" do
|
33
|
+
@flay_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
|
34
|
+
@flay_grapher.get_metrics(@metrics, @date)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,15 +1,45 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
2
3
|
describe MetricFu::FlogGrapher do
|
3
|
-
|
4
|
-
MetricFu::
|
4
|
+
before :each do
|
5
|
+
@flog_grapher = MetricFu::FlogGrapher.new
|
6
|
+
MetricFu.configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should respond to flog_total, flog_average and labels" do
|
10
|
+
@flog_grapher.should respond_to(:flog_average)
|
11
|
+
@flog_grapher.should respond_to(:labels)
|
12
|
+
@flog_grapher.should respond_to(:top_five_percent_average)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "responding to #initialize" do
|
16
|
+
it "should initialize top_five_percent_average, flog_average and labels" do
|
17
|
+
@flog_grapher.flog_average.should == []
|
18
|
+
@flog_grapher.labels.should == {}
|
19
|
+
@flog_grapher.top_five_percent_average.should == []
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "responding to #get_metrics" do
|
24
|
+
before(:each) do
|
25
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml")))
|
26
|
+
@date = "1/2"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should push to top_five_percent_average" do
|
30
|
+
average = (73.6 + 68.5 + 66.1 + 46.6 + 44.8 + 44.1 + 41.2 + 36.0) / 8.0
|
31
|
+
@flog_grapher.top_five_percent_average.should_receive(:push).with(average)
|
32
|
+
@flog_grapher.get_metrics(@metrics, @date)
|
33
|
+
end
|
5
34
|
|
6
|
-
|
7
|
-
|
8
|
-
|
35
|
+
it "should push 9.9 to flog_average" do
|
36
|
+
@flog_grapher.flog_average.should_receive(:push).with(9.9)
|
37
|
+
@flog_grapher.get_metrics(@metrics, @date)
|
38
|
+
end
|
9
39
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
40
|
+
it "should update labels with the date" do
|
41
|
+
@flog_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
|
42
|
+
@flog_grapher.get_metrics(@metrics, @date)
|
43
|
+
end
|
14
44
|
end
|
15
|
-
end
|
45
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe RcovGrapher do
|
4
|
+
before :each do
|
5
|
+
@rcov_grapher = MetricFu::RcovGrapher.new
|
6
|
+
MetricFu.configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should respond to rcov_percent and labels" do
|
10
|
+
@rcov_grapher.should respond_to(:rcov_percent)
|
11
|
+
@rcov_grapher.should respond_to(:labels)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "responding to #initialize" do
|
15
|
+
it "should initialise rcov_percent and labels" do
|
16
|
+
@rcov_grapher.rcov_percent.should == []
|
17
|
+
@rcov_grapher.labels.should == {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "responding to #get_metrics" do
|
22
|
+
before(:each) do
|
23
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml")))
|
24
|
+
@date = "1/2"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should push 49.6 to rcov_percent" do
|
28
|
+
@rcov_grapher.rcov_percent.should_receive(:push).with(49.6)
|
29
|
+
@rcov_grapher.get_metrics(@metrics, @date)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should update labels with the date" do
|
33
|
+
@rcov_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
|
34
|
+
@rcov_grapher.get_metrics(@metrics, @date)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe ReekGrapher do
|
4
|
+
before :each do
|
5
|
+
@reek_grapher = MetricFu::ReekGrapher.new
|
6
|
+
MetricFu.configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should respond to reek_count and labels" do
|
10
|
+
@reek_grapher.should respond_to(:reek_count)
|
11
|
+
@reek_grapher.should respond_to(:labels)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "responding to #initialize" do
|
15
|
+
it "should initialise reek_count and labels" do
|
16
|
+
@reek_grapher.reek_count.should == {}
|
17
|
+
@reek_grapher.labels.should == {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "responding to #get_metrics" do
|
22
|
+
before(:each) do
|
23
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml")))
|
24
|
+
@date = "1/2"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should set a hash of code smells to reek_count" do
|
28
|
+
@reek_grapher.get_metrics(@metrics, @date)
|
29
|
+
@reek_grapher.reek_count.should == {
|
30
|
+
"Uncommunicative Name" => [27],
|
31
|
+
"Feature Envy" => [20],
|
32
|
+
"Utility Function" => [15],
|
33
|
+
"Long Method" => [26],
|
34
|
+
"Nested Iterators" => [12],
|
35
|
+
"Control Couple" => [4],
|
36
|
+
"Duplication" => [48],
|
37
|
+
"Large Class" => [1]
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should update labels with the date" do
|
42
|
+
@reek_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
|
43
|
+
@reek_grapher.get_metrics(@metrics, @date)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe RoodiGrapher do
|
4
|
+
before :each do
|
5
|
+
@roodi_grapher = MetricFu::RoodiGrapher.new
|
6
|
+
MetricFu.configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should respond to roodi_count and labels" do
|
10
|
+
@roodi_grapher.should respond_to(:roodi_count)
|
11
|
+
@roodi_grapher.should respond_to(:labels)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "responding to #initialize" do
|
15
|
+
it "should initialise roodi_count and labels" do
|
16
|
+
@roodi_grapher.roodi_count.should == []
|
17
|
+
@roodi_grapher.labels.should == {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "responding to #get_metrics" do
|
22
|
+
before(:each) do
|
23
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml")))
|
24
|
+
@date = "1/2"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should push 13 to roodi_count" do
|
28
|
+
@roodi_grapher.roodi_count.should_receive(:push).with(13)
|
29
|
+
@roodi_grapher.get_metrics(@metrics, @date)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should update labels with the date" do
|
33
|
+
@roodi_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
|
34
|
+
@roodi_grapher.get_metrics(@metrics, @date)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|