metric_fu 4.10.0 → 4.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -2
  4. data/.simplecov +42 -0
  5. data/.travis.yml +7 -6
  6. data/CONTRIBUTING.md +1 -1
  7. data/DEV.md +4 -3
  8. data/Gemfile +29 -7
  9. data/HISTORY.md +29 -3
  10. data/README.md +6 -1
  11. data/Rakefile +33 -11
  12. data/checksum/metric_fu-4.10.0.gem.sha512 +1 -1
  13. data/gem_tasks/usage_test.rake +0 -11
  14. data/lib/metric_fu.rb +12 -0
  15. data/lib/metric_fu/configuration.rb +1 -5
  16. data/lib/metric_fu/environment.rb +3 -3
  17. data/lib/metric_fu/formatter.rb +1 -1
  18. data/lib/metric_fu/formatter/html.rb +9 -9
  19. data/lib/metric_fu/gem_run.rb +2 -2
  20. data/lib/metric_fu/{metrics/generator.rb → generator.rb} +0 -0
  21. data/lib/metric_fu/loader.rb +30 -23
  22. data/lib/metric_fu/logger.rb +65 -0
  23. data/lib/metric_fu/logging/mf_debugger.rb +13 -48
  24. data/lib/metric_fu/metric.rb +3 -3
  25. data/lib/metric_fu/metrics/cane/{cane.rb → generator.rb} +0 -0
  26. data/lib/metric_fu/metrics/cane/{cane_grapher.rb → grapher.rb} +0 -0
  27. data/lib/metric_fu/metrics/cane/{init.rb → metric.rb} +1 -1
  28. data/lib/metric_fu/metrics/cane/{template_awesome/cane.html.erb → report.html.erb} +0 -0
  29. data/lib/metric_fu/metrics/churn/{churn.rb → generator.rb} +0 -0
  30. data/lib/metric_fu/metrics/churn/{churn_hotspot.rb → hotspot.rb} +0 -0
  31. data/lib/metric_fu/metrics/churn/{init.rb → metric.rb} +0 -0
  32. data/lib/metric_fu/metrics/churn/{template_awesome/churn.html.erb → report.html.erb} +0 -0
  33. data/lib/metric_fu/metrics/flay/{flay.rb → generator.rb} +16 -2
  34. data/lib/metric_fu/metrics/flay/{flay_grapher.rb → grapher.rb} +0 -0
  35. data/lib/metric_fu/metrics/flay/{flay_hotspot.rb → hotspot.rb} +0 -0
  36. data/lib/metric_fu/metrics/flay/{init.rb → metric.rb} +1 -1
  37. data/lib/metric_fu/metrics/flay/{template_awesome/flay.html.erb → report.html.erb} +0 -0
  38. data/lib/metric_fu/metrics/flog/{flog.rb → generator.rb} +0 -0
  39. data/lib/metric_fu/metrics/flog/{flog_grapher.rb → grapher.rb} +0 -0
  40. data/lib/metric_fu/metrics/flog/{flog_hotspot.rb → hotspot.rb} +0 -0
  41. data/lib/metric_fu/metrics/flog/{init.rb → metric.rb} +1 -1
  42. data/lib/metric_fu/metrics/flog/{template_awesome/flog.html.erb → report.html.erb} +0 -0
  43. data/lib/metric_fu/metrics/hotspots/{hotspots.rb → generator.rb} +1 -1
  44. data/lib/metric_fu/metrics/hotspots/{init.rb → metric.rb} +0 -0
  45. data/lib/metric_fu/metrics/hotspots/{template_awesome/hotspots.html.erb → report.html.erb} +0 -0
  46. data/lib/metric_fu/metrics/rails_best_practices/{rails_best_practices.rb → generator.rb} +0 -0
  47. data/lib/metric_fu/metrics/rails_best_practices/{rails_best_practices_grapher.rb → grapher.rb} +0 -0
  48. data/lib/metric_fu/metrics/rails_best_practices/{init.rb → metric.rb} +1 -1
  49. data/lib/metric_fu/metrics/rails_best_practices/{template_awesome/rails_best_practices.html.erb → report.html.erb} +0 -0
  50. data/lib/metric_fu/metrics/rcov/{rcov.rb → generator.rb} +0 -0
  51. data/lib/metric_fu/metrics/rcov/{rcov_grapher.rb → grapher.rb} +0 -0
  52. data/lib/metric_fu/metrics/rcov/{rcov_hotspot.rb → hotspot.rb} +0 -0
  53. data/lib/metric_fu/metrics/rcov/{init.rb → metric.rb} +0 -0
  54. data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +57 -9
  55. data/lib/metric_fu/metrics/rcov/{template_awesome/rcov.html.erb → report.html.erb} +0 -0
  56. data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +13 -2
  57. data/lib/metric_fu/metrics/reek/{reek.rb → generator.rb} +0 -0
  58. data/lib/metric_fu/metrics/reek/{reek_grapher.rb → grapher.rb} +0 -0
  59. data/lib/metric_fu/metrics/reek/{reek_hotspot.rb → hotspot.rb} +1 -1
  60. data/lib/metric_fu/metrics/reek/{init.rb → metric.rb} +0 -0
  61. data/lib/metric_fu/metrics/reek/{template_awesome/reek.html.erb → report.html.erb} +0 -0
  62. data/lib/metric_fu/metrics/roodi/{roodi.rb → generator.rb} +0 -0
  63. data/lib/metric_fu/metrics/roodi/{roodi_grapher.rb → grapher.rb} +0 -0
  64. data/lib/metric_fu/metrics/roodi/{roodi_hotspot.rb → hotspot.rb} +0 -0
  65. data/lib/metric_fu/metrics/roodi/{init.rb → metric.rb} +0 -0
  66. data/lib/metric_fu/metrics/roodi/{template_awesome/roodi.html.erb → report.html.erb} +0 -0
  67. data/lib/metric_fu/metrics/saikuro/{saikuro.rb → generator.rb} +0 -0
  68. data/lib/metric_fu/metrics/saikuro/{saikuro_hotspot.rb → hotspot.rb} +0 -0
  69. data/lib/metric_fu/metrics/saikuro/{init.rb → metric.rb} +0 -0
  70. data/lib/metric_fu/metrics/saikuro/{template_awesome/saikuro.html.erb → report.html.erb} +0 -0
  71. data/lib/metric_fu/metrics/stats/{stats.rb → generator.rb} +1 -1
  72. data/lib/metric_fu/metrics/stats/{stats_grapher.rb → grapher.rb} +0 -0
  73. data/lib/metric_fu/metrics/stats/{stats_hotspot.rb → hotspot.rb} +0 -0
  74. data/lib/metric_fu/metrics/stats/{init.rb → metric.rb} +0 -0
  75. data/lib/metric_fu/metrics/stats/{template_awesome/stats.html.erb → report.html.erb} +0 -0
  76. data/lib/metric_fu/{metrics → reporting/graphs}/graph.rb +0 -0
  77. data/lib/metric_fu/{reporting/templates/awesome → templates}/_graph.html.erb +0 -0
  78. data/lib/metric_fu/{reporting/templates/awesome → templates}/_report_footer.html.erb +0 -0
  79. data/lib/metric_fu/templates/configuration.rb +3 -2
  80. data/lib/metric_fu/{reporting/templates/awesome → templates}/index.html.erb +1 -1
  81. data/lib/metric_fu/{reporting/templates → templates}/javascripts/bluff-min.js +0 -0
  82. data/lib/metric_fu/{reporting/templates → templates}/javascripts/bluff_graph.js +0 -0
  83. data/lib/metric_fu/{reporting/templates → templates}/javascripts/excanvas.js +0 -0
  84. data/lib/metric_fu/{reporting/templates → templates}/javascripts/highcharts.js +0 -0
  85. data/lib/metric_fu/{reporting/templates → templates}/javascripts/highcharts_graph.js +0 -0
  86. data/lib/metric_fu/{reporting/templates → templates}/javascripts/js-class.js +0 -0
  87. data/lib/metric_fu/{reporting/templates → templates}/javascripts/standalone-framework.js +0 -0
  88. data/lib/metric_fu/{reporting/templates → templates}/javascripts/utils.js +0 -0
  89. data/lib/metric_fu/{reporting/templates/awesome → templates}/layout.html.erb +1 -1
  90. data/lib/metric_fu/templates/metrics_template.rb +68 -0
  91. data/lib/metric_fu/templates/report.rb +11 -3
  92. data/lib/metric_fu/{metrics/base_template.rb → templates/template.rb} +8 -24
  93. data/lib/metric_fu/utility.rb +25 -0
  94. data/lib/metric_fu/version.rb +1 -1
  95. data/metric_fu.gemspec +2 -0
  96. data/spec/capture_warnings.rb +48 -0
  97. data/spec/dummy/lib/bad_encoding.rb +6 -0
  98. data/spec/fixtures/coverage-153.rb +11 -0
  99. data/spec/fixtures/rcov_output.txt +135 -0
  100. data/spec/metric_fu/configuration_spec.rb +4 -265
  101. data/spec/metric_fu/formatter/configuration_spec.rb +46 -0
  102. data/spec/metric_fu/formatter/html_spec.rb +17 -25
  103. data/spec/metric_fu/formatter/yaml_spec.rb +1 -1
  104. data/spec/metric_fu/{metrics/generator_spec.rb → generator_spec.rb} +0 -0
  105. data/spec/metric_fu/metrics/cane/configuration_spec.rb +22 -0
  106. data/spec/metric_fu/metrics/cane/{cane_spec.rb → generator_spec.rb} +1 -1
  107. data/spec/metric_fu/metrics/churn/configuration_spec.rb +15 -0
  108. data/spec/metric_fu/metrics/churn/{churn_spec.rb → generator_spec.rb} +1 -1
  109. data/spec/metric_fu/metrics/flay/configuration_spec.rb +15 -0
  110. data/spec/metric_fu/metrics/flay/{flay_spec.rb → generator_spec.rb} +2 -2
  111. data/spec/metric_fu/metrics/flay/{flay_grapher_spec.rb → grapher_spec.rb} +1 -1
  112. data/spec/metric_fu/metrics/flog/configuration_spec.rb +20 -0
  113. data/spec/metric_fu/metrics/flog/{flog_spec.rb → generator_spec.rb} +1 -1
  114. data/spec/metric_fu/metrics/flog/{flog_grapher_spec.rb → grapher_spec.rb} +1 -1
  115. data/spec/metric_fu/metrics/hotspots/{hotspots_spec.rb → generator_spec.rb} +1 -1
  116. data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +47 -0
  117. data/spec/metric_fu/metrics/rails_best_practices/{rails_best_practices_spec.rb → generator_spec.rb} +1 -1
  118. data/spec/metric_fu/metrics/rails_best_practices/{rails_best_practices_grapher_spec.rb → grapher_spec.rb} +1 -1
  119. data/spec/metric_fu/metrics/rcov/configuration_spec.rb +30 -0
  120. data/spec/metric_fu/metrics/rcov/generator_spec.rb +26 -0
  121. data/spec/metric_fu/metrics/rcov/{rcov_grapher_spec.rb → grapher_spec.rb} +1 -1
  122. data/spec/metric_fu/metrics/rcov/{rcov_hotspot_spec.rb → hotspot_spec.rb} +2 -2
  123. data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +40 -12
  124. data/spec/metric_fu/metrics/reek/configuration_spec.rb +13 -0
  125. data/spec/metric_fu/metrics/reek/{reek_spec.rb → generator_spec.rb} +1 -1
  126. data/spec/metric_fu/metrics/reek/{reek_grapher_spec.rb → grapher_spec.rb} +1 -1
  127. data/spec/metric_fu/metrics/roodi/configuration_spec.rb +16 -0
  128. data/spec/metric_fu/metrics/roodi/{roodi_spec.rb → generator_spec.rb} +1 -1
  129. data/spec/metric_fu/metrics/roodi/{roodi_grapher_spec.rb → grapher_spec.rb} +1 -1
  130. data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +26 -0
  131. data/spec/metric_fu/metrics/saikuro/{saikuro_spec.rb → generator_spec.rb} +1 -1
  132. data/spec/metric_fu/metrics/stats/{stats_spec.rb → generator_spec.rb} +1 -1
  133. data/spec/metric_fu/metrics/stats/{stats_grapher_spec.rb → grapher_spec.rb} +1 -1
  134. data/spec/metric_fu/{metrics → reporting/graphs}/graph_spec.rb +1 -1
  135. data/spec/metric_fu/run_spec.rb +1 -1
  136. data/spec/metric_fu/templates/configuration_spec.rb +57 -0
  137. data/spec/metric_fu/templates/report_spec.rb +15 -0
  138. data/spec/metric_fu/{metrics/base_template_spec.rb → templates/template_spec.rb} +0 -0
  139. data/spec/quality_spec.rb +86 -0
  140. data/spec/shared/configured.rb +47 -0
  141. data/spec/shared/test_coverage.rb +99 -0
  142. data/spec/spec_helper.rb +9 -5
  143. data/spec/support/helper_methods.rb +3 -2
  144. data/spec/support/matcher_create_file.rb +2 -2
  145. data/spec/support/matcher_create_files.rb +2 -2
  146. data/spec/support/usage_test.rb +24 -7
  147. data/spec/usage_test_spec.rb +28 -2
  148. metadata +165 -112
  149. metadata.gz.sig +0 -0
  150. data/Gemfile.devtools +0 -39
  151. data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +0 -62
  152. data/spec/metric_fu/metrics/rcov/rcov_spec.rb +0 -185
@@ -0,0 +1,135 @@
1
+ Profiling enabled.
2
+ .............................................................................................................................................................................................
3
+
4
+
5
+ Top 10 slowest examples:
6
+ 0.2707830 MetricFu::RoodiGrapher responding to #get_metrics should push 13 to roodi_count
7
+ 0.1994550 MetricFu::RcovGrapher responding to #get_metrics should update labels with the date
8
+ 0.1985800 MetricFu::ReekGrapher responding to #get_metrics should set a hash of code smells to reek_count
9
+ 0.1919860 MetricFu::ReekGrapher responding to #get_metrics should update labels with the date
10
+ 0.1907400 MetricFu::RoodiGrapher responding to #get_metrics should update labels with the date
11
+ 0.1883000 MetricFu::FlogGrapher responding to #get_metrics should update labels with the date
12
+ 0.1882650 MetricFu::FlayGrapher responding to #get_metrics should push 476 to flay_score
13
+ 0.1868780 MetricFu::FlogGrapher responding to #get_metrics should push to top_five_percent_average
14
+ 0.1847730 MetricFu::FlogGrapher responding to #get_metrics should push 9.9 to flog_average
15
+ 0.1844090 MetricFu::FlayGrapher responding to #get_metrics should update labels with the date
16
+
17
+ Finished in 2.517686 seconds
18
+
19
+ 189 examples, 0 failures
20
+ ================================================================================
21
+ ./lib/metric_fu/metrics/hotspots/analysis/record.rb
22
+ ================================================================================
23
+ module MetricFu
24
+ class Record
25
+ --
26
+ attr_reader :data
27
+ --
28
+ def initialize(data, columns)
29
+ @data = data
30
+ -- end
31
+ --
32
+ def method_missing(name, *args, &block)
33
+ key = name.to_s
34
+ if key == 'fetch'
35
+ @data.send(name, *args, &block)
36
+ elsif @data.has_key?(key)
37
+ @data[key]
38
+ -- else
39
+ !! super(name, *args, &block)
40
+ -- end
41
+ -- end
42
+ --
43
+ def []=(key, value)
44
+ @data[key]=value
45
+ -- end
46
+ --
47
+ def [](key)
48
+ @data[key]
49
+ -- end
50
+ --
51
+ def has_key?(key)
52
+ @data.has_key?(key)
53
+ -- end
54
+ --
55
+ -- end
56
+ -- end
57
+
58
+ ================================================================================
59
+ ./lib/metric_fu/metrics/hotspots/analysis/table.rb
60
+ ================================================================================
61
+ %w(record).each do |path|
62
+ MetricFu.metrics_require { "hotspots/analysis/#{path}" }
63
+ -- end
64
+ --
65
+ module MetricFu
66
+ class Table
67
+ include Enumerable
68
+ --
69
+ def initialize(opts = {})
70
+ @rows = []
71
+ @columns = opts.fetch(:column_names)
72
+ --
73
+ @make_index = opts.fetch(:make_index) {true}
74
+ @metric_index = {}
75
+ -- end
76
+ --
77
+ def <<(row)
78
+ record = nil
79
+ if row.is_a?(MetricFu::Record)
80
+ record = row
81
+ -- else
82
+ record = MetricFu::Record.new(row, @columns)
83
+ -- end
84
+ @rows << record
85
+ updated_key_index(record) if @make_index
86
+ -- end
87
+ --
88
+ def concat(records)
89
+ !! records.each do |record|
90
+ !! self << record
91
+ -- end
92
+ !! self
93
+ -- end
94
+ --
95
+ def each
96
+ @rows.each do |row|
97
+ yield row
98
+ -- end
99
+ -- end
100
+ --
101
+ def size
102
+ length
103
+ -- end
104
+ --
105
+ def length
106
+ @rows.length
107
+ -- end
108
+ --
109
+ def [](index)
110
+ @rows[index]
111
+ -- end
112
+ --
113
+ def column(column_name)
114
+ arr = []
115
+ @rows.each do |row|
116
+ arr << row[column_name]
117
+ -- end
118
+ arr
119
+ -- end
120
+ --
121
+ def group_by_metric
122
+ @metric_index.to_a
123
+ -- end
124
+ --
125
+ private
126
+ --
127
+ def updated_key_index(record)
128
+ if record.has_key?('metric')
129
+ @metric_index[record.metric] ||= MetricFu::Table.new(:column_names => @columns, :make_index => false)
130
+ @metric_index[record.metric] << record
131
+ -- end
132
+ -- end
133
+ --
134
+ -- end
135
+ -- end
@@ -1,49 +1,9 @@
1
1
  require "spec_helper"
2
+ require 'shared/configured'
2
3
 
3
4
  describe MetricFu::Configuration do
4
5
 
5
- def get_new_config
6
- ENV['CC_BUILD_ARTIFACTS'] = nil
7
- @config = MetricFu.configuration
8
- @config.reset
9
- MetricFu.configuration.configure_metric(:rcov) do |rcov|
10
- rcov.enabled = true
11
- end
12
- MetricFu.configure
13
- allow(MetricFu::Io::FileSystem).to receive(:create_directories) # no need to create directories for the tests
14
- @config
15
- end
16
-
17
- def directory(name)
18
- MetricFu::Io::FileSystem.directory(name)
19
- end
20
-
21
- def base_directory
22
- directory('base_directory')
23
- end
24
-
25
- def output_directory
26
- directory('output_directory')
27
- end
28
-
29
- def scratch_directory
30
- directory('scratch_directory')
31
- end
32
-
33
- def template_directory
34
- directory('template_directory')
35
- end
36
-
37
- def template_class
38
- MetricFu::Formatter::Templates.option('template_class')
39
- end
40
-
41
- def metric_fu_root
42
- directory('root_directory')
43
- end
44
- def load_metric(metric)
45
- load File.join(MetricFu.metrics_dir, metric, 'init.rb')
46
- end
6
+ it_behaves_like 'configured' do
47
7
 
48
8
  describe '#is_cruise_control_rb? ' do
49
9
 
@@ -109,15 +69,7 @@ describe MetricFu::Configuration do
109
69
  app_root_absolute_path = File.expand_path(app_root)
110
70
  metric_fu_absolute_path = File.expand_path(metric_fu_root)
111
71
  expect(metric_fu_absolute_path).to eq(app_root_absolute_path)
112
- end
113
-
114
- it 'should set @template_directory to the lib/templates relative '+
115
- 'to @metric_fu_root_directory' do
116
- template_dir = File.join(File.dirname(__FILE__),
117
- '..', '..', 'lib','templates')
118
- template_dir_abs_path = File.expand_path(template_dir)
119
- calc_template_dir_abs_path = File.expand_path(template_directory)
120
- expect(calc_template_dir_abs_path).to eq(template_dir_abs_path)
72
+ expect(MetricFu.root.to_s).to eq(app_root_absolute_path)
121
73
  end
122
74
 
123
75
  it 'should set @scratch_directory to scratch relative '+
@@ -132,185 +84,8 @@ describe MetricFu::Configuration do
132
84
  expect(output_directory).to eq(output_dir)
133
85
  end
134
86
 
135
- it 'should set @template_class to AwesomeTemplate by default' do
136
- expect(template_class).to eq(AwesomeTemplate)
137
- end
138
-
139
- describe 'when a templates configuration is given' do
140
-
141
- before do
142
- class DummyTemplate;end
143
-
144
- @config.templates_configuration do |config|
145
- config.template_class = DummyTemplate
146
- config.link_prefix = 'http:/'
147
- config.syntax_highlighting = false
148
- config.darwin_txmt_protocol_no_thanks = false
149
- end
150
- end
151
-
152
- it 'should set given template_class' do
153
- expect(template_class).to eq(DummyTemplate)
154
- end
155
-
156
- it 'should set given link_prefix' do
157
- expect(MetricFu::Formatter::Templates.option('link_prefix')).to eq('http:/')
158
- end
159
-
160
- it 'should set given darwin_txmt_protocol_no_thanks' do
161
- expect(MetricFu::Formatter::Templates.option('darwin_txmt_protocol_no_thanks')).to be_falsey
162
- end
163
-
164
- it 'should set given syntax_highlighting' do
165
- expect(MetricFu::Formatter::Templates.option('syntax_highlighting')).to be_falsey
166
- end
167
-
168
- end
169
-
170
- it 'should set @flay to {:dirs_to_flay => @code_dirs}' do
171
- load_metric 'flay'
172
- expect(MetricFu::Metric.get_metric(:flay).run_options).to eq(
173
- {:dirs_to_flay => ['lib'], :filetypes=>["rb"], :minimum_score=>nil}
174
- )
175
- end
176
-
177
- it 'should set @reek to {:dirs_to_reek => @code_dirs}' do
178
- load_metric 'reek'
179
- expect(MetricFu::Metric.get_metric(:reek).run_options).to eq(
180
- {:config_file_pattern=>nil, :dirs_to_reek => ['lib']}
181
- )
182
- end
183
-
184
- it 'should set @roodi to {:dirs_to_roodi => @code_dirs}' do
185
- load_metric 'roodi'
186
- expect(MetricFu::Metric.get_metric(:roodi).run_options).to eq(
187
- { :dirs_to_roodi => directory('code_dirs'),
188
- :roodi_config => "#{directory('root_directory')}/config/roodi_config.yml"}
189
- )
190
- end
191
-
192
- it 'should set @churn to {}' do
193
- load_metric 'churn'
194
- expect(MetricFu::Metric.get_metric(:churn).run_options).to eq(
195
- { :start_date => %q("1 year ago"), :minimum_churn_count => 10, :ignore_files=>[], :data_directory=> MetricFu::Io::FileSystem.scratch_directory('churn')}
196
- )
197
- end
198
-
199
-
200
- it 'should set @rcov to ' +
201
- %q(:test_files => Dir['{spec,test}/**/*_{spec,test}.rb'],
202
- :rcov_opts => [
203
- "--sort coverage",
204
- "--no-html",
205
- "--text-coverage",
206
- "--no-color",
207
- "--profile",
208
- "--exclude-only '.*'",
209
- '--include-file "\Aapp,\Alib"',
210
- "-Ispec"
211
- ]) do
212
- load_metric 'rcov'
213
- expect(MetricFu::Metric.get_metric(:rcov).run_options).to eq(
214
- { :environment => 'test',
215
- :external => nil,
216
- :test_files => Dir['{spec,test}/**/*_{spec,test}.rb'],
217
- :rcov_opts => [
218
- "--sort coverage",
219
- "--no-html",
220
- "--text-coverage",
221
- "--no-color",
222
- "--profile",
223
- "--exclude-only '.*'",
224
- '--include-file "\Aapp,\Alib"',
225
- "-Ispec"
226
- ],
227
- }
228
- )
229
- end
230
-
231
- it 'should set @saikuro to { :output_directory => @scratch_directory + "/saikuro",
232
- :input_directory => @code_dirs,
233
- :cyclo => "",
234
- :filter_cyclo => "0",
235
- :warn_cyclo => "5",
236
- :error_cyclo => "7",
237
- :formater => "text" }' do
238
- load_metric 'saikuro'
239
- expect(MetricFu::Metric.get_metric(:saikuro).run_options).to eq(
240
- { :output_directory => "#{scratch_directory}/saikuro",
241
- :input_directory => ['lib'],
242
- :cyclo => "",
243
- :filter_cyclo => "0",
244
- :warn_cyclo => "5",
245
- :error_cyclo => "7",
246
- :formater => "text"}
247
- )
248
- end
249
-
250
- if MetricFu.configuration.mri?
251
- it 'should set @flog to {:dirs_to_flog => @code_dirs}' do
252
- load_metric 'flog'
253
- expect(MetricFu::Metric.get_metric(:flog).run_options).to eq({
254
- :all => true,
255
- :continue => true,
256
- :dirs_to_flog => ["lib"],
257
- :quiet => true
258
- })
259
- end
260
- it 'should set @cane to ' +
261
- %q(:dirs_to_cane => @code_dirs, :abc_max => 15, :line_length => 80, :no_doc => 'n', :no_readme => 'y') do
262
- load_metric 'cane'
263
- expect(MetricFu::Metric.get_metric(:cane).run_options).to eq(
264
- {
265
- :dirs_to_cane => directory('code_dirs'),
266
- :filetypes => ["rb"],
267
- :abc_max => 15,
268
- :line_length => 80,
269
- :no_doc => "n",
270
- :no_readme => "n"}
271
- )
272
- end
273
- end
274
-
275
-
276
87
  end
277
- describe 'if #rails? is true ' do
278
88
 
279
- before(:each) do
280
- @config = MetricFu.configuration
281
- allow(@config).to receive(:rails?).and_return(true)
282
- @config.reset
283
- MetricFu.configure
284
- %w(rails_best_practices).each do |metric|
285
- load_metric metric
286
- end
287
- end
288
-
289
- describe '#set_graphs ' do
290
- it 'should set the graphs to include rails_best_practices' do
291
- expect(MetricFu::Metric.get_metric(:rails_best_practices).has_graph?).to be_truthy
292
- end
293
- end
294
-
295
- it 'should set @rails_best_practices to {}' do
296
- load_metric 'rails_best_practices'
297
- expect(MetricFu::Metric.get_metric(:rails_best_practices).run_options).to eql({})
298
- end
299
- end
300
-
301
- describe 'if #rails? is false ' do
302
- before(:each) do
303
- get_new_config
304
- allow(@config).to receive(:rails?).and_return(false)
305
- %w(rails_best_practices).each do |metric|
306
- load_metric metric
307
- end
308
- end
309
-
310
- it 'should set the registered code_dirs to ["lib"]' do
311
- expect(directory('code_dirs')).to eq(['lib'])
312
- end
313
- end
314
89
  end
315
90
 
316
91
  describe '#platform' do
@@ -323,41 +98,5 @@ describe MetricFu::Configuration do
323
98
  end
324
99
  end
325
100
 
326
- describe '#configure_formatter' do
327
- before(:each) { get_new_config }
328
-
329
- context 'given a built-in formatter' do
330
- before do
331
- @config.configure_formatter('html')
332
- end
333
-
334
- it 'adds to the list of formatters' do
335
- expect(@config.formatters.first).to be_an_instance_of(MetricFu::Formatter::HTML)
336
- end
337
- end
338
-
339
- context 'given a custom formatter by class name' do
340
- before do
341
- stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
342
- @config.configure_formatter('MyCustomFormatter')
343
- end
344
-
345
- it 'adds to the list of formatters' do
346
- expect(@config.formatters.first).to be_an_instance_of(MyCustomFormatter)
347
- end
348
- end
349
-
350
- context 'given multiple formatters' do
351
- before do
352
- stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
353
- @config.configure_formatter('html')
354
- @config.configure_formatter('yaml')
355
- @config.configure_formatter('MyCustomFormatter')
356
- end
357
-
358
- it 'adds each to the list of formatters' do
359
- expect(@config.formatters.count).to eq(3)
360
- end
361
- end
362
- end
101
+ end
363
102
  end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+ require 'shared/configured'
3
+
4
+ describe MetricFu::Configuration, 'for formatters' do
5
+ it_behaves_like 'configured' do
6
+
7
+ describe '#configure_formatter' do
8
+ before(:each) { get_new_config }
9
+
10
+ context 'given a built-in formatter' do
11
+ before do
12
+ @config.configure_formatter('html')
13
+ end
14
+
15
+ it 'adds to the list of formatters' do
16
+ expect(@config.formatters.first).to be_an_instance_of(MetricFu::Formatter::HTML)
17
+ end
18
+ end
19
+
20
+ context 'given a custom formatter by class name' do
21
+ before do
22
+ stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
23
+ @config.configure_formatter('MyCustomFormatter')
24
+ end
25
+
26
+ it 'adds to the list of formatters' do
27
+ expect(@config.formatters.first).to be_an_instance_of(MyCustomFormatter)
28
+ end
29
+ end
30
+
31
+ context 'given multiple formatters' do
32
+ before do
33
+ stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
34
+ @config.configure_formatter('html')
35
+ @config.configure_formatter('yaml')
36
+ @config.configure_formatter('MyCustomFormatter')
37
+ end
38
+
39
+ it 'adds each to the list of formatters' do
40
+ expect(@config.formatters.count).to eq(3)
41
+ end
42
+ end
43
+ end
44
+
45
+ end
46
+ end