edouard-metric_fu 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +119 -0
- data/MIT-LICENSE +22 -0
- data/Manifest.txt +25 -0
- data/README +1 -0
- data/Rakefile +47 -0
- data/TODO +14 -0
- data/lib/base/base_template.rb +134 -0
- data/lib/base/configuration.rb +207 -0
- data/lib/base/generator.rb +160 -0
- data/lib/base/graph.rb +37 -0
- data/lib/base/md5_tracker.rb +52 -0
- data/lib/base/report.rb +100 -0
- data/lib/generators/churn.rb +91 -0
- data/lib/generators/flay.rb +34 -0
- data/lib/generators/flog.rb +133 -0
- data/lib/generators/rcov.rb +87 -0
- data/lib/generators/reek.rb +37 -0
- data/lib/generators/roodi.rb +31 -0
- data/lib/generators/saikuro.rb +209 -0
- data/lib/generators/stats.rb +43 -0
- data/lib/graphs/flay_grapher.rb +34 -0
- data/lib/graphs/flog_grapher.rb +37 -0
- data/lib/graphs/rcov_grapher.rb +34 -0
- data/lib/graphs/reek_grapher.rb +44 -0
- data/lib/graphs/roodi_grapher.rb +34 -0
- data/lib/metric_fu.rb +24 -0
- data/lib/templates/awesome/awesome_template.rb +30 -0
- data/lib/templates/awesome/churn.html.erb +19 -0
- data/lib/templates/awesome/default.css +66 -0
- data/lib/templates/awesome/flay.html.erb +27 -0
- data/lib/templates/awesome/flog.html.erb +46 -0
- data/lib/templates/awesome/index.html.erb +28 -0
- data/lib/templates/awesome/layout.html.erb +27 -0
- data/lib/templates/awesome/rcov.html.erb +36 -0
- data/lib/templates/awesome/reek.html.erb +34 -0
- data/lib/templates/awesome/roodi.html.erb +21 -0
- data/lib/templates/awesome/saikuro.html.erb +71 -0
- data/lib/templates/awesome/stats.html.erb +41 -0
- data/lib/templates/standard/churn.html.erb +31 -0
- data/lib/templates/standard/default.css +64 -0
- data/lib/templates/standard/flay.html.erb +34 -0
- data/lib/templates/standard/flog.html.erb +53 -0
- data/lib/templates/standard/index.html.erb +38 -0
- data/lib/templates/standard/rcov.html.erb +43 -0
- data/lib/templates/standard/reek.html.erb +42 -0
- data/lib/templates/standard/roodi.html.erb +29 -0
- data/lib/templates/standard/saikuro.html.erb +84 -0
- data/lib/templates/standard/standard_template.rb +26 -0
- data/lib/templates/standard/stats.html.erb +55 -0
- data/spec/base/base_template_spec.rb +140 -0
- data/spec/base/configuration_spec.rb +303 -0
- data/spec/base/generator_spec.rb +181 -0
- data/spec/base/md5_tracker_spec.rb +57 -0
- data/spec/base/report_spec.rb +139 -0
- data/spec/generators/churn_spec.rb +152 -0
- data/spec/generators/flay_spec.rb +104 -0
- data/spec/generators/flog_spec.rb +208 -0
- data/spec/generators/reek_spec.rb +60 -0
- data/spec/generators/saikuro_spec.rb +63 -0
- data/spec/generators/stats_spec.rb +74 -0
- data/spec/spec_helper.rb +28 -0
- data/tasks/metric_fu.rake +19 -0
- data/tasks/railroad.rake +39 -0
- data/vendor/_fonts/monaco.ttf +0 -0
- data/vendor/saikuro/saikuro.rb +1214 -0
- metadata +174 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Saikuro Results</title>
|
4
|
+
<style>
|
5
|
+
<%= inline_css("default.css") %>
|
6
|
+
</style>
|
7
|
+
</head>
|
8
|
+
|
9
|
+
<body>
|
10
|
+
<h1>Saikuro Results</h1>
|
11
|
+
<a href="index.html">back to menu</a>
|
12
|
+
<p><a href='http://saikuro.rubyforge.org/'>Saikuro</a> analyzes ruby code for cyclomatic complexity.</p>
|
13
|
+
|
14
|
+
<h2>Analyzed Methods</h2>
|
15
|
+
<table>
|
16
|
+
<tr>
|
17
|
+
<th>Method Name</th>
|
18
|
+
<th>Complexity</th>
|
19
|
+
<th># Lines</th>
|
20
|
+
</tr>
|
21
|
+
<% @saikuro[:methods].each do |method| %>
|
22
|
+
<tr>
|
23
|
+
<td><%= method[:name] %></td>
|
24
|
+
<td><%= method[:complexity] %></td>
|
25
|
+
<td><%= method[:lines] %></td>
|
26
|
+
</tr>
|
27
|
+
<% end %>
|
28
|
+
</table>
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
<h2>Analyzed Classes</h2>
|
33
|
+
<table>
|
34
|
+
<tr>
|
35
|
+
<th>Class Name</th>
|
36
|
+
<th>Complexity</th>
|
37
|
+
<th># Lines</th>
|
38
|
+
</tr>
|
39
|
+
<% @saikuro[:classes].each do |klass| %>
|
40
|
+
<tr>
|
41
|
+
<td><%= klass[:name] %></td>
|
42
|
+
<td><%= klass[:complexity] %></td>
|
43
|
+
<td><%= klass[:lines] %></td>
|
44
|
+
</tr>
|
45
|
+
<% end %>
|
46
|
+
</table>
|
47
|
+
|
48
|
+
|
49
|
+
<h2>Analyzed Files</h2>
|
50
|
+
<% @saikuro[:files].each do |file| %>
|
51
|
+
<% file[:classes].each do |klass| %>
|
52
|
+
<% if !klass[:methods].empty? %>
|
53
|
+
<h3><%= file[:filename] %></h3>
|
54
|
+
<h4>Class : <%= klass[:class_name] %></h4>
|
55
|
+
<h5>Total complexity : <%= klass[:complexity] %></h5>
|
56
|
+
<h5>Total lines : <%= klass[:lines] %></h5>
|
57
|
+
<table>
|
58
|
+
<tr>
|
59
|
+
<th>Method</th>
|
60
|
+
<th>Complexity</th>
|
61
|
+
<th># Lines</th>
|
62
|
+
</tr>
|
63
|
+
<% klass[:methods].each do |method| %>
|
64
|
+
<tr>
|
65
|
+
<td>
|
66
|
+
<%= method[:name] %>
|
67
|
+
</td>
|
68
|
+
<td>
|
69
|
+
<%= method[:complexity] %>
|
70
|
+
</td>
|
71
|
+
<td>
|
72
|
+
<%= method[:lines] %>
|
73
|
+
</td>
|
74
|
+
</tr>
|
75
|
+
<% end %>
|
76
|
+
</table>
|
77
|
+
<% end %>
|
78
|
+
<% end %>
|
79
|
+
<% end %>
|
80
|
+
|
81
|
+
<p>Generated on <%= Time.now.localtime %></p>
|
82
|
+
</body>
|
83
|
+
</html>
|
84
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class StandardTemplate < MetricFu::Template
|
2
|
+
|
3
|
+
|
4
|
+
def write
|
5
|
+
report.each_pair do |section, contents|
|
6
|
+
if template_exists?(section)
|
7
|
+
create_instance_var(section, contents)
|
8
|
+
html = erbify(section)
|
9
|
+
fn = output_filename(section)
|
10
|
+
MetricFu.report.save_output(html, MetricFu.output_directory, fn)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Instance variables we need should already be created from above
|
15
|
+
if template_exists?('index')
|
16
|
+
html = erbify('index')
|
17
|
+
fn = output_filename('index')
|
18
|
+
MetricFu.report.save_output(html, MetricFu.output_directory, fn)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def this_directory
|
23
|
+
File.dirname(__FILE__)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Rake Stats Results</title>
|
4
|
+
<style>
|
5
|
+
<%= inline_css("default.css") %>
|
6
|
+
</style>
|
7
|
+
</head>
|
8
|
+
|
9
|
+
<body>
|
10
|
+
<h1>Rake Stats Results</h1>
|
11
|
+
<a href="index.html">back to menu</a>
|
12
|
+
<p>Rails rake stats results.</p>
|
13
|
+
<table>
|
14
|
+
<tr>
|
15
|
+
<th>Lines of Code</th>
|
16
|
+
<th>Lines of Test</th>
|
17
|
+
<th>Code to test ratio</th>
|
18
|
+
</tr>
|
19
|
+
<tr>
|
20
|
+
<td><%= @stats[:codeLOC] %></td>
|
21
|
+
<td><%= @stats[:testLOC] %></td>
|
22
|
+
<td>1:<%= @stats[:code_to_test_ratio] %></td>
|
23
|
+
</tr>
|
24
|
+
</table>
|
25
|
+
|
26
|
+
<table>
|
27
|
+
<tr>
|
28
|
+
<th>Name</th>
|
29
|
+
<th>Lines</th>
|
30
|
+
<th>LOC</th>
|
31
|
+
<th>Classes</th>
|
32
|
+
<th>Methods</th>
|
33
|
+
<th>Methods per class</th>
|
34
|
+
<th>LOC per method</th>
|
35
|
+
</tr>
|
36
|
+
<% count = 0 %>
|
37
|
+
<% @stats[:lines].each do |line| %>
|
38
|
+
<tr>
|
39
|
+
<td><%= line[:name] %></td>
|
40
|
+
<td><%= line[:lines] %></td>
|
41
|
+
<td><%= line[:loc] %></td>
|
42
|
+
<td><%= line[:classes] %></td>
|
43
|
+
<td><%= line[:methods] %></td>
|
44
|
+
<td><%= line[:methods_per_class] %></td>
|
45
|
+
<td><%= line[:loc_per_method] %></td>
|
46
|
+
</tr>
|
47
|
+
<% count += 1 %>
|
48
|
+
<% end %>
|
49
|
+
</table>
|
50
|
+
|
51
|
+
<p>Generated on <%= Time.now.localtime %></p>
|
52
|
+
</body>
|
53
|
+
</html>
|
54
|
+
|
55
|
+
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper.rb"
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
describe MetricFu::Template do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@template = Template.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#erbify" do
|
11
|
+
it 'should evaluate a erb doc' do
|
12
|
+
section = 'section'
|
13
|
+
File.stub!(:read).and_return('foo')
|
14
|
+
erb = mock('erb')
|
15
|
+
erb.should_receive(:result)
|
16
|
+
ERB.should_receive(:new).with('foo').and_return(erb)
|
17
|
+
@template.should_receive(:template).and_return('foo')
|
18
|
+
@template.send(:erbify, section)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#template_exists? " do
|
23
|
+
|
24
|
+
before(:each) do
|
25
|
+
@section = mock('section')
|
26
|
+
@template.should_receive(:template).
|
27
|
+
with(@section).and_return(@section)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'if the template exists' do
|
31
|
+
it 'should return true' do
|
32
|
+
File.should_receive(:exist?).with(@section).and_return(true)
|
33
|
+
result = @template.send(:template_exists?, @section)
|
34
|
+
result.should be_true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'if the template does not exist' do
|
39
|
+
it 'should return false' do
|
40
|
+
File.should_receive(:exist?).with(@section).and_return(false)
|
41
|
+
result = @template.send(:template_exists?, @section)
|
42
|
+
result.should be_false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#create_instance_var" do
|
48
|
+
it 'should set an instance variable with the passed contents' do
|
49
|
+
section = 'section'
|
50
|
+
contents = 'contents'
|
51
|
+
@template.send(:create_instance_var, section, contents)
|
52
|
+
@template.instance_variable_get(:@section).should == contents
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#template" do
|
57
|
+
it 'should generate the filename of the template file' do
|
58
|
+
section = mock('section')
|
59
|
+
section.should_receive(:to_s).and_return('section')
|
60
|
+
@template.should_receive(:this_directory).and_return('dir')
|
61
|
+
result = @template.send(:template, section)
|
62
|
+
result.should == "dir/section.html.erb"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#output_filename" do
|
67
|
+
it 'should generate the filename of the output file' do
|
68
|
+
section = mock('section')
|
69
|
+
section.should_receive(:to_s).and_return('section')
|
70
|
+
result = @template.send(:output_filename, section)
|
71
|
+
result.should == "section.html"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#inline_css" do
|
76
|
+
it 'should return the contents of a css file' do
|
77
|
+
css = 'mycss.css'
|
78
|
+
@template.should_receive(:this_directory).and_return('dir')
|
79
|
+
io = mock('io', :read => "css contents")
|
80
|
+
@template.should_receive(:open).and_yield(io)
|
81
|
+
result = @template.send(:inline_css, css)
|
82
|
+
result.should == 'css contents'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#link_to_filename " do
|
87
|
+
describe "when on OS X" do
|
88
|
+
before(:each) do
|
89
|
+
config = mock("configuration")
|
90
|
+
config.should_receive(:platform).and_return('universal-darwin-9.0')
|
91
|
+
MetricFu.stub!(:configuration).and_return(config)
|
92
|
+
File.should_receive(:expand_path).and_return('filename')
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should return a textmate protocol link' do
|
96
|
+
name = "filename"
|
97
|
+
result = @template.send(:link_to_filename, name)
|
98
|
+
result.should eql("<a href='txmt://open/?url=file://" \
|
99
|
+
+ "filename&line='>filename:</a>")
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "when on other platforms" do
|
105
|
+
before(:each) do
|
106
|
+
config = mock("configuration")
|
107
|
+
config.should_receive(:platform).and_return('other')
|
108
|
+
MetricFu.stub!(:configuration).and_return(config)
|
109
|
+
File.should_receive(:expand_path).and_return('filename')
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should return a file protocol link' do
|
113
|
+
name = "filename"
|
114
|
+
result = @template.send(:link_to_filename, name)
|
115
|
+
result.should == "<a href='file://filename'>filename:</a>"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "#cycle" do
|
121
|
+
it 'should return the first_value passed if iteration passed is even' do
|
122
|
+
first_val = "first"
|
123
|
+
second_val = "second"
|
124
|
+
iter = 2
|
125
|
+
result = @template.send(:cycle, first_val, second_val, iter)
|
126
|
+
result.should == first_val
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should return the second_value passed if iteration passed is odd' do
|
130
|
+
first_val = "first"
|
131
|
+
second_val = "second"
|
132
|
+
iter = 1
|
133
|
+
result = @template.send(:cycle, first_val, second_val, iter)
|
134
|
+
result.should == second_val
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
|
@@ -0,0 +1,303 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper.rb"
|
2
|
+
|
3
|
+
describe MetricFu::Configuration do
|
4
|
+
|
5
|
+
def get_new_config
|
6
|
+
@config = Configuration.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def base_directory
|
10
|
+
@config.instance_variable_get(:@base_directory)
|
11
|
+
end
|
12
|
+
|
13
|
+
def output_directory
|
14
|
+
@config.instance_variable_get(:@output_directory)
|
15
|
+
end
|
16
|
+
|
17
|
+
def scratch_directory
|
18
|
+
@config.instance_variable_get(:@scratch_directory)
|
19
|
+
end
|
20
|
+
|
21
|
+
def template_directory
|
22
|
+
@config.instance_variable_get(:@template_directory)
|
23
|
+
end
|
24
|
+
|
25
|
+
def template_class
|
26
|
+
@config.instance_variable_get(:@template_class)
|
27
|
+
end
|
28
|
+
|
29
|
+
def metric_fu_root
|
30
|
+
@config.instance_variable_get(:@metric_fu_root_directory)
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#warn_about_deprecated_config_options' do
|
34
|
+
|
35
|
+
def get_new_config_and_raise_runtime_error
|
36
|
+
lambda { get_new_config }.should raise_error
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'when ::MetricFu::CHURN_OPTIONS is present' do
|
40
|
+
before(:each) { ::MetricFu::CHURN_OPTIONS = 'option' }
|
41
|
+
after(:each) { ::MetricFu.send(:remove_const, 'CHURN_OPTIONS') }
|
42
|
+
|
43
|
+
it 'should raise a RuntimeError with "Use config.churn '+
|
44
|
+
'instead of MetricFu::CHURN_OPTIONS"' do
|
45
|
+
get_new_config_and_raise_runtime_error
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'when ::MetricFu::DIRECTORIES_TO_FLOG is present' do
|
50
|
+
before(:each) { ::MetricFu::DIRECTORIES_TO_FLOG = 'option' }
|
51
|
+
after(:each) { ::MetricFu.send(:remove_const,'DIRECTORIES_TO_FLOG')}
|
52
|
+
|
53
|
+
it 'should raise a RuntimeError with "Use config.flog '+
|
54
|
+
'[:dirs_to_flog] instead of MetricFu::DIRECTORIES_TO_FLOG' do
|
55
|
+
get_new_config_and_raise_runtime_error
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'when ::MetricFu::SAIKURO_OPTIONS is present' do
|
60
|
+
before(:each) { ::MetricFu::SAIKURO_OPTIONS = 'option' }
|
61
|
+
after(:each) { ::MetricFu.send(:remove_const,'SAIKURO_OPTIONS')}
|
62
|
+
|
63
|
+
it 'should raise a RuntimeError with "Use config.saikuro '+
|
64
|
+
'instead of MetricFu::SAIKURO_OPTIONS' do
|
65
|
+
get_new_config_and_raise_runtime_error
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe 'when SAIKURO_OPTIONS is present' do
|
70
|
+
before(:each) { SAIKURO_OPTIONS = 'option' }
|
71
|
+
after(:each) { Object.send(:remove_const,'SAIKURO_OPTIONS')}
|
72
|
+
|
73
|
+
it 'should raise a RuntimeError with "Use config.saikuro '+
|
74
|
+
'instead of SAIKURO_OPTIONS' do
|
75
|
+
get_new_config_and_raise_runtime_error
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#reset" do
|
81
|
+
|
82
|
+
before(:each) { get_new_config }
|
83
|
+
|
84
|
+
describe 'when there is a CC_BUILD_ARTIFACTS environment variable' do
|
85
|
+
before(:each) { ENV['CC_BUILD_ARTIFACTS'] = 'foo' }
|
86
|
+
|
87
|
+
it 'should return the CC_BUILD_ARTIFACTS environment variable' do
|
88
|
+
get_new_config
|
89
|
+
base_directory.should == ENV['CC_BUILD_ARTIFACTS']
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'when there is no CC_BUILD_ARTIFACTS environment variable' do
|
94
|
+
before(:each) { ENV['CC_BUILD_ARTIFACTS'] = nil }
|
95
|
+
|
96
|
+
it 'should return "tmp/metric_fu"' do
|
97
|
+
get_new_config
|
98
|
+
base_directory.should == "tmp/metric_fu"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should set @metric_fu_root_directory to the base of the '+
|
103
|
+
'metric_fu application' do
|
104
|
+
app_root = File.join(File.dirname(__FILE__), '..', '..')
|
105
|
+
app_root_absolute_path = File.expand_path(app_root)
|
106
|
+
metric_fu_absolute_path = File.expand_path(metric_fu_root)
|
107
|
+
metric_fu_absolute_path.should == app_root_absolute_path
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should set @template_directory to the lib/templates relative '+
|
111
|
+
'to @metric_fu_root_directory' do
|
112
|
+
template_dir = File.join(File.dirname(__FILE__),
|
113
|
+
'..', '..', 'lib','templates')
|
114
|
+
template_dir_abs_path = File.expand_path(template_dir)
|
115
|
+
calc_template_dir_abs_path = File.expand_path(template_directory)
|
116
|
+
calc_template_dir_abs_path.should == template_dir_abs_path
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should set @scratch_directory to scratch relative '+
|
120
|
+
'to @base_directory' do
|
121
|
+
scratch_dir = File.join(base_directory, 'scratch')
|
122
|
+
scratch_directory.should == scratch_dir
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should set @output_directory to output relative '+
|
126
|
+
'to @base_directory' do
|
127
|
+
output_dir = File.join(base_directory, 'output')
|
128
|
+
output_directory.should == output_dir
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should set @template_class to StandardTemplate' do
|
132
|
+
template_class.should == AwesomeTemplate
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should set @flay to {:dirs_to_flay => @code_dirs}' do
|
136
|
+
@config.instance_variable_get(:@flay).
|
137
|
+
should == {:dirs_to_flay => ['lib']}
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should set @flog to {:dirs_to_flog => @code_dirs}' do
|
141
|
+
@config.instance_variable_get(:@flog).
|
142
|
+
should == {:dirs_to_flog => ['lib']}
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'should set @reek to {:dirs_to_reek => @code_dirs}' do
|
146
|
+
@config.instance_variable_get(:@reek).
|
147
|
+
should == {:dirs_to_reek => ['lib']}
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should set @roodi to {:dirs_to_roodi => @code_dirs}' do
|
151
|
+
@config.instance_variable_get(:@roodi).
|
152
|
+
should == {:dirs_to_roodi => ['lib']}
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should set @churn to {}' do
|
156
|
+
@config.instance_variable_get(:@churn).
|
157
|
+
should == {}
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should set @stats to {}' do
|
161
|
+
@config.instance_variable_get(:@stats).
|
162
|
+
should == {}
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'should set @rcov to { :test_files => ["test/**/*_test.rb",
|
166
|
+
"spec/**/*_spec.rb"]
|
167
|
+
:rcov_opts => ["--sort coverage",
|
168
|
+
"--no-html",
|
169
|
+
"--text-coverage",
|
170
|
+
"--no-color",
|
171
|
+
"--profile",
|
172
|
+
"--rails",
|
173
|
+
"--exclude /gems/,/Library/,/usr/,spec"]}' do
|
174
|
+
@config.instance_variable_get(:@rcov).
|
175
|
+
should == { :test_files => ['test/**/*_test.rb',
|
176
|
+
'spec/**/*_spec.rb'],
|
177
|
+
:rcov_opts => ["--sort coverage",
|
178
|
+
"--no-html",
|
179
|
+
"--text-coverage",
|
180
|
+
"--no-color",
|
181
|
+
"--profile",
|
182
|
+
"--rails",
|
183
|
+
"--exclude /gems/,/Library/,/usr/,spec"]}
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'should set @saikuro to { :output_directory => @scratch_directory + "/saikuro",
|
187
|
+
:input_directory => @code_dirs,
|
188
|
+
:cyclo => "",
|
189
|
+
:filter_cyclo => "0",
|
190
|
+
:warn_cyclo => "5",
|
191
|
+
:error_cyclo => "7",
|
192
|
+
:formater => "text" }' do
|
193
|
+
@config.instance_variable_get(:@saikuro).
|
194
|
+
should == { :output_directory => 'tmp/metric_fu/scratch/saikuro',
|
195
|
+
:input_directory => ['lib'],
|
196
|
+
:cyclo => "",
|
197
|
+
:filter_cyclo => "0",
|
198
|
+
:warn_cyclo => "5",
|
199
|
+
:error_cyclo => "7",
|
200
|
+
:formater => "text"}
|
201
|
+
end
|
202
|
+
|
203
|
+
describe 'if #rails? is true ' do
|
204
|
+
before(:each) do
|
205
|
+
@config.stub!(:rails?).and_return(true)
|
206
|
+
end
|
207
|
+
|
208
|
+
describe '#set_metrics ' do
|
209
|
+
it 'should set the @metrics instance var to AVAILABLE_METRICS + '\
|
210
|
+
+'[:stats]' do
|
211
|
+
@config.instance_variable_get(:@metrics).
|
212
|
+
should == MetricFu::AVAILABLE_METRICS << [:stats]
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
describe '#set_code_dirs ' do
|
217
|
+
it 'should set the @code_dirs instance var to ["app", "lib"]' do
|
218
|
+
# This is hard to spec properly because the @code_dirs variable
|
219
|
+
# is set during the reset process.
|
220
|
+
#@config.instance_variable_get(:@code_dirs).
|
221
|
+
# should == ['app','lib']
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
describe 'if #rails? is false ' do
|
227
|
+
before(:each) do
|
228
|
+
@config.stub!(:rails?).and_return(false)
|
229
|
+
end
|
230
|
+
|
231
|
+
describe '#set_metrics ' do
|
232
|
+
it 'should set the @metrics instance var to AVAILABLE_METRICS' do
|
233
|
+
@config.instance_variable_get(:@metrics).
|
234
|
+
should == MetricFu::AVAILABLE_METRICS
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe '#set_code_dirs ' do
|
239
|
+
it 'should set the @code_dirs instance var to ["lib"]' do
|
240
|
+
@config.instance_variable_get(:@code_dirs).should == ['lib']
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
describe '#add_attr_accessors_to_self' do
|
247
|
+
|
248
|
+
before(:each) { get_new_config }
|
249
|
+
|
250
|
+
MetricFu::AVAILABLE_METRICS.each do |metric|
|
251
|
+
it "should have a reader for #{metric}" do
|
252
|
+
@config.respond_to?(metric).should be_true
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should have a writer for #{metric}=" do
|
256
|
+
@config.respond_to?((metric.to_s + '=').to_sym).should be_true
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
describe '#add_class_methods_to_metric_fu' do
|
262
|
+
|
263
|
+
before(:each) { get_new_config }
|
264
|
+
|
265
|
+
MetricFu::AVAILABLE_METRICS.each do |metric|
|
266
|
+
it "should add a #{metric} class method to the MetricFu module " do
|
267
|
+
MetricFu.respond_to?(metric).should be_true
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
describe '#platform' do
|
273
|
+
|
274
|
+
before(:each) { get_new_config }
|
275
|
+
|
276
|
+
it 'should return the value of the PLATFORM constant' do
|
277
|
+
this_platform = PLATFORM
|
278
|
+
@config.platform.should == this_platform
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
describe '#is_cruise_control_rb? ' do
|
283
|
+
|
284
|
+
before(:each) { get_new_config }
|
285
|
+
describe "when the CC_BUILD_ARTIFACTS env var is not nil" do
|
286
|
+
|
287
|
+
before(:each) { ENV['CC_BUILD_ARTIFACTS'] = 'is set' }
|
288
|
+
|
289
|
+
it 'should return true' do
|
290
|
+
@config.is_cruise_control_rb?.should be_true
|
291
|
+
end
|
292
|
+
|
293
|
+
end
|
294
|
+
|
295
|
+
describe "when the CC_BUILD_ARTIFACTS env var is nil" do
|
296
|
+
before(:each) { ENV['CC_BUILD_ARTIFACTS'] = nil }
|
297
|
+
|
298
|
+
it 'should return false' do
|
299
|
+
@config.is_cruise_control_rb?.should be_false
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|