metric_fu 4.3.1 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.metrics +55 -26
  3. data/.travis.yml +4 -1
  4. data/AUTHORS +12 -0
  5. data/Gemfile +1 -0
  6. data/HISTORY.md +24 -0
  7. data/README.md +27 -22
  8. data/checksum/metric_fu-4.3.1.gem.sha512 +1 -0
  9. data/checksum/metric_fu-4.4.0.gem.sha512 +1 -0
  10. data/lib/metric_fu.rb +28 -79
  11. data/lib/metric_fu/cli/helper.rb +1 -1
  12. data/lib/metric_fu/cli/parser.rb +1 -1
  13. data/lib/metric_fu/configuration.rb +104 -150
  14. data/lib/metric_fu/environment.rb +88 -0
  15. data/lib/metric_fu/formatter.rb +23 -0
  16. data/lib/metric_fu/formatter/html.rb +12 -9
  17. data/lib/metric_fu/initial_requires.rb +1 -0
  18. data/lib/metric_fu/io.rb +60 -1
  19. data/lib/metric_fu/load_files.rb +4 -2
  20. data/lib/metric_fu/loader.rb +62 -0
  21. data/lib/metric_fu/metric.rb +102 -0
  22. data/lib/metric_fu/metrics/base_template.rb +15 -9
  23. data/lib/metric_fu/metrics/cane/cane.rb +9 -5
  24. data/lib/metric_fu/metrics/cane/init.rb +35 -13
  25. data/lib/metric_fu/metrics/churn/churn.rb +5 -1
  26. data/lib/metric_fu/metrics/churn/init.rb +24 -4
  27. data/lib/metric_fu/metrics/flay/flay.rb +7 -3
  28. data/lib/metric_fu/metrics/flay/init.rb +29 -13
  29. data/lib/metric_fu/metrics/flay/template_awesome/flay.html.erb +1 -1
  30. data/lib/metric_fu/metrics/flog/flog.rb +14 -38
  31. data/lib/metric_fu/metrics/flog/init.rb +30 -7
  32. data/lib/metric_fu/metrics/generator.rb +21 -6
  33. data/lib/metric_fu/metrics/graph.rb +2 -2
  34. data/lib/metric_fu/metrics/hotspots/hotspots.rb +5 -1
  35. data/lib/metric_fu/metrics/hotspots/init.rb +21 -5
  36. data/lib/metric_fu/metrics/rails_best_practices/init.rb +29 -5
  37. data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb +20 -27
  38. data/lib/metric_fu/metrics/rails_best_practices/template_awesome/rails_best_practices.html.erb +1 -1
  39. data/lib/metric_fu/metrics/rcov/init.rb +40 -15
  40. data/lib/metric_fu/metrics/rcov/rcov.rb +15 -10
  41. data/lib/metric_fu/metrics/reek/init.rb +25 -6
  42. data/lib/metric_fu/metrics/reek/reek.rb +52 -31
  43. data/lib/metric_fu/metrics/reek/template_awesome/reek.html.erb +1 -1
  44. data/lib/metric_fu/metrics/roodi/init.rb +25 -6
  45. data/lib/metric_fu/metrics/roodi/roodi.rb +7 -3
  46. data/lib/metric_fu/metrics/saikuro/init.rb +22 -6
  47. data/lib/metric_fu/metrics/saikuro/saikuro.rb +8 -3
  48. data/lib/metric_fu/metrics/stats/init.rb +28 -5
  49. data/lib/metric_fu/metrics/stats/stats.rb +24 -6
  50. data/lib/metric_fu/metrics/stats/template_awesome/stats.html.erb +2 -2
  51. data/lib/metric_fu/parser_ext.rb +15 -0
  52. data/lib/metric_fu/reporting/graphs/engines/gchart.rb +1 -1
  53. data/lib/metric_fu/reporting/graphs/engines/init.rb +18 -4
  54. data/lib/metric_fu/reporting/graphs/grapher.rb +1 -1
  55. data/lib/metric_fu/reporting/result.rb +13 -6
  56. data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +1 -1
  57. data/lib/metric_fu/run.rb +7 -10
  58. data/lib/metric_fu/sexp_ext.rb +11 -0
  59. data/lib/metric_fu/version.rb +1 -1
  60. data/metric_fu.gemspec +23 -20
  61. data/spec/cli/helper_spec.rb +5 -16
  62. data/spec/metric_fu/configuration_spec.rb +62 -88
  63. data/spec/metric_fu/formatter/html_spec.rb +26 -16
  64. data/spec/metric_fu/formatter/yaml_spec.rb +2 -2
  65. data/spec/metric_fu/metric_spec.rb +50 -0
  66. data/spec/metric_fu/metrics/base_template_spec.rb +9 -7
  67. data/spec/metric_fu/metrics/cane/cane_spec.rb +19 -24
  68. data/spec/metric_fu/metrics/churn/churn_spec.rb +8 -8
  69. data/spec/metric_fu/metrics/flay/flay_spec.rb +7 -13
  70. data/spec/metric_fu/metrics/flog/flog_spec.rb +63 -58
  71. data/spec/metric_fu/metrics/generator_spec.rb +4 -0
  72. data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +7 -7
  73. data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +14 -33
  74. data/spec/metric_fu/metrics/rcov/rcov_spec.rb +17 -18
  75. data/spec/metric_fu/metrics/reek/reek_spec.rb +9 -10
  76. data/spec/metric_fu/metrics/roodi/roodi_spec.rb +5 -11
  77. data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +15 -14
  78. data/spec/metric_fu/metrics/stats/stats_spec.rb +5 -6
  79. data/spec/metric_fu/reporting/graphs/engines/bluff_spec.rb +2 -3
  80. data/spec/metric_fu/reporting/graphs/engines/gchart_spec.rb +12 -9
  81. data/spec/metric_fu/reporting/result_spec.rb +3 -3
  82. data/spec/run_spec.rb +45 -29
  83. data/spec/spec_helper.rb +7 -0
  84. data/spec/support/helper_methods.rb +9 -0
  85. data/spec/support/suite.rb +17 -11
  86. metadata +59 -56
  87. data/bin/mf-rails_best_practices +0 -9
  88. data/bin/mf-stats +0 -7
@@ -12,63 +12,72 @@ describe MetricFu::Formatter::HTML do
12
12
  # for some platforms.
13
13
  @metric_with_graph = MetricFu.configuration.mri? ? :cane : :flay
14
14
  @metric_without_graph = :hotspots
15
+ MetricFu.configuration.configure_metrics.each do |metric|
16
+ metric.enabled = true if [@metric_with_graph, @metric_without_graph].include?(metric.name)
17
+ end
18
+
15
19
  MetricFu.result.add(@metric_with_graph) # metric w/ graph
16
20
  MetricFu.result.add(@metric_without_graph) # metric w/out graph
17
21
  end
18
22
 
23
+ def directory(name)
24
+ MetricFu::Io::FileSystem.directory(name)
25
+ end
26
+
19
27
  context "In general" do
20
28
 
21
29
  it "creates a report yaml file" do
22
30
  # For backward compatibility.
23
31
  expect {
24
32
  MetricFu::Formatter::HTML.new.finish
25
- }.to create_file("#{MetricFu.base_directory}/report.yml")
33
+ }.to create_file("#{directory('base_directory')}/report.yml")
26
34
  end
27
35
 
28
36
  it "creates a data yaml file" do
29
37
  # For use with graphs.
30
38
  expect {
31
39
  MetricFu::Formatter::HTML.new.finish
32
- }.to create_file("#{MetricFu.data_directory}/#{Time.now.strftime("%Y%m%d")}.yml")
40
+ }.to create_file("#{directory('data_directory')}/#{Time.now.strftime("%Y%m%d")}.yml")
33
41
  end
34
42
 
35
43
  it "creates a report index html file" do
36
44
  expect {
37
45
  MetricFu::Formatter::HTML.new.finish
38
- }.to create_file("#{MetricFu.output_directory}/index.html")
46
+ }.to create_file("#{directory('output_directory')}/index.html")
39
47
  end
40
48
 
41
49
  it "creates templatized html files for each metric" do
42
50
  expect {
43
51
  MetricFu::Formatter::HTML.new.finish
44
52
  }.to create_files([
45
- "#{MetricFu.output_directory}/#{@metric_with_graph}.html",
46
- "#{MetricFu.output_directory}/#{@metric_without_graph}.html"
53
+ "#{directory('output_directory')}/#{@metric_with_graph}.html",
54
+ "#{directory('output_directory')}/#{@metric_without_graph}.html"
47
55
  ])
48
56
  end
49
57
 
50
58
  it "copies common javascripts to the output directory" do
51
59
  expect {
52
60
  MetricFu::Formatter::HTML.new.finish
53
- }.to create_file("#{MetricFu.output_directory}/bluff*.js")
61
+ }.to create_file("#{directory('output_directory')}/bluff*.js")
54
62
  end
55
63
 
56
64
  it "creates graphs for appropriate metrics" do
57
65
  expect {
58
66
  MetricFu::Formatter::HTML.new.finish
59
67
  }.to create_files([
60
- "#{MetricFu.output_directory}/#{@metric_with_graph}.js",
68
+ "#{directory('output_directory')}/#{@metric_with_graph}.js",
61
69
  ])
62
70
  end
63
71
 
64
72
  context 'when on OS X' do
65
73
  before do
66
- MetricFu.configuration.stub(:platform).and_return('darwin')
74
+ MetricFu.configuration.stub(:osx?).and_return(true)
75
+ MetricFu.configuration.stub(:is_cruise_control_rb?).and_return(false)
67
76
  end
68
77
 
69
78
  it "can open the results in the browser" do
70
79
  formatter = MetricFu::Formatter::HTML.new
71
- formatter.should_receive(:system).with("open #{Pathname.pwd.join(MetricFu.output_directory).join('index.html')}")
80
+ formatter.should_receive(:system).with("open #{Pathname.pwd.join(directory('output_directory')).join('index.html')}")
72
81
  formatter.finish
73
82
  formatter.display_results
74
83
  end
@@ -85,40 +94,41 @@ describe MetricFu::Formatter::HTML do
85
94
  it "creates the report index html file in the custom output directory" do
86
95
  expect {
87
96
  MetricFu::Formatter::HTML.new(output: @output).finish
88
- }.to create_file("#{MetricFu.base_directory}/#{@output}/index.html")
97
+ }.to create_file("#{directory('base_directory')}/#{@output}/index.html")
89
98
  end
90
99
 
91
100
  it "creates templatized html files for each metric in the custom output directory" do
92
101
  expect {
93
102
  MetricFu::Formatter::HTML.new(output: @output).finish
94
103
  }.to create_files([
95
- "#{MetricFu.base_directory}/#{@output}/#{@metric_with_graph}.html",
96
- "#{MetricFu.base_directory}/#{@output}/#{@metric_without_graph}.html"
104
+ "#{directory('base_directory')}/#{@output}/#{@metric_with_graph}.html",
105
+ "#{directory('base_directory')}/#{@output}/#{@metric_without_graph}.html"
97
106
  ])
98
107
  end
99
108
 
100
109
  it "copies common javascripts to the custom output directory" do
101
110
  expect {
102
111
  MetricFu::Formatter::HTML.new(output: @output).finish
103
- }.to create_file("#{MetricFu.base_directory}/#{@output}/bluff*.js")
112
+ }.to create_file("#{directory('base_directory')}/#{@output}/bluff*.js")
104
113
  end
105
114
 
106
115
  it "creates graphs for appropriate metrics in the custom output directory " do
107
116
  expect {
108
117
  MetricFu::Formatter::HTML.new(output: @output).finish
109
118
  }.to create_file(
110
- "#{MetricFu.base_directory}/#{@output}/#{@metric_with_graph}.js",
119
+ "#{directory('base_directory')}/#{@output}/#{@metric_with_graph}.js",
111
120
  )
112
121
  end
113
122
 
114
123
  context 'when on OS X' do
115
124
  before do
116
- MetricFu.configuration.stub(:platform).and_return('darwin')
125
+ MetricFu.configuration.stub(:osx?).and_return(true)
126
+ MetricFu.configuration.stub(:is_cruise_control_rb?).and_return(false)
117
127
  end
118
128
 
119
129
  it "can open the results in the browser from the custom output directory" do
120
130
  formatter = MetricFu::Formatter::HTML.new(output: @output)
121
- path = Pathname.pwd.join("#{MetricFu.base_directory}/#{@output}/index.html")
131
+ path = Pathname.pwd.join("#{directory('base_directory')}/#{@output}/index.html")
122
132
  formatter.should_receive(:system).with("open #{path}")
123
133
  formatter.finish
124
134
  formatter.display_results
@@ -17,7 +17,7 @@ describe MetricFu::Formatter::YAML do
17
17
  it "creates a report yaml file" do
18
18
  expect {
19
19
  MetricFu::Formatter::YAML.new.finish
20
- }.to create_file("#{MetricFu.base_directory}/report.yml")
20
+ }.to create_file("#{directory('base_directory')}/report.yml")
21
21
  end
22
22
 
23
23
  end
@@ -31,7 +31,7 @@ describe MetricFu::Formatter::YAML do
31
31
  it "creates a report yaml file to the custom output path" do
32
32
  expect {
33
33
  MetricFu::Formatter::YAML.new(output: @output).finish
34
- }.to create_file("#{MetricFu.base_directory}/customreport.yml")
34
+ }.to create_file("#{directory('base_directory')}/customreport.yml")
35
35
  end
36
36
 
37
37
  end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe MetricFu::Metric do
4
+ before do
5
+ @metric = MetricFu::Metric.get_metric(:flog)
6
+ #@original_options = @metric.run_options.dup
7
+ end
8
+
9
+ #it 'can have its run_options over-written' do
10
+ #new_options = {:foo => 'bar'}
11
+ #@metric.run_options = new_options
12
+ #expect(@original_options).to_not eq(new_options)
13
+ #expect(@metric.run_options).to eq(new_options)
14
+ #end
15
+
16
+ #it 'can have its run_options modified' do
17
+ #new_options = {:foo => 'bar'}
18
+ #@metric.run_options.merge!(new_options)
19
+ #expect(@metric.run_options).to eq(@original_options.merge(new_options))
20
+ #end
21
+
22
+ context 'given a valid configurable option' do
23
+
24
+ before do
25
+ @metric.stub(:default_run_options).and_return({:foo => 'baz'})
26
+ end
27
+
28
+ it 'can be configured as an attribute' do
29
+ @metric.foo = 'qux'
30
+ expect(@metric.run_options[:foo]).to eq('qux')
31
+ end
32
+
33
+ end
34
+
35
+ context 'given an invalid configurable option' do
36
+
37
+ before do
38
+ @metric.stub(:default_run_options).and_return({})
39
+ end
40
+
41
+ it 'raises an error' do
42
+ expect { @metric.foo = 'bar' }.to raise_error(RuntimeError, /not a valid configuration option/)
43
+ end
44
+
45
+ end
46
+
47
+ after do
48
+ @metric.configured_run_options.clear
49
+ end
50
+ end
@@ -87,9 +87,10 @@ describe MetricFu::Template do
87
87
  describe "when on OS X" do
88
88
  before(:each) do
89
89
  config = double("configuration")
90
+ config.stub(:osx?).and_return(true)
90
91
  config.stub(:platform).and_return('universal-darwin-9.0')
91
- config.stub(:darwin_txmt_protocol_no_thanks).and_return(false)
92
- config.stub(:link_prefix).and_return(nil)
92
+ MetricFu::Formatter::Templates.stub(:option).with('darwin_txmt_protocol_no_thanks').and_return(false)
93
+ MetricFu::Formatter::Templates.stub(:option).with('link_prefix').and_return(nil)
93
94
  MetricFu.stub(:configuration).and_return(config)
94
95
  end
95
96
 
@@ -117,9 +118,11 @@ describe MetricFu::Template do
117
118
  describe "but no thanks for txtmt" do
118
119
  before(:each) do
119
120
  config = double("configuration")
121
+ config.stub(:osx?).and_return(true)
120
122
  config.stub(:platform).and_return('universal-darwin-9.0')
121
- config.stub(:darwin_txmt_protocol_no_thanks).and_return(true)
122
123
  config.stub(:link_prefix).and_return(nil)
124
+ MetricFu::Formatter::Templates.stub(:option).with('darwin_txmt_protocol_no_thanks').and_return(true)
125
+ MetricFu::Formatter::Templates.stub(:option).with('link_prefix').and_return(nil)
123
126
  MetricFu.stub(:configuration).and_return(config)
124
127
  @template.should_receive(:complete_file_path).and_return('filename')
125
128
  end
@@ -144,9 +147,8 @@ describe MetricFu::Template do
144
147
  describe "when on other platforms" do
145
148
  before(:each) do
146
149
  config = double("configuration")
147
- config.should_receive(:platform).and_return('other')
148
- config.stub(:link_prefix).and_return(nil)
149
- config.stub(:darwin_txmt_protocol_no_thanks).and_return(false)
150
+ config.should_receive(:osx?).and_return(false)
151
+ MetricFu::Formatter::Templates.stub(:option).with('link_prefix').and_return(nil)
150
152
  MetricFu.stub(:configuration).and_return(config)
151
153
  @template.should_receive(:complete_file_path).and_return('filename')
152
154
  end
@@ -160,7 +162,7 @@ describe MetricFu::Template do
160
162
  describe "when configured with a link_prefix" do
161
163
  before(:each) do
162
164
  config = double("configuration")
163
- config.should_receive(:link_prefix).and_return('http://example.org/files')
165
+ MetricFu::Formatter::Templates.stub(:option).with('link_prefix').and_return('http://example.org/files')
164
166
  MetricFu.stub(:configuration).and_return(config)
165
167
  @template.should_receive(:complete_file_path).and_return('filename')
166
168
  end
@@ -1,59 +1,53 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Cane do
3
+ describe CaneGenerator do
4
4
  describe "emit method" do
5
- def configure_cane_with(options={})
6
- MetricFu::Configuration.run {|config|
7
- config.add_metric(:cane)
8
- config.configure_metric(:cane, options)
9
- }
10
- end
11
5
 
12
6
  it "should execute cane command" do
13
- configure_cane_with({})
14
- @cane = MetricFu::Cane.new('base_dir')
7
+ options = {}
8
+ @cane = MetricFu::CaneGenerator.new(options)
15
9
  @cane.should_receive(:`).with("mf-cane")
16
10
  output = @cane.emit
17
11
  end
18
12
 
19
13
  it "should use abc max option" do
20
- configure_cane_with({abc_max: 20})
21
- @cane = MetricFu::Cane.new('base_dir')
14
+ options = {abc_max: 20}
15
+ @cane = MetricFu::CaneGenerator.new(options)
22
16
  @cane.should_receive(:`).with("mf-cane --abc-max 20")
23
17
  output = @cane.emit
24
18
  end
25
19
 
26
20
  it "should use style max line length option" do
27
- configure_cane_with({line_length: 100})
28
- @cane = MetricFu::Cane.new('base_dir')
21
+ options = {line_length: 100}
22
+ @cane = MetricFu::CaneGenerator.new(options)
29
23
  @cane.should_receive(:`).with("mf-cane --style-measure 100")
30
24
  output = @cane.emit
31
25
  end
32
26
 
33
27
  it "should use no-doc if specified" do
34
- configure_cane_with({no_doc: 'y'})
35
- @cane = MetricFu::Cane.new('base_dir')
28
+ options = {no_doc: 'y'}
29
+ @cane = MetricFu::CaneGenerator.new(options)
36
30
  @cane.should_receive(:`).with("mf-cane --no-doc")
37
31
  output = @cane.emit
38
32
  end
39
33
 
40
34
  it "should include doc violations if no_doc != 'y'" do
41
- configure_cane_with({no_doc: 'n'})
42
- @cane = MetricFu::Cane.new('base_dir')
35
+ options = {no_doc: 'n'}
36
+ @cane = MetricFu::CaneGenerator.new(options)
43
37
  @cane.should_receive(:`).with("mf-cane")
44
38
  output = @cane.emit
45
39
  end
46
40
 
47
41
  it "should use no-readme if specified" do
48
- configure_cane_with({no_readme: 'y'})
49
- @cane = MetricFu::Cane.new('base_dir')
42
+ options = {no_readme: 'y'}
43
+ @cane = MetricFu::CaneGenerator.new(options)
50
44
  @cane.should_receive(:`).with("mf-cane --no-readme")
51
45
  output = @cane.emit
52
46
  end
53
47
 
54
48
  it "should include README violations if no_readme != 'y'" do
55
- configure_cane_with({no_readme: 'n'})
56
- @cane = MetricFu::Cane.new('base_dir')
49
+ options = {no_readme: 'n'}
50
+ @cane = MetricFu::CaneGenerator.new(options)
57
51
  @cane.should_receive(:`).with("mf-cane")
58
52
  output = @cane.emit
59
53
  end
@@ -61,9 +55,10 @@ describe Cane do
61
55
 
62
56
  describe "parse cane empty output" do
63
57
  before :each do
64
- MetricFu::Configuration.run {}
58
+ # MetricFu::Configuration.run {}
65
59
  File.stub(:directory?).and_return(true)
66
- @cane = MetricFu::Cane.new('base_dir')
60
+ options = {}
61
+ @cane = MetricFu::CaneGenerator.new(options)
67
62
  @cane.instance_variable_set(:@output, '')
68
63
  end
69
64
 
@@ -81,7 +76,7 @@ describe Cane do
81
76
  lines = sample_cane_output
82
77
  MetricFu::Configuration.run {}
83
78
  File.stub(:directory?).and_return(true)
84
- @cane = MetricFu::Cane.new('base_dir')
79
+ @cane = MetricFu::CaneGenerator.new('base_dir')
85
80
  @cane.instance_variable_set(:@output, lines)
86
81
  end
87
82
 
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Churn do
3
+ describe MetricFu::ChurnGenerator do
4
4
 
5
5
  let(:churn_yaml) { "--- \n:churn: \n :changed_files: \n - spec/graphs/flog_grapher_spec.rb\n - spec/base/graph_spec.rb\n - lib/templates/awesome/layout.html.erb\n - lib/graphs/rcov_grapher.rb\n - lib/base/base_template.rb\n - spec/graphs/grapher_spec.rb\n - lib/templates/awesome/flog.html.erb\n - lib/templates/awesome/flay.html.erb\n - lib/graphs/roodi_grapher.rb\n - lib/graphs/reek_grapher.rb\n - HISTORY\n - spec/graphs/roodi_grapher_spec.rb\n - lib/generators/rcov.rb\n - spec/graphs/engines/gchart_spec.rb\n - spec/graphs/rcov_grapher_spec.rb\n - lib/templates/javascripts/excanvas.js\n - lib/templates/javascripts/bluff-min.js\n - spec/graphs/reek_grapher_spec.rb\n" }
6
6
 
@@ -16,12 +16,12 @@ describe Churn do
16
16
  end
17
17
 
18
18
  it "initializes with yaml option" do
19
- churn = MetricFu::Churn.new
19
+ churn = MetricFu::ChurnGenerator.new
20
20
  churn.send(:build_churn_options).should == "--yaml"
21
21
  end
22
22
 
23
23
  it "initializes with given minimum_churn_count option" do
24
- churn = MetricFu::Churn.new( { :minimum_churn_count => 5 })
24
+ churn = MetricFu::ChurnGenerator.new( { :minimum_churn_count => 5 })
25
25
  churn.send(:build_churn_options).should == "--yaml --minimum_churn_count=5"
26
26
  end
27
27
  end
@@ -34,21 +34,21 @@ describe Churn do
34
34
  end
35
35
 
36
36
  it "should be empty on error text" do
37
- churn = MetricFu::Churn.new
37
+ churn = MetricFu::ChurnGenerator.new
38
38
  churn.instance_variable_set(:@output, "Churning requires a subversion or git repo")
39
39
  result = churn.analyze
40
40
  result.should == {:churn => {}}
41
41
  end
42
42
 
43
43
  it "should be empty on error no output captured" do
44
- churn = MetricFu::Churn.new
44
+ churn = MetricFu::ChurnGenerator.new
45
45
  churn.instance_variable_set(:@output, nil)
46
46
  result = churn.analyze
47
47
  result.should == {:churn => {}}
48
48
  end
49
49
 
50
50
  it "should return yaml results" do
51
- churn = MetricFu::Churn.new
51
+ churn = MetricFu::ChurnGenerator.new
52
52
  churn.instance_variable_set(:@output, churn_yaml)
53
53
  result = churn.analyze
54
54
  result.should == {:churn => {:changed_files => ["spec/graphs/flog_grapher_spec.rb", "spec/base/graph_spec.rb", "lib/templates/awesome/layout.html.erb", "lib/graphs/rcov_grapher.rb", "lib/base/base_template.rb", "spec/graphs/grapher_spec.rb", "lib/templates/awesome/flog.html.erb", "lib/templates/awesome/flay.html.erb", "lib/graphs/roodi_grapher.rb", "lib/graphs/reek_grapher.rb", "HISTORY", "spec/graphs/roodi_grapher_spec.rb", "lib/generators/rcov.rb", "spec/graphs/engines/gchart_spec.rb", "spec/graphs/rcov_grapher_spec.rb", "lib/templates/javascripts/excanvas.js", "lib/templates/javascripts/bluff-min.js", "spec/graphs/reek_grapher_spec.rb"]}}
@@ -63,7 +63,7 @@ describe Churn do
63
63
  end
64
64
 
65
65
  it "should put the changes into a hash" do
66
- churn = MetricFu::Churn.new
66
+ churn = MetricFu::ChurnGenerator.new
67
67
  churn.instance_variable_set(:@churn, {:churn => 'results'})
68
68
  churn.to_h[:churn].should == "results"
69
69
  end
@@ -73,7 +73,7 @@ describe Churn do
73
73
  describe "emit method" do
74
74
  before :each do
75
75
  config_setup
76
- @churn = MetricFu::Churn.new
76
+ @churn = MetricFu::ChurnGenerator.new
77
77
  end
78
78
 
79
79
  it "returns churn output" do
@@ -1,26 +1,20 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Flay do
3
+ describe MetricFu::FlayGenerator do
4
4
  describe "emit method" do
5
5
  it "should look at the dirs" do
6
- MetricFu::Configuration.run {|config|
7
- config.add_metric(:flay)
8
- config.configure_metric(:flay, { :dirs_to_flay => ['app', 'lib'], :filetypes => ['rb'] })
9
- }
6
+ options = { :dirs_to_flay => ['app', 'lib'], :filetypes => ['rb'] }
10
7
  File.stub(:directory?).and_return(true)
11
- @flay = MetricFu::Flay.new('base_dir')
8
+ @flay = MetricFu::FlayGenerator.new(options)
12
9
 
13
10
  @flay.should_receive(:`).with("mf-flay app lib")
14
11
  output = @flay.emit
15
12
  end
16
13
 
17
14
  it "should limit flay scores by the minimum_score" do
18
- MetricFu::Configuration.run {|config|
19
- config.add_metric(:flay)
20
- config.configure_metric(:flay, { :dirs_to_flay => [], :minimum_score => 99 })
21
- }
15
+ options = { :dirs_to_flay => [], :minimum_score => 99 }
22
16
  File.stub(:directory?).and_return(true)
23
- @flay = MetricFu::Flay.new('base_dir')
17
+ @flay = MetricFu::FlayGenerator.new(options)
24
18
 
25
19
  @flay.should_receive(:`).with("mf-flay --mass 99 ")
26
20
  output = @flay.emit
@@ -45,7 +39,7 @@ Total score (lower is better) = 246
45
39
  HERE
46
40
  MetricFu::Configuration.run {}
47
41
  File.stub(:directory?).and_return(true)
48
- @flay = MetricFu::Flay.new('base_dir')
42
+ @flay = MetricFu::FlayGenerator.new('base_dir')
49
43
  @flay.instance_variable_set(:@output, lines)
50
44
  end
51
45
 
@@ -89,7 +83,7 @@ Total score (lower is better) = 246
89
83
 
90
84
  MetricFu::Configuration.run {}
91
85
  File.stub(:directory?).and_return(true)
92
- flay = MetricFu::Flay.new('base_dir')
86
+ flay = MetricFu::FlayGenerator.new('base_dir')
93
87
  flay.instance_variable_set(:@matches, lines)
94
88
  @results = flay.to_h
95
89
  end