nielsm-metric_fu 0.9.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +38 -0
- data/README +1 -154
- data/Rakefile +9 -2
- data/TODO +3 -3
- data/lib/base/base_template.rb +146 -0
- data/lib/base/configuration.rb +207 -0
- data/lib/base/generator.rb +160 -0
- data/lib/base/graph.rb +37 -0
- data/lib/{metric_fu → base}/md5_tracker.rb +0 -0
- data/lib/base/report.rb +100 -0
- data/lib/{metric_fu → generators}/churn.rb +26 -23
- data/lib/generators/flay.rb +34 -0
- data/lib/generators/flog.rb +140 -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 +208 -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 -3
- data/lib/templates/awesome/awesome_template.rb +30 -0
- data/lib/templates/awesome/churn.html.erb +19 -0
- data/lib/templates/awesome/default.css +75 -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/{churn.html.erb → standard/churn.html.erb} +13 -4
- data/lib/templates/{default.css → standard/default.css} +20 -1
- data/lib/templates/{flay.html.erb → standard/flay.html.erb} +13 -9
- 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/{roodi.html.erb → standard/roodi.html.erb} +11 -8
- 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 +161 -0
- data/spec/base/configuration_spec.rb +303 -0
- data/spec/base/generator_spec.rb +181 -0
- data/spec/{md5_tracker_spec.rb → base/md5_tracker_spec.rb} +1 -1
- 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 +219 -0
- data/spec/generators/reek_spec.rb +60 -0
- data/spec/generators/saikuro_spec.rb +58 -0
- data/spec/generators/stats_spec.rb +74 -0
- data/spec/graphs/flog_grapher_spec.rb +15 -0
- data/spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html +10 -0
- data/spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html +16 -0
- data/spec/resources/saikuro/index_cyclo.html +155 -0
- data/spec/resources/saikuro_sfiles/thing.rb_cyclo.html +10 -0
- data/spec/spec.opts +8 -0
- data/spec/spec_helper.rb +24 -7
- data/tasks/metric_fu.rake +22 -0
- data/vendor/_fonts/monaco.ttf +0 -0
- data/{lib/metric_fu → vendor}/saikuro/saikuro.rb +0 -0
- metadata +84 -66
- data/lib/metric_fu/base.rb +0 -160
- data/lib/metric_fu/flay.rb +0 -17
- data/lib/metric_fu/flog.rb +0 -129
- data/lib/metric_fu/reek.rb +0 -17
- data/lib/metric_fu/roodi.rb +0 -17
- data/lib/tasks/churn.rake +0 -9
- data/lib/tasks/coverage.rake +0 -54
- data/lib/tasks/flay.rake +0 -6
- data/lib/tasks/flog.rake +0 -69
- data/lib/tasks/metric_fu.rake +0 -24
- data/lib/tasks/metric_fu.rb +0 -6
- data/lib/tasks/railroad.rake +0 -39
- data/lib/tasks/reek.rake +0 -6
- data/lib/tasks/roodi.rake +0 -7
- data/lib/tasks/saikuro.rake +0 -35
- data/lib/tasks/stats.rake +0 -14
- data/lib/templates/flog.html.erb +0 -38
- data/lib/templates/flog_page.html.erb +0 -25
- data/lib/templates/reek.html.erb +0 -30
- data/spec/base_spec.rb +0 -57
- data/spec/churn_spec.rb +0 -117
- data/spec/config_spec.rb +0 -110
- data/spec/flay_spec.rb +0 -19
- data/spec/flog_spec.rb +0 -208
- data/spec/reek_spec.rb +0 -26
@@ -0,0 +1,181 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe MetricFu::Generator do
|
4
|
+
|
5
|
+
MetricFu::Configuration.run do |config|
|
6
|
+
end
|
7
|
+
|
8
|
+
class ConcreteClass < MetricFu::Generator
|
9
|
+
def emit
|
10
|
+
end
|
11
|
+
|
12
|
+
def analyze
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_h
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
@concrete_class = ConcreteClass.new
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "ConcreteClass#class_name" do
|
24
|
+
it "should be 'concreteclass'" do
|
25
|
+
ConcreteClass.class_name.should == 'concreteclass'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "ConcreteClass#metric_directory" do
|
30
|
+
it "should be 'tmp/metric_fu/scratch/concreteclass'" do
|
31
|
+
ConcreteClass.metric_directory.
|
32
|
+
should == "tmp/metric_fu/scratch/concreteclass"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#create_metric_dir_if_missing " do
|
37
|
+
describe "when the metric_dir exists " do
|
38
|
+
it 'should not call mkdir_p on FileUtils' do
|
39
|
+
File.stub!(:directory?).and_return(true)
|
40
|
+
FileUtils.should_not_receive(:mkdir_p)
|
41
|
+
@concrete_class.create_metric_dir_if_missing
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when the metric_dir does not exist " do
|
46
|
+
it 'should call mkdir_p on FileUtils' do
|
47
|
+
File.stub!(:directory?).and_return(false)
|
48
|
+
FileUtils.should_receive(:mkdir_p)
|
49
|
+
@concrete_class.create_metric_dir_if_missing
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#create_output_dir_if_missing" do
|
55
|
+
describe "when the output_dir exists " do
|
56
|
+
it 'should not call mkdir_p on FileUtils' do
|
57
|
+
File.stub!(:directory?).and_return(true)
|
58
|
+
FileUtils.should_not_receive(:mkdir_p)
|
59
|
+
@concrete_class.create_output_dir_if_missing
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "when the output_dir does not exist " do
|
64
|
+
it 'should call mkdir_p on FileUtils' do
|
65
|
+
File.stub!(:directory?).and_return(false)
|
66
|
+
FileUtils.should_receive(:mkdir_p)
|
67
|
+
@concrete_class.create_output_dir_if_missing
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#metric_directory' do
|
73
|
+
it 'should return the results of ConcreteClass#metric_directory' do
|
74
|
+
ConcreteClass.stub!(:metric_directory).and_return('foo')
|
75
|
+
@concrete_class.metric_directory.should == 'foo'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe 'ConcreteClass#generate_report' do
|
80
|
+
it 'should create a new instance of ConcreteClass' do
|
81
|
+
ConcreteClass.should_receive(:new).and_return(@concrete_class)
|
82
|
+
@concrete_class.should_receive(:generate_report).and_return(true)
|
83
|
+
ConcreteClass.generate_report
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should call #generate_report on the new ConcreteClass' do
|
87
|
+
ConcreteClass.should_receive(:new).and_return(@concrete_class)
|
88
|
+
@concrete_class.should_receive(:generate_report).and_return(true)
|
89
|
+
ConcreteClass.generate_report
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '@concrete_class should have hook methods for '\
|
94
|
+
+'[before|after]_[emit|analyze|to_h]' do
|
95
|
+
|
96
|
+
%w[emit analyze].each do |meth|
|
97
|
+
|
98
|
+
it "should respond to #before_#{meth}" do
|
99
|
+
@concrete_class.respond_to?("before_#{meth}".to_sym).should be_true
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should respond to #after_#{meth}" do
|
103
|
+
@concrete_class.respond_to?("after_#{meth}".to_sym).should be_true
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should respond to #before_to_h" do
|
108
|
+
@concrete_class.respond_to?("before_to_h".to_sym).should be_true
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#generate_report" do
|
113
|
+
it 'should raise an error when calling #emit' do
|
114
|
+
@abstract_class = MetricFu::Generator.new
|
115
|
+
lambda { @abstract_class.generate_report }.should raise_error
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should call #analyze' do
|
119
|
+
@abstract_class = MetricFu::Generator.new
|
120
|
+
lambda { @abstract_class.generate_report }.should raise_error
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should call #to_h' do
|
124
|
+
@abstract_class = MetricFu::Generator.new
|
125
|
+
lambda { @abstract_class.generate_report }.should raise_error
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "#generate_report (in a concrete class)" do
|
130
|
+
|
131
|
+
%w[emit analyze].each do |meth|
|
132
|
+
it "should call #before_#{meth}" do
|
133
|
+
@concrete_class.should_receive("before_#{meth}")
|
134
|
+
@concrete_class.generate_report
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should call ##{meth}" do
|
138
|
+
@concrete_class.should_receive("#{meth}")
|
139
|
+
@concrete_class.generate_report
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should call #after_#{meth}" do
|
143
|
+
@concrete_class.should_receive("after_#{meth}")
|
144
|
+
@concrete_class.generate_report
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should call #before_to_h" do
|
149
|
+
@concrete_class.should_receive("before_to_h")
|
150
|
+
@concrete_class.generate_report
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should call #to_h" do
|
154
|
+
@concrete_class.should_receive(:to_h)
|
155
|
+
@concrete_class.generate_report
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should raise error if the concrete class is missing a required dependency" do
|
159
|
+
concrete_class_with_missing_gem = Class.new(MetricFu::Generator) do
|
160
|
+
def self.verify_dependencies!
|
161
|
+
raise 'gem install something # if you want these tasks'
|
162
|
+
end
|
163
|
+
end
|
164
|
+
lambda { concrete_class_with_missing_gem.generate_report }.should raise_error("gem install something # if you want these tasks")
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "instantiation" do
|
170
|
+
it "should fail is dependencies not verified" do
|
171
|
+
ConcreteClass.should_receive(:verify_dependencies!).and_raise("Missing a required gem. Please 'gem install something'")
|
172
|
+
lambda { ConcreteClass.new() }.should raise_error("Missing a required gem. Please 'gem install something'")
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should succeed when dependencies verified" do
|
176
|
+
ConcreteClass.should_receive(:verify_dependencies!).and_return(true)
|
177
|
+
ConcreteClass.new()
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe MetricFu do
|
4
|
+
|
5
|
+
describe "#report" do
|
6
|
+
it 'should return an instance of Report' do
|
7
|
+
MetricFu.report.instance_of?(Report).should be(true)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe MetricFu::Report do
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
@report = MetricFu::Report.new
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#to_yaml" do
|
19
|
+
it 'should call #report_hash' do
|
20
|
+
report_hash = mock('report_hash')
|
21
|
+
report_hash.should_receive(:to_yaml)
|
22
|
+
@report.should_receive(:report_hash).and_return(report_hash)
|
23
|
+
@report.to_yaml
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#report_hash" do
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#save_templatized_report" do
|
31
|
+
it 'should create a new template class assign a report_hash '\
|
32
|
+
'to the template class, and ask it to write itself out' do
|
33
|
+
template_class = mock('template_class')
|
34
|
+
template_class.should_receive(:new).and_return(template_class)
|
35
|
+
MetricFu.should_receive(:template_class).and_return(template_class)
|
36
|
+
template_class.should_receive(:report=)
|
37
|
+
template_class.should_receive(:write)
|
38
|
+
@report.save_templatized_report
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#add" do
|
43
|
+
it 'should add a passed hash to the report_hash instance variable' do
|
44
|
+
report_type = mock('report_type')
|
45
|
+
report_type.should_receive(:to_s).and_return('type')
|
46
|
+
report_type.should_receive(:generate_report).and_return({:a => 'b'})
|
47
|
+
MetricFu.should_receive(:const_get).
|
48
|
+
with('Type').and_return(report_type)
|
49
|
+
report_hash = mock('report_hash')
|
50
|
+
report_hash.should_receive(:merge!).with({:a => 'b'})
|
51
|
+
@report.should_receive(:report_hash).and_return(report_hash)
|
52
|
+
@report.add(report_type)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#save_output" do
|
57
|
+
it 'should write the passed content to dir/index.html' do
|
58
|
+
f = mock('file')
|
59
|
+
content = 'content'
|
60
|
+
@report.should_receive(:open).with('dir/file', 'w').and_yield(f)
|
61
|
+
f.should_receive(:puts).with(content)
|
62
|
+
@report.save_output(content, 'dir', 'file')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#open_in_browser? ' do
|
67
|
+
|
68
|
+
before(:each) do
|
69
|
+
@config = mock('configuration')
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'when the platform is os x ' do
|
73
|
+
|
74
|
+
before(:each) do
|
75
|
+
@config.should_receive(:platform).and_return('darwin')
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'and we are in cruise control ' do
|
79
|
+
|
80
|
+
before(:each) do
|
81
|
+
@config.should_receive(:is_cruise_control_rb?).and_return(true)
|
82
|
+
MetricFu.stub!(:configuration).and_return(@config)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should return false' do
|
86
|
+
@report.open_in_browser?.should be_false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe 'and we are not in cruise control' do
|
91
|
+
|
92
|
+
before(:each) do
|
93
|
+
@config.should_receive(:is_cruise_control_rb?).and_return(false)
|
94
|
+
MetricFu.stub!(:configuration).and_return(@config)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should return true' do
|
98
|
+
@report.open_in_browser?.should be_true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe 'when the platform is not os x ' do
|
104
|
+
before(:each) do
|
105
|
+
@config.should_receive(:platform).and_return('other')
|
106
|
+
end
|
107
|
+
|
108
|
+
describe 'and we are in cruise control' do
|
109
|
+
before(:each) do
|
110
|
+
MetricFu.stub!(:configuration).and_return(@config)
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should return false' do
|
114
|
+
@report.open_in_browser?.should be_false
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe 'and we are not in cruise control' do
|
119
|
+
before(:each) do
|
120
|
+
MetricFu.stub!(:configuration).and_return(@config)
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should return false' do
|
124
|
+
@report.open_in_browser?.should be_false
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
describe '#show_in_browser' do
|
132
|
+
it 'should call open with the passed directory' do
|
133
|
+
@report.should_receive(:open_in_browser?).and_return(true)
|
134
|
+
@report.should_receive(:system).with("open my_dir/index.html")
|
135
|
+
@report.show_in_browser('my_dir')
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Churn do
|
4
|
+
describe "initialize" do
|
5
|
+
before :each do
|
6
|
+
MetricFu::Configuration.run {}
|
7
|
+
File.stub!(:directory?).and_return(true)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should setup git if .git exits" do
|
11
|
+
MetricFu::Churn.should_receive(:system).and_return(true)
|
12
|
+
Churn::Git.should_receive(:new)
|
13
|
+
MetricFu::Churn.new
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should setup git if .svn exits" do
|
17
|
+
MetricFu::Churn.should_receive(:system).and_return(false)
|
18
|
+
File.should_receive(:exist?).with(".svn").and_return(true)
|
19
|
+
Churn::Svn.should_receive(:new)
|
20
|
+
MetricFu::Churn.new()
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should raise an error if not .svn or .git" do
|
24
|
+
MetricFu::Churn.should_receive(:system).and_return(false)
|
25
|
+
lambda{MetricFu::Churn.new()}.should raise_error(Exception)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "emit method with git" do
|
30
|
+
before :each do
|
31
|
+
MetricFu::Configuration.run {|config| config.churn = {:minimum_churn_count => 2} }
|
32
|
+
File.stub!(:directory?).and_return(true)
|
33
|
+
MetricFu::Churn.should_receive(:system).and_return(true)
|
34
|
+
@git = Churn::Git.new
|
35
|
+
Churn::Git.should_receive(:new).and_return(@git)
|
36
|
+
@lines = <<-HERE.gsub(/^\s*/, "")
|
37
|
+
|
38
|
+
lib/generators/flog.rb
|
39
|
+
spec/generators/flog_spec.rb
|
40
|
+
|
41
|
+
|
42
|
+
lib/generators/flog.rb
|
43
|
+
spec/generators/flay_spec.rb
|
44
|
+
|
45
|
+
|
46
|
+
lib/metric_fu.rb
|
47
|
+
|
48
|
+
|
49
|
+
lib/generators/saikuro.rb
|
50
|
+
lib/metric_fu.rb
|
51
|
+
tasks/metric_fu.rake
|
52
|
+
|
53
|
+
|
54
|
+
spec/churn_spec.rb
|
55
|
+
spec/config_spec.rb
|
56
|
+
spec/flay_spec.rb
|
57
|
+
spec/flog_spec.rb
|
58
|
+
lib/metric_fu.rb
|
59
|
+
spec/reek_spec.rb
|
60
|
+
HERE
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should read the logs" do
|
64
|
+
churn = MetricFu::Churn.new
|
65
|
+
@git.should_receive(:`).with("git log --name-only --pretty=format:").and_return(@lines)
|
66
|
+
changes = churn.emit
|
67
|
+
changes["lib/generators/flog.rb"].should == 2
|
68
|
+
changes["lib/metric_fu.rb"].should == 3
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "emit method with svn" do
|
73
|
+
before :each do
|
74
|
+
MetricFu::Configuration.run{|config| config.churn = {:minimum_churn_count => 2} }
|
75
|
+
File.stub!(:directory?).and_return(true)
|
76
|
+
MetricFu::Churn.should_receive(:system).and_return(false)
|
77
|
+
File.should_receive(:exist?).with(".svn").and_return(true)
|
78
|
+
@svn = Churn::Svn.new
|
79
|
+
Churn::Svn.should_receive(:new).and_return(@svn)
|
80
|
+
@lines = <<-HERE.gsub(/^\s*/, "")
|
81
|
+
------------------------------------------------------------------------
|
82
|
+
r3183 | dave | 2009-04-28 07:23:37 -0500 (Tue, 28 Apr 2009) | 1 line
|
83
|
+
Changed paths:
|
84
|
+
M /trunk/app/views/promotions/index.erb
|
85
|
+
M /trunk/app/models/email_personalizer.rb
|
86
|
+
|
87
|
+
making custom macros case-insensitive
|
88
|
+
------------------------------------------------------------------------
|
89
|
+
r3182 | marc | 2009-04-28 03:59:32 -0500 (Tue, 28 Apr 2009) | 1 line
|
90
|
+
Changed paths:
|
91
|
+
M /trunk/app/models/file_extraction.rb
|
92
|
+
M /trunk/app/views/promotions/index.erb
|
93
|
+
M /trunk/config/environment.rb
|
94
|
+
|
95
|
+
Demo of the drop out effect for uploading promotions.
|
96
|
+
------------------------------------------------------------------------
|
97
|
+
r3181 | dave | 2009-04-27 21:40:04 -0500 (Mon, 27 Apr 2009) | 1 line
|
98
|
+
Changed paths:
|
99
|
+
M /trunk/app/views/promotions/index.erb
|
100
|
+
A /trunk/app/models/file_extraction.rb
|
101
|
+
A /trunk/app/models/url_file_extraction.rb
|
102
|
+
M /trunk/app/models/zip_file_extraction.rb
|
103
|
+
M /trunk/test/data/zip_test.zip
|
104
|
+
M /trunk/test/unit/zip_file_extraction_test.rb
|
105
|
+
|
106
|
+
URL imports
|
107
|
+
HERE
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should read the logs" do
|
111
|
+
churn = MetricFu::Churn.new
|
112
|
+
@svn.should_receive(:`).with("svn log --verbose").and_return(@lines)
|
113
|
+
changes = churn.emit
|
114
|
+
changes["/trunk/app/views/promotions/index.erb"].should == 3
|
115
|
+
changes["/trunk/app/models/file_extraction.rb"].should == 2
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "analyze method" do
|
120
|
+
before :each do
|
121
|
+
MetricFu::Configuration.run {}
|
122
|
+
File.stub!(:directory?).and_return(true)
|
123
|
+
MetricFu::Churn.should_receive(:system).and_return(true)
|
124
|
+
@changes = {"lib/generators/flog.rb"=>2, "lib/metric_fu.rb"=>3}
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should organize and format" do
|
128
|
+
churn = MetricFu::Churn.new
|
129
|
+
churn.instance_variable_set(:@changes, @changes)
|
130
|
+
changes = churn.analyze
|
131
|
+
changes.first[:file_path].should == "lib/metric_fu.rb"
|
132
|
+
changes.first[:times_changed].should == 3
|
133
|
+
changes[1][:file_path].should == "lib/generators/flog.rb"
|
134
|
+
changes[1][:times_changed].should == 2
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "to_h method" do
|
139
|
+
before :each do
|
140
|
+
MetricFu::Configuration.run {}
|
141
|
+
File.stub!(:directory?).and_return(true)
|
142
|
+
MetricFu::Churn.should_receive(:system).and_return(true)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should put the changes into a hash" do
|
146
|
+
churn = MetricFu::Churn.new
|
147
|
+
churn.instance_variable_set(:@changes, "churn_info")
|
148
|
+
churn.to_h[:churn][:changes].should == "churn_info"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|