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.
- checksums.yaml +7 -0
- data/.metrics +55 -26
- data/.travis.yml +4 -1
- data/AUTHORS +12 -0
- data/Gemfile +1 -0
- data/HISTORY.md +24 -0
- data/README.md +27 -22
- data/checksum/metric_fu-4.3.1.gem.sha512 +1 -0
- data/checksum/metric_fu-4.4.0.gem.sha512 +1 -0
- data/lib/metric_fu.rb +28 -79
- data/lib/metric_fu/cli/helper.rb +1 -1
- data/lib/metric_fu/cli/parser.rb +1 -1
- data/lib/metric_fu/configuration.rb +104 -150
- data/lib/metric_fu/environment.rb +88 -0
- data/lib/metric_fu/formatter.rb +23 -0
- data/lib/metric_fu/formatter/html.rb +12 -9
- data/lib/metric_fu/initial_requires.rb +1 -0
- data/lib/metric_fu/io.rb +60 -1
- data/lib/metric_fu/load_files.rb +4 -2
- data/lib/metric_fu/loader.rb +62 -0
- data/lib/metric_fu/metric.rb +102 -0
- data/lib/metric_fu/metrics/base_template.rb +15 -9
- data/lib/metric_fu/metrics/cane/cane.rb +9 -5
- data/lib/metric_fu/metrics/cane/init.rb +35 -13
- data/lib/metric_fu/metrics/churn/churn.rb +5 -1
- data/lib/metric_fu/metrics/churn/init.rb +24 -4
- data/lib/metric_fu/metrics/flay/flay.rb +7 -3
- data/lib/metric_fu/metrics/flay/init.rb +29 -13
- data/lib/metric_fu/metrics/flay/template_awesome/flay.html.erb +1 -1
- data/lib/metric_fu/metrics/flog/flog.rb +14 -38
- data/lib/metric_fu/metrics/flog/init.rb +30 -7
- data/lib/metric_fu/metrics/generator.rb +21 -6
- data/lib/metric_fu/metrics/graph.rb +2 -2
- data/lib/metric_fu/metrics/hotspots/hotspots.rb +5 -1
- data/lib/metric_fu/metrics/hotspots/init.rb +21 -5
- data/lib/metric_fu/metrics/rails_best_practices/init.rb +29 -5
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb +20 -27
- data/lib/metric_fu/metrics/rails_best_practices/template_awesome/rails_best_practices.html.erb +1 -1
- data/lib/metric_fu/metrics/rcov/init.rb +40 -15
- data/lib/metric_fu/metrics/rcov/rcov.rb +15 -10
- data/lib/metric_fu/metrics/reek/init.rb +25 -6
- data/lib/metric_fu/metrics/reek/reek.rb +52 -31
- data/lib/metric_fu/metrics/reek/template_awesome/reek.html.erb +1 -1
- data/lib/metric_fu/metrics/roodi/init.rb +25 -6
- data/lib/metric_fu/metrics/roodi/roodi.rb +7 -3
- data/lib/metric_fu/metrics/saikuro/init.rb +22 -6
- data/lib/metric_fu/metrics/saikuro/saikuro.rb +8 -3
- data/lib/metric_fu/metrics/stats/init.rb +28 -5
- data/lib/metric_fu/metrics/stats/stats.rb +24 -6
- data/lib/metric_fu/metrics/stats/template_awesome/stats.html.erb +2 -2
- data/lib/metric_fu/parser_ext.rb +15 -0
- data/lib/metric_fu/reporting/graphs/engines/gchart.rb +1 -1
- data/lib/metric_fu/reporting/graphs/engines/init.rb +18 -4
- data/lib/metric_fu/reporting/graphs/grapher.rb +1 -1
- data/lib/metric_fu/reporting/result.rb +13 -6
- data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +1 -1
- data/lib/metric_fu/run.rb +7 -10
- data/lib/metric_fu/sexp_ext.rb +11 -0
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +23 -20
- data/spec/cli/helper_spec.rb +5 -16
- data/spec/metric_fu/configuration_spec.rb +62 -88
- data/spec/metric_fu/formatter/html_spec.rb +26 -16
- data/spec/metric_fu/formatter/yaml_spec.rb +2 -2
- data/spec/metric_fu/metric_spec.rb +50 -0
- data/spec/metric_fu/metrics/base_template_spec.rb +9 -7
- data/spec/metric_fu/metrics/cane/cane_spec.rb +19 -24
- data/spec/metric_fu/metrics/churn/churn_spec.rb +8 -8
- data/spec/metric_fu/metrics/flay/flay_spec.rb +7 -13
- data/spec/metric_fu/metrics/flog/flog_spec.rb +63 -58
- data/spec/metric_fu/metrics/generator_spec.rb +4 -0
- data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +7 -7
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +14 -33
- data/spec/metric_fu/metrics/rcov/rcov_spec.rb +17 -18
- data/spec/metric_fu/metrics/reek/reek_spec.rb +9 -10
- data/spec/metric_fu/metrics/roodi/roodi_spec.rb +5 -11
- data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +15 -14
- data/spec/metric_fu/metrics/stats/stats_spec.rb +5 -6
- data/spec/metric_fu/reporting/graphs/engines/bluff_spec.rb +2 -3
- data/spec/metric_fu/reporting/graphs/engines/gchart_spec.rb +12 -9
- data/spec/metric_fu/reporting/result_spec.rb +3 -3
- data/spec/run_spec.rb +45 -29
- data/spec/spec_helper.rb +7 -0
- data/spec/support/helper_methods.rb +9 -0
- data/spec/support/suite.rb +17 -11
- metadata +59 -56
- data/bin/mf-rails_best_practices +0 -9
- 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("#{
|
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("#{
|
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("#{
|
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
|
-
"#{
|
46
|
-
"#{
|
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("#{
|
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
|
-
"#{
|
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(:
|
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(
|
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("#{
|
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
|
-
"#{
|
96
|
-
"#{
|
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("#{
|
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
|
-
"#{
|
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(:
|
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("#{
|
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("#{
|
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("#{
|
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
|
-
|
92
|
-
|
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(:
|
148
|
-
|
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
|
-
|
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
|
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
|
-
|
14
|
-
@cane = MetricFu::
|
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
|
-
|
21
|
-
@cane = MetricFu::
|
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
|
-
|
28
|
-
@cane = MetricFu::
|
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
|
-
|
35
|
-
@cane = MetricFu::
|
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
|
-
|
42
|
-
@cane = MetricFu::
|
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
|
-
|
49
|
-
@cane = MetricFu::
|
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
|
-
|
56
|
-
@cane = MetricFu::
|
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
|
-
|
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::
|
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
|
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::
|
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::
|
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::
|
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::
|
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::
|
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::
|
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::
|
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
|
3
|
+
describe MetricFu::FlayGenerator do
|
4
4
|
describe "emit method" do
|
5
5
|
it "should look at the dirs" do
|
6
|
-
|
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::
|
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
|
-
|
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::
|
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::
|
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::
|
86
|
+
flay = MetricFu::FlayGenerator.new('base_dir')
|
93
87
|
flay.instance_variable_set(:@matches, lines)
|
94
88
|
@results = flay.to_h
|
95
89
|
end
|