flyerhzm-metric_fu 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/HISTORY +164 -0
  2. data/MIT-LICENSE +22 -0
  3. data/Manifest.txt +25 -0
  4. data/README.textile +27 -0
  5. data/Rakefile +18 -0
  6. data/TODO +9 -0
  7. data/lib/base/base_template.rb +145 -0
  8. data/lib/base/configuration.rb +180 -0
  9. data/lib/base/generator.rb +167 -0
  10. data/lib/base/graph.rb +39 -0
  11. data/lib/base/md5_tracker.rb +52 -0
  12. data/lib/base/report.rb +100 -0
  13. data/lib/generators/churn.rb +90 -0
  14. data/lib/generators/flay.rb +34 -0
  15. data/lib/generators/flog.rb +167 -0
  16. data/lib/generators/rails_best_practices.rb +31 -0
  17. data/lib/generators/rcov.rb +87 -0
  18. data/lib/generators/reek.rb +64 -0
  19. data/lib/generators/roodi.rb +32 -0
  20. data/lib/generators/saikuro.rb +208 -0
  21. data/lib/generators/stats.rb +43 -0
  22. data/lib/graphs/engines/bluff.rb +98 -0
  23. data/lib/graphs/engines/gchart.rb +119 -0
  24. data/lib/graphs/flay_grapher.rb +20 -0
  25. data/lib/graphs/flog_grapher.rb +40 -0
  26. data/lib/graphs/grapher.rb +11 -0
  27. data/lib/graphs/rails_best_practices_grapher.rb +20 -0
  28. data/lib/graphs/rcov_grapher.rb +20 -0
  29. data/lib/graphs/reek_grapher.rb +32 -0
  30. data/lib/graphs/roodi_grapher.rb +20 -0
  31. data/lib/metric_fu.rb +31 -0
  32. data/lib/templates/awesome/awesome_template.rb +37 -0
  33. data/lib/templates/awesome/churn.html.erb +19 -0
  34. data/lib/templates/awesome/css/buttons.css +82 -0
  35. data/lib/templates/awesome/css/default.css +75 -0
  36. data/lib/templates/awesome/css/integrity.css +335 -0
  37. data/lib/templates/awesome/css/reset.css +7 -0
  38. data/lib/templates/awesome/flay.html.erb +33 -0
  39. data/lib/templates/awesome/flog.html.erb +53 -0
  40. data/lib/templates/awesome/index.html.erb +31 -0
  41. data/lib/templates/awesome/layout.html.erb +30 -0
  42. data/lib/templates/awesome/rails_best_practices.html.erb +27 -0
  43. data/lib/templates/awesome/rcov.html.erb +42 -0
  44. data/lib/templates/awesome/reek.html.erb +40 -0
  45. data/lib/templates/awesome/roodi.html.erb +27 -0
  46. data/lib/templates/awesome/saikuro.html.erb +71 -0
  47. data/lib/templates/awesome/stats.html.erb +41 -0
  48. data/lib/templates/javascripts/bluff-min.js +1 -0
  49. data/lib/templates/javascripts/excanvas.js +19 -0
  50. data/lib/templates/javascripts/js-class.js +1 -0
  51. data/lib/templates/standard/churn.html.erb +31 -0
  52. data/lib/templates/standard/default.css +64 -0
  53. data/lib/templates/standard/flay.html.erb +34 -0
  54. data/lib/templates/standard/flog.html.erb +53 -0
  55. data/lib/templates/standard/index.html.erb +41 -0
  56. data/lib/templates/standard/rails_best_practices.html.erb +29 -0
  57. data/lib/templates/standard/rcov.html.erb +43 -0
  58. data/lib/templates/standard/reek.html.erb +42 -0
  59. data/lib/templates/standard/roodi.html.erb +29 -0
  60. data/lib/templates/standard/saikuro.html.erb +84 -0
  61. data/lib/templates/standard/standard_template.rb +26 -0
  62. data/lib/templates/standard/stats.html.erb +55 -0
  63. data/spec/base/base_template_spec.rb +161 -0
  64. data/spec/base/configuration_spec.rb +269 -0
  65. data/spec/base/generator_spec.rb +244 -0
  66. data/spec/base/graph_spec.rb +24 -0
  67. data/spec/base/md5_tracker_spec.rb +57 -0
  68. data/spec/base/report_spec.rb +139 -0
  69. data/spec/generators/churn_spec.rb +152 -0
  70. data/spec/generators/flay_spec.rb +104 -0
  71. data/spec/generators/flog_spec.rb +238 -0
  72. data/spec/generators/reek_spec.rb +126 -0
  73. data/spec/generators/saikuro_spec.rb +58 -0
  74. data/spec/generators/stats_spec.rb +74 -0
  75. data/spec/graphs/engines/bluff_spec.rb +15 -0
  76. data/spec/graphs/engines/gchart_spec.rb +15 -0
  77. data/spec/graphs/flay_grapher_spec.rb +37 -0
  78. data/spec/graphs/flog_grapher_spec.rb +45 -0
  79. data/spec/graphs/rcov_grapher_spec.rb +37 -0
  80. data/spec/graphs/reek_grapher_spec.rb +46 -0
  81. data/spec/graphs/roodi_grapher_spec.rb +37 -0
  82. data/spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html +10 -0
  83. data/spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html +16 -0
  84. data/spec/resources/saikuro/index_cyclo.html +155 -0
  85. data/spec/resources/saikuro_sfiles/thing.rb_cyclo.html +11 -0
  86. data/spec/resources/yml/20090630.yml +7844 -0
  87. data/spec/spec.opts +8 -0
  88. data/spec/spec_helper.rb +7 -0
  89. data/tasks/metric_fu.rake +22 -0
  90. data/vendor/_fonts/monaco.ttf +0 -0
  91. data/vendor/saikuro/saikuro.rb +1219 -0
  92. metadata +234 -0
@@ -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
+
@@ -0,0 +1,104 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Flay do
4
+ before :each do
5
+ MetricFu::Flay.stub!(:verify_dependencies!).and_return(true)
6
+ end
7
+ describe "emit method" do
8
+ before :each do
9
+ MetricFu::Configuration.run {|config| config.flay = { :dirs_to_flay => ['app', 'lib'] } }
10
+ File.stub!(:directory?).and_return(true)
11
+ @flay = MetricFu::Flay.new('base_dir')
12
+
13
+ end
14
+
15
+ it "should look at the dirs" do
16
+ Dir.should_receive(:[]).with(File.join("app", "**/*.rb")).and_return("path/to/app")
17
+ Dir.should_receive(:[]).with(File.join("lib", "**/*.rb")).and_return("path/to/lib")
18
+ @flay.should_receive(:`).with("flay path/to/app path/to/lib")
19
+ output = @flay.emit
20
+ end
21
+ end
22
+
23
+ describe "analyze method" do
24
+ before :each do
25
+ lines = <<-HERE
26
+ Total score (lower is better) = 246
27
+
28
+
29
+ 1) IDENTICAL code found in :or (mass*2 = 68)
30
+ app/controllers/link_targets_controller.rb:57
31
+ app/controllers/primary_sites_controller.rb:138
32
+
33
+ 2) Similar code found in :if (mass = 64)
34
+ app/controllers/primary_sites_controller.rb:75
35
+ app/controllers/primary_sites_controller.rb:76
36
+ app/controllers/primary_sites_controller.rb:88
37
+ app/controllers/primary_sites_controller.rb:89
38
+ HERE
39
+ MetricFu::Configuration.run {}
40
+ File.stub!(:directory?).and_return(true)
41
+ @flay = MetricFu::Flay.new('base_dir')
42
+ @flay.instance_variable_set(:@output, lines)
43
+ end
44
+
45
+ it "should analyze and return matches" do
46
+ @flay.analyze.should == [ ["Total score (lower is better) = 246"],
47
+ ["\n1) IDENTICAL code found in :or (mass*2 = 68)",
48
+ "app/controllers/link_targets_controller.rb:57",
49
+ "app/controllers/primary_sites_controller.rb:138"],
50
+ ["2) Similar code found in :if (mass = 64)",
51
+ "app/controllers/primary_sites_controller.rb:75",
52
+ "app/controllers/primary_sites_controller.rb:76",
53
+ "app/controllers/primary_sites_controller.rb:88",
54
+ "app/controllers/primary_sites_controller.rb:89"] ]
55
+ end
56
+ end
57
+
58
+ describe "to_h method" do
59
+
60
+ before :each do
61
+ lines = [ ["Total score (lower is better) = 284"],
62
+ ["\n1) IDENTICAL code found in :or (mass*2 = 68)",
63
+ "app/controllers/link_targets_controller.rb:57",
64
+ "app/controllers/primary_sites_controller.rb:138"],
65
+ ["2) Similar code found in :if (mass = 64)",
66
+ "app/controllers/primary_sites_controller.rb:75",
67
+ "app/controllers/primary_sites_controller.rb:76",
68
+ "app/controllers/primary_sites_controller.rb:88",
69
+ "app/controllers/primary_sites_controller.rb:89"],
70
+ ["3) Similar code found in :defn (mass = 40)",
71
+ "app/controllers/link_targets_controller.rb:40",
72
+ "app/controllers/primary_sites_controller.rb:98"],
73
+ ["4) Similar code found in :defn (mass = 38)",
74
+ "app/controllers/link_targets_controller.rb:13",
75
+ "app/controllers/primary_sites_controller.rb:50"],
76
+ ["5) Similar code found in :defn (mass = 38)",
77
+ "app/models/primary_site.rb:104",
78
+ "app/models/primary_site.rb:109"],
79
+ ["6) Similar code found in :call (mass = 36)",
80
+ "app/controllers/bookmarklet_integration_controller.rb:6",
81
+ "app/controllers/bookmarklet_integration_controller.rb:17"]]
82
+
83
+ MetricFu::Configuration.run {}
84
+ File.stub!(:directory?).and_return(true)
85
+ flay = MetricFu::Flay.new('base_dir')
86
+ flay.instance_variable_set(:@matches, lines)
87
+ @results = flay.to_h
88
+ end
89
+
90
+ it "should find the total_score" do
91
+ @results[:flay][:total_score].should == '284'
92
+ end
93
+
94
+ it "should have 6 matches" do
95
+ @results[:flay][:matches].size.should == 6
96
+ end
97
+
98
+ it "should capture info for match" do
99
+ @results[:flay][:matches].first[:reason].should =~ /IDENTICAL/
100
+ @results[:flay][:matches].first[:matches].first[:name].should =~ /link_targets_controller/
101
+ @results[:flay][:matches].first[:matches].first[:line].should == "57"
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,238 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ describe Flog do
3
+ before :each do
4
+ @text = <<-HERE
5
+ 157.9: flog total
6
+ 11.3: flog/method average
7
+
8
+ 34.8: UsersController#create
9
+ 9.2: branch
10
+ 6.8: current_user
11
+ 5.2: assignment
12
+ 3.4: role
13
+ 3.0: render
14
+ 3.0: ==
15
+ 2.8: flash
16
+ 1.6: after_create_page
17
+ 1.6: params
18
+ 1.5: activate!
19
+ 1.5: errors
20
+ 1.4: login
21
+ 1.4: redirect_to
22
+ 1.4: []
23
+ 1.3: empty?
24
+ 1.3: save
25
+ 1.2: new
26
+ 24.2: UsersController#authorize_user
27
+ 4.8: branch
28
+ 4.7: current_user
29
+ 3.6: params
30
+ 3.2: []
31
+ 2.6: ==
32
+ 1.5: role
33
+ 1.5: to_i
34
+ 1.5: id
35
+ 1.4: new_session_path
36
+ 1.3: include?
37
+ 1.2: assignment
38
+ 1.2: flash
39
+ 1.2: redirect_to
40
+ 16.4: UsersController#thank_you
41
+ 4.0: assignment
42
+ 3.3: params
43
+ 2.9: []
44
+ 2.7: redirect_to
45
+ 2.4: branch
46
+ 1.5: new_session_path
47
+ 1.4: flash
48
+ 1.4: activate!
49
+ 1.3: can_activate?
50
+ 1.2: find_by_id
51
+ 14.2: UsersController#update
52
+ 3.2: params
53
+ 2.8: []
54
+ 2.6: assignment
55
+ 1.4: login
56
+ 1.4: flash
57
+ 1.4: redirect_to
58
+ 1.3: render
59
+ 1.2: branch
60
+ 1.2: update_attributes
61
+ 1.2: find_by_id
62
+ 12.5: UsersController#sanitize_params
63
+ 3.9: assignment
64
+ 3.6: branch
65
+ 3.0: current_user
66
+ 1.6: params
67
+ 1.5: role
68
+ 1.4: []
69
+ 1.3: include?
70
+ 1.3: ==
71
+ 1.2: reject!
72
+ 10.6: UsersController#users_have_changed
73
+ 3.9: assignment
74
+ 2.6: branch
75
+ 1.6: params
76
+ 1.5: refresh_from_external
77
+ 1.4: find_by_id
78
+ 1.4: []
79
+ 1.2: split
80
+ 1.2: each
81
+ 1.2: head
82
+ 10.0: UsersController#after_create_page
83
+ 3.0: current_user
84
+ 2.6: id
85
+ 2.4: branch
86
+ 1.5: role
87
+ 1.3: login
88
+ 1.3: ==
89
+ 8.4: UsersController#add_primary_site
90
+ 2.4: assignment
91
+ 1.6: params
92
+ 1.4: []
93
+ 1.4: new
94
+ 1.2: find_by_id
95
+ 1.2: all
96
+ 1.2: render
97
+ 7.7: UsersController#none
98
+ 3.3: before_filter
99
+ 1.1: private
100
+ 1.1: caches_page
101
+ 1.1: after_filter
102
+ 1.1: skip_before_filter
103
+ 7.2: UsersController#destroy
104
+ 1.8: params
105
+ 1.6: []
106
+ 1.4: find_by_id
107
+ 1.2: destroy
108
+ 1.2: redirect_to
109
+ 5.9: UsersController#edit
110
+ 2.4: assignment
111
+ 1.6: params
112
+ 1.4: []
113
+ 1.2: all
114
+ 1.2: find_by_id
115
+ 2.7: UsersController#signup
116
+ 1.2: render
117
+ 1.2: assignment
118
+ 1.2: new
119
+ 1.7: UsersController#new
120
+ 1.2: assignment
121
+ 1.2: new
122
+ 1.7: UsersController#index
123
+ 1.2: assignment
124
+ 1.2: all
125
+ HERE
126
+ MetricFu::Flog.stub!(:verify_dependencies!).and_return(true)
127
+ end
128
+
129
+ describe "parse method" do
130
+ before :each do
131
+ MetricFu::Configuration.run {}
132
+ File.stub!(:directory?).and_return(true)
133
+ flog = MetricFu::Flog.new('base_dir')
134
+ @flog_page = flog.parse(@text)
135
+ end
136
+
137
+ it "should find the total score" do
138
+ @flog_page.score.should == 157.9
139
+ end
140
+
141
+ it "should find the average score" do
142
+ @flog_page.average_score.should == 11.3
143
+ end
144
+
145
+ it "should find the scanned method score" do
146
+ @flog_page.scanned_methods.first.score.should == 34.8
147
+ end
148
+
149
+ it "should find the scanned method name" do
150
+ @flog_page.scanned_methods.first.name.should == "UsersController#create"
151
+ end
152
+
153
+ it "should find the scanned method opperators names" do
154
+ @flog_page.scanned_methods.first.operators.first.operator.should == "branch"
155
+ end
156
+
157
+ it "should find the scanned method opperators scores" do
158
+ @flog_page.scanned_methods.first.operators.first.score.should == 9.2
159
+ end
160
+
161
+ it "should find the name of the method even if namespaced" do
162
+ text = <<-HERE
163
+ 157.9: flog total
164
+ 11.3: flog/method average
165
+
166
+ 34.8: SomeNamespace::UsersController#create
167
+ HERE
168
+ flog = MetricFu::Flog.new('base_dir')
169
+ flog_page = flog.parse(text)
170
+ flog_page.scanned_methods.first.name.should == "SomeNamespace::UsersController#create"
171
+ end
172
+
173
+ it "should parse empty flog files" do
174
+ text = ""
175
+ flog = MetricFu::Flog.new('base_dir')
176
+ flog_page = flog.parse(text)
177
+ flog_page.should be_nil
178
+ end
179
+ end
180
+
181
+ describe "to_h function with results" do
182
+ before :each do
183
+ MetricFu::Configuration.run {}
184
+ File.stub!(:directory?).and_return(true)
185
+ flog = MetricFu::Flog.new('base_dir')
186
+ flog.should_receive(:open).and_return(@text)
187
+ flog.stub!(:is_file_current?).and_return(true)
188
+ Dir.should_receive(:glob).and_return(["tmp/metric_fu/scratch/flog/app/controllers/user_controller.txt"])
189
+ flog.analyze
190
+ @flog_hash = flog.to_h
191
+ end
192
+
193
+ it "should put the total in the hash" do
194
+ @flog_hash[:flog][:total].should == 157.9
195
+ end
196
+
197
+ it "should put the average in the hash" do
198
+ @flog_hash[:flog][:average].should == 11.3
199
+ end
200
+
201
+ it "should put pages into the hash" do
202
+ @flog_hash[:flog][:pages].first[:scanned_methods].first[:score].should == 34.8
203
+ end
204
+
205
+ it "should put the filename into the hash" do
206
+ @flog_hash[:flog][:pages].first[:path].should == "/app/controllers/user_controller.rb"
207
+ end
208
+ end
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
+
228
+ describe "to_h function with zero total" do
229
+ it "should not blow up" do
230
+ MetricFu::Configuration.run {}
231
+ File.stub!(:directory?).and_return(true)
232
+ flog = MetricFu::Flog.new('base_dir')
233
+ flog.should_receive(:open).and_return("") # some sort of empty or unparsable file
234
+ Dir.should_receive(:glob).and_return(["empty_file.txt"])
235
+ flog.analyze
236
+ end
237
+ end
238
+ end