metric_fu 4.11.3 → 4.11.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.rubocop.yml +15 -0
  5. data/.rubocop_todo.yml +69 -0
  6. data/.travis.yml +0 -1
  7. data/CONTRIBUTORS +1 -1
  8. data/Gemfile +23 -20
  9. data/Guardfile +9 -9
  10. data/HISTORY.md +10 -1
  11. data/checksum/metric_fu-4.11.3.gem.sha512 +1 -0
  12. data/config/rubocop.yml +269 -0
  13. data/gem_tasks/rubocop.rake +10 -0
  14. data/lib/metric_fu.rb +11 -9
  15. data/lib/metric_fu/calculate.rb +0 -1
  16. data/lib/metric_fu/cli/client.rb +6 -6
  17. data/lib/metric_fu/cli/helper.rb +22 -13
  18. data/lib/metric_fu/cli/parser.rb +14 -18
  19. data/lib/metric_fu/configuration.rb +7 -11
  20. data/lib/metric_fu/constantize.rb +4 -4
  21. data/lib/metric_fu/data_structures/line_numbers.rb +10 -11
  22. data/lib/metric_fu/data_structures/location.rb +12 -14
  23. data/lib/metric_fu/data_structures/sexp_node.rb +31 -13
  24. data/lib/metric_fu/environment.rb +29 -31
  25. data/lib/metric_fu/formatter.rb +4 -6
  26. data/lib/metric_fu/formatter/html.rb +13 -13
  27. data/lib/metric_fu/formatter/syntax.rb +5 -7
  28. data/lib/metric_fu/formatter/yaml.rb +1 -1
  29. data/lib/metric_fu/gem_run.rb +13 -15
  30. data/lib/metric_fu/gem_version.rb +9 -11
  31. data/lib/metric_fu/generator.rb +5 -8
  32. data/lib/metric_fu/io.rb +13 -15
  33. data/lib/metric_fu/loader.rb +17 -18
  34. data/lib/metric_fu/logger.rb +15 -18
  35. data/lib/metric_fu/logging/mf_debugger.rb +4 -4
  36. data/lib/metric_fu/metric.rb +11 -12
  37. data/lib/metric_fu/metrics/cane/generator.rb +10 -9
  38. data/lib/metric_fu/metrics/cane/grapher.rb +5 -7
  39. data/lib/metric_fu/metrics/cane/metric.rb +6 -8
  40. data/lib/metric_fu/metrics/cane/report.html.erb +3 -3
  41. data/lib/metric_fu/metrics/cane/violations.rb +6 -6
  42. data/lib/metric_fu/metrics/churn/generator.rb +2 -6
  43. data/lib/metric_fu/metrics/churn/hotspot.rb +1 -3
  44. data/lib/metric_fu/metrics/churn/metric.rb +5 -7
  45. data/lib/metric_fu/metrics/flay/generator.rb +7 -11
  46. data/lib/metric_fu/metrics/flay/grapher.rb +5 -6
  47. data/lib/metric_fu/metrics/flay/hotspot.rb +5 -7
  48. data/lib/metric_fu/metrics/flay/metric.rb +5 -7
  49. data/lib/metric_fu/metrics/flog/generator.rb +22 -23
  50. data/lib/metric_fu/metrics/flog/grapher.rb +11 -11
  51. data/lib/metric_fu/metrics/flog/hotspot.rb +3 -5
  52. data/lib/metric_fu/metrics/flog/metric.rb +3 -5
  53. data/lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb +0 -1
  54. data/lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb +19 -18
  55. data/lib/metric_fu/metrics/hotspots/analysis/grouping.rb +0 -2
  56. data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -3
  57. data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +4 -6
  58. data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +14 -9
  59. data/lib/metric_fu/metrics/hotspots/analysis/ranking.rb +4 -5
  60. data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +1 -3
  61. data/lib/metric_fu/metrics/hotspots/analysis/record.rb +3 -5
  62. data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +0 -2
  63. data/lib/metric_fu/metrics/hotspots/analysis/table.rb +3 -4
  64. data/lib/metric_fu/metrics/hotspots/generator.rb +3 -6
  65. data/lib/metric_fu/metrics/hotspots/hotspot.rb +13 -13
  66. data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +5 -8
  67. data/lib/metric_fu/metrics/hotspots/metric.rb +1 -3
  68. data/lib/metric_fu/metrics/hotspots/report.html.erb +1 -1
  69. data/lib/metric_fu/metrics/rails_best_practices/generator.rb +10 -12
  70. data/lib/metric_fu/metrics/rails_best_practices/grapher.rb +5 -6
  71. data/lib/metric_fu/metrics/rails_best_practices/metric.rb +1 -3
  72. data/lib/metric_fu/metrics/rcov/external_client.rb +1 -3
  73. data/lib/metric_fu/metrics/rcov/generator.rb +13 -15
  74. data/lib/metric_fu/metrics/rcov/grapher.rb +6 -7
  75. data/lib/metric_fu/metrics/rcov/hotspot.rb +5 -7
  76. data/lib/metric_fu/metrics/rcov/metric.rb +5 -7
  77. data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +16 -55
  78. data/lib/metric_fu/metrics/rcov/rcov_line.rb +48 -0
  79. data/lib/metric_fu/metrics/rcov/report.html.erb +2 -2
  80. data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +10 -11
  81. data/lib/metric_fu/metrics/reek/generator.rb +22 -23
  82. data/lib/metric_fu/metrics/reek/grapher.rb +5 -6
  83. data/lib/metric_fu/metrics/reek/hotspot.rb +5 -7
  84. data/lib/metric_fu/metrics/reek/metric.rb +2 -4
  85. data/lib/metric_fu/metrics/roodi/generator.rb +9 -10
  86. data/lib/metric_fu/metrics/roodi/grapher.rb +5 -6
  87. data/lib/metric_fu/metrics/roodi/hotspot.rb +1 -3
  88. data/lib/metric_fu/metrics/roodi/metric.rb +2 -4
  89. data/lib/metric_fu/metrics/saikuro/generator.rb +23 -27
  90. data/lib/metric_fu/metrics/saikuro/hotspot.rb +1 -3
  91. data/lib/metric_fu/metrics/saikuro/metric.rb +7 -8
  92. data/lib/metric_fu/metrics/saikuro/parsing_element.rb +6 -8
  93. data/lib/metric_fu/metrics/saikuro/report.html.erb +1 -1
  94. data/lib/metric_fu/metrics/saikuro/scratch_file.rb +24 -29
  95. data/lib/metric_fu/metrics/stats/generator.rb +9 -12
  96. data/lib/metric_fu/metrics/stats/grapher.rb +8 -9
  97. data/lib/metric_fu/metrics/stats/hotspot.rb +1 -3
  98. data/lib/metric_fu/metrics/stats/metric.rb +3 -5
  99. data/lib/metric_fu/reporter.rb +1 -1
  100. data/lib/metric_fu/reporting/graphs/graph.rb +8 -12
  101. data/lib/metric_fu/reporting/graphs/grapher.rb +7 -9
  102. data/lib/metric_fu/reporting/result.rb +0 -3
  103. data/lib/metric_fu/run.rb +12 -3
  104. data/lib/metric_fu/tasks/metric_fu.rake +8 -8
  105. data/lib/metric_fu/templates/configuration.rb +2 -5
  106. data/lib/metric_fu/templates/metrics_template.rb +19 -19
  107. data/lib/metric_fu/templates/report.rb +5 -8
  108. data/lib/metric_fu/templates/template.rb +20 -24
  109. data/lib/metric_fu/utility.rb +7 -8
  110. data/lib/metric_fu/version.rb +1 -1
  111. data/metric_fu.gemspec +31 -32
  112. data/spec/cli/helper_spec.rb +7 -14
  113. data/spec/dummy/lib/bad_encoding.rb +1 -1
  114. data/spec/fixtures/coverage-153.rb +2 -2
  115. data/spec/fixtures/coverage.rb +2 -2
  116. data/spec/metric_fu/calculate_spec.rb +3 -3
  117. data/spec/metric_fu/configuration_spec.rb +70 -82
  118. data/spec/metric_fu/data_structures/line_numbers_spec.rb +3 -5
  119. data/spec/metric_fu/data_structures/location_spec.rb +13 -31
  120. data/spec/metric_fu/formatter/configuration_spec.rb +11 -13
  121. data/spec/metric_fu/formatter/html_spec.rb +21 -28
  122. data/spec/metric_fu/formatter/yaml_spec.rb +9 -17
  123. data/spec/metric_fu/formatter_spec.rb +6 -6
  124. data/spec/metric_fu/gem_version_spec.rb +3 -5
  125. data/spec/metric_fu/generator_spec.rb +28 -38
  126. data/spec/metric_fu/loader_spec.rb +1 -3
  127. data/spec/metric_fu/metric_spec.rb +17 -21
  128. data/spec/metric_fu/metrics/cane/configuration_spec.rb +8 -8
  129. data/spec/metric_fu/metrics/cane/generator_spec.rb +26 -29
  130. data/spec/metric_fu/metrics/churn/configuration_spec.rb +6 -8
  131. data/spec/metric_fu/metrics/churn/generator_spec.rb +6 -11
  132. data/spec/metric_fu/metrics/flay/configuration_spec.rb +6 -8
  133. data/spec/metric_fu/metrics/flay/generator_spec.rb +36 -37
  134. data/spec/metric_fu/metrics/flay/grapher_spec.rb +2 -2
  135. data/spec/metric_fu/metrics/flog/configuration_spec.rb +11 -13
  136. data/spec/metric_fu/metrics/flog/generator_spec.rb +29 -31
  137. data/spec/metric_fu/metrics/flog/grapher_spec.rb +8 -10
  138. data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +18 -24
  139. data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +12 -17
  140. data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +2 -6
  141. data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -14
  142. data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +1 -3
  143. data/spec/metric_fu/metrics/hotspots/generator_spec.rb +6 -8
  144. data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +1 -3
  145. data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +4 -5
  146. data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +6 -10
  147. data/spec/metric_fu/metrics/rails_best_practices/generator_spec.rb +2 -3
  148. data/spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb +3 -3
  149. data/spec/metric_fu/metrics/rcov/configuration_spec.rb +20 -22
  150. data/spec/metric_fu/metrics/rcov/generator_spec.rb +6 -10
  151. data/spec/metric_fu/metrics/rcov/grapher_spec.rb +2 -2
  152. data/spec/metric_fu/metrics/rcov/hotspot_spec.rb +8 -8
  153. data/spec/metric_fu/metrics/rcov/rcov_line_spec.rb +89 -0
  154. data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +31 -33
  155. data/spec/metric_fu/metrics/reek/configuration_spec.rb +6 -6
  156. data/spec/metric_fu/metrics/reek/generator_spec.rb +19 -20
  157. data/spec/metric_fu/metrics/reek/grapher_spec.rb +4 -4
  158. data/spec/metric_fu/metrics/roodi/configuration_spec.rb +7 -9
  159. data/spec/metric_fu/metrics/roodi/generator_spec.rb +3 -3
  160. data/spec/metric_fu/metrics/roodi/grapher_spec.rb +2 -2
  161. data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +18 -19
  162. data/spec/metric_fu/metrics/saikuro/generator_spec.rb +7 -7
  163. data/spec/metric_fu/metrics/stats/generator_spec.rb +9 -9
  164. data/spec/metric_fu/metrics/stats/grapher_spec.rb +2 -2
  165. data/spec/metric_fu/reporter_spec.rb +3 -4
  166. data/spec/metric_fu/reporting/graphs/graph_spec.rb +1 -4
  167. data/spec/metric_fu/reporting/graphs/grapher_spec.rb +5 -5
  168. data/spec/metric_fu/reporting/result_spec.rb +9 -11
  169. data/spec/metric_fu/run_spec.rb +18 -32
  170. data/spec/metric_fu/templates/configuration_spec.rb +28 -34
  171. data/spec/metric_fu/templates/metrics_template_spec.rb +11 -0
  172. data/spec/metric_fu/templates/report_spec.rb +4 -4
  173. data/spec/metric_fu/templates/template_spec.rb +62 -48
  174. data/spec/metric_fu/utility_spec.rb +2 -2
  175. data/spec/metric_fu_spec.rb +5 -7
  176. data/spec/shared/configured.rb +9 -11
  177. data/spec/shared/test_coverage.rb +5 -9
  178. data/spec/spec_helper.rb +9 -9
  179. data/spec/support/deferred_garbaged_collection.rb +1 -2
  180. data/spec/support/matcher_create_file.rb +2 -4
  181. data/spec/support/matcher_create_files.rb +2 -4
  182. data/spec/support/suite.rb +3 -3
  183. data/spec/support/test_fixtures.rb +5 -7
  184. data/spec/support/timeout.rb +1 -1
  185. data/spec/support/usage_test.rb +23 -24
  186. data/spec/usage_test_spec.rb +18 -20
  187. metadata +12 -2
  188. metadata.gz.sig +0 -0
@@ -2,101 +2,89 @@ require "spec_helper"
2
2
  require "shared/configured"
3
3
 
4
4
  describe MetricFu::Configuration do
5
-
6
- it_behaves_like "configured" do
7
-
8
- describe "#is_cruise_control_rb?" do
9
-
10
- before(:each) { get_new_config }
11
- describe "when the CC_BUILD_ARTIFACTS env var is not nil" do
12
-
13
- before(:each) do
14
- ENV["CC_BUILD_ARTIFACTS"] = "is set"
5
+ it_behaves_like "configured" do
6
+ describe "#is_cruise_control_rb?" do
7
+ before(:each) { get_new_config }
8
+ describe "when the CC_BUILD_ARTIFACTS env var is not nil" do
9
+ before(:each) do
10
+ ENV["CC_BUILD_ARTIFACTS"] = "is set"
11
+ end
12
+
13
+ it "should return true" do
14
+ expect(@config.is_cruise_control_rb?).to be_truthy
15
+ end
16
+
17
+ after(:each) do
18
+ ENV["CC_BUILD_ARTIFACTS"] = nil
19
+ FileUtils.rm_rf(File.join(MetricFu.root_dir, "is set"))
20
+ end
15
21
  end
16
22
 
17
- it "should return true" do
18
- expect(@config.is_cruise_control_rb?).to be_truthy
19
- end
23
+ describe "when the CC_BUILD_ARTIFACTS env var is nil" do
24
+ before(:each) { ENV["CC_BUILD_ARTIFACTS"] = nil }
20
25
 
21
- after(:each) do
22
- ENV["CC_BUILD_ARTIFACTS"] = nil
23
- FileUtils.rm_rf(File.join(MetricFu.root_dir, "is set"))
26
+ it "should return false" do
27
+ expect(@config.is_cruise_control_rb?).to be_falsey
28
+ end
24
29
  end
25
-
26
30
  end
27
31
 
28
- describe "when the CC_BUILD_ARTIFACTS env var is nil" do
29
- before(:each) { ENV["CC_BUILD_ARTIFACTS"] = nil }
30
-
31
- it "should return false" do
32
- expect(@config.is_cruise_control_rb?).to be_falsey
32
+ describe "#reset" do
33
+ describe "when there is a CC_BUILD_ARTIFACTS environment variable" do
34
+ before do
35
+ ENV["CC_BUILD_ARTIFACTS"] = "foo"
36
+ @config = MetricFu.configuration
37
+ @config.reset
38
+ MetricFu.configure
39
+ end
40
+ it "should return the CC_BUILD_ARTIFACTS environment variable" do
41
+ compare_paths(base_directory, ENV["CC_BUILD_ARTIFACTS"])
42
+ end
43
+ after do
44
+ ENV["CC_BUILD_ARTIFACTS"] = nil
45
+ FileUtils.rm_rf(File.join(MetricFu.root_dir, "foo"))
46
+ end
33
47
  end
34
- end
35
- end
36
-
37
- describe "#reset" do
38
48
 
39
- describe "when there is a CC_BUILD_ARTIFACTS environment variable" do
40
-
41
- before do
42
- ENV["CC_BUILD_ARTIFACTS"] = "foo"
43
- @config = MetricFu.configuration
44
- @config.reset
45
- MetricFu.configure
46
- end
47
- it "should return the CC_BUILD_ARTIFACTS environment variable" do
48
- compare_paths(base_directory, ENV["CC_BUILD_ARTIFACTS"])
49
- end
50
- after do
51
- ENV["CC_BUILD_ARTIFACTS"] = nil
52
- FileUtils.rm_rf(File.join(MetricFu.root_dir, "foo"))
49
+ describe "when there is no CC_BUILD_ARTIFACTS environment variable" do
50
+ before(:each) do
51
+ ENV["CC_BUILD_ARTIFACTS"] = nil
52
+ get_new_config
53
+ end
54
+ it "should return 'tmp/metric_fu'" do
55
+ expect(base_directory).to eq(MetricFu.artifact_dir)
56
+ end
57
+
58
+ it "should set @metric_fu_root_directory to the base of the "\
59
+ "metric_fu application" do
60
+ app_root = File.join(File.dirname(__FILE__), "..", "..")
61
+ app_root_absolute_path = File.expand_path(app_root)
62
+ metric_fu_absolute_path = File.expand_path(metric_fu_root)
63
+ expect(metric_fu_absolute_path).to eq(app_root_absolute_path)
64
+ expect(MetricFu.root.to_s).to eq(app_root_absolute_path)
65
+ end
66
+
67
+ it "should set @scratch_directory to scratch relative "\
68
+ "to @base_directory" do
69
+ scratch_dir = MetricFu.scratch_dir
70
+ expect(scratch_directory).to eq(scratch_dir)
71
+ end
72
+
73
+ it "should set @output_directory to output relative "\
74
+ "to @base_directory" do
75
+ output_dir = MetricFu.output_dir
76
+ expect(output_directory).to eq(output_dir)
77
+ end
53
78
  end
54
79
  end
55
80
 
56
- describe "when there is no CC_BUILD_ARTIFACTS environment variable" do
81
+ describe "#platform" do
82
+ before(:each) { get_new_config }
57
83
 
58
- before(:each) do
59
- ENV["CC_BUILD_ARTIFACTS"] = nil
60
- get_new_config
61
- end
62
- it "should return 'tmp/metric_fu'" do
63
- expect(base_directory).to eq(MetricFu.artifact_dir)
84
+ it "should return the value of the PLATFORM constant" do
85
+ this_platform = RUBY_PLATFORM
86
+ expect(@config.platform).to eq(this_platform)
64
87
  end
65
-
66
- it "should set @metric_fu_root_directory to the base of the "\
67
- "metric_fu application" do
68
- app_root = File.join(File.dirname(__FILE__), "..", "..")
69
- app_root_absolute_path = File.expand_path(app_root)
70
- metric_fu_absolute_path = File.expand_path(metric_fu_root)
71
- expect(metric_fu_absolute_path).to eq(app_root_absolute_path)
72
- expect(MetricFu.root.to_s).to eq(app_root_absolute_path)
73
- end
74
-
75
- it "should set @scratch_directory to scratch relative "\
76
- "to @base_directory" do
77
- scratch_dir = MetricFu.scratch_dir
78
- expect(scratch_directory).to eq(scratch_dir)
79
- end
80
-
81
- it "should set @output_directory to output relative "\
82
- "to @base_directory" do
83
- output_dir = MetricFu.output_dir
84
- expect(output_directory).to eq(output_dir)
85
- end
86
-
87
- end
88
-
89
- end
90
-
91
- describe "#platform" do
92
-
93
- before(:each) { get_new_config }
94
-
95
- it "should return the value of the PLATFORM constant" do
96
- this_platform = RUBY_PLATFORM
97
- expect(@config.platform).to eq(this_platform)
98
88
  end
99
89
  end
100
-
101
- end
102
90
  end
@@ -1,9 +1,9 @@
1
1
  require "spec_helper"
2
- MetricFu.data_structures_require { 'line_numbers' }
2
+ MetricFu.data_structures_require { "line_numbers" }
3
3
 
4
4
  describe MetricFu::LineNumbers do
5
5
  FIXTURE_DATA = ->(paths) {
6
- FIXTURE.load_file( ['line_numbers'].concat(Array(paths)) )
6
+ FIXTURE.load_file(["line_numbers"].concat(Array(paths)))
7
7
  }
8
8
  describe "in_method?" do
9
9
  it "should know if a line is NOT in a method" do
@@ -51,7 +51,7 @@ describe MetricFu::LineNumbers do
51
51
 
52
52
  it "should work with modules" do
53
53
  ln = MetricFu::LineNumbers.new(FIXTURE_DATA["module.rb"])
54
- expect(ln.method_at_line(4)).to eq('KickAss#get_beat_up?')
54
+ expect(ln.method_at_line(4)).to eq("KickAss#get_beat_up?")
55
55
  end
56
56
 
57
57
  it "should work with module surrounding class" do
@@ -59,7 +59,5 @@ describe MetricFu::LineNumbers do
59
59
  expect(ln.method_at_line(5)).to eq("StuffModule::ThingClass#do_it")
60
60
  # ln.method_at_line(12).should == "StuffModule#blah" #why no work?
61
61
  end
62
-
63
62
  end
64
-
65
63
  end
@@ -1,8 +1,7 @@
1
1
  require "spec_helper"
2
- MetricFu.data_structures_require { 'location' }
2
+ MetricFu.data_structures_require { "location" }
3
3
 
4
4
  describe MetricFu::Location do
5
-
6
5
  context "with non-standard Reek method names" do
7
6
  # reek reports the method with :: not # on modules like
8
7
  # module ApplicationHelper \n def signed_in?, convert it so it records correctly
@@ -13,33 +12,29 @@ describe MetricFu::Location do
13
12
  end
14
13
 
15
14
  it "has method name" do
16
- expect(@location.method_name).to eq('ApplicationHelper#section_link')
15
+ expect(@location.method_name).to eq("ApplicationHelper#section_link")
17
16
  end
18
17
 
19
18
  it "has nil file path" do
20
- expect(@location.file_path).to eq(nil)
19
+ expect(@location.file_path).to eq(nil)
21
20
  end
22
21
 
23
22
  it "has class name" do
24
- expect(@location.class_name).to eq('ApplicationHelper')
23
+ expect(@location.class_name).to eq("ApplicationHelper")
25
24
  end
26
-
27
25
  end
28
26
 
29
27
  context "using new" do
30
-
31
28
  before do
32
29
  @location = Location.new("lib/foo.rb", "Foo", "Foo#some_method")
33
30
  end
34
31
 
35
32
  it "should return fully qualified method" do
36
- expect(@location.method_name).to eq('Foo#some_method')
33
+ expect(@location.method_name).to eq("Foo#some_method")
37
34
  end
38
-
39
35
  end
40
36
 
41
37
  context "using .for with class" do
42
-
43
38
  before do
44
39
  @location = Location.for("Module::Foo")
45
40
  end
@@ -53,58 +48,49 @@ describe MetricFu::Location do
53
48
  end
54
49
 
55
50
  it "has class_name" do
56
- expect(@location.class_name).to eq('Foo')
51
+ expect(@location.class_name).to eq("Foo")
57
52
  end
58
-
59
53
  end
60
54
 
61
55
  context "using .for with method" do
62
-
63
56
  before do
64
57
  @location = Location.for("Module::Foo#some_method")
65
58
  end
66
59
 
67
60
  it "strips module from class name" do
68
- expect(@location.class_name).to eq('Foo')
61
+ expect(@location.class_name).to eq("Foo")
69
62
  end
70
63
 
71
64
  it "strips module from method name" do
72
- expect(@location.method_name).to eq('Foo#some_method')
65
+ expect(@location.method_name).to eq("Foo#some_method")
73
66
  end
74
67
 
75
68
  it "has nil file_path" do
76
69
  expect(@location.file_path).to be nil
77
70
  end
78
-
79
71
  end
80
72
 
81
73
  context "with class method" do
82
-
83
74
  it "provides non-qualified name" do
84
75
  location = Location.for("Foo.some_class_method")
85
- expect(location.simple_method_name).to eq('.some_class_method')
76
+ expect(location.simple_method_name).to eq(".some_class_method")
86
77
  end
87
-
88
78
  end
89
79
 
90
80
  context "with instance method" do
91
-
92
81
  it "provides non-qualified name" do
93
82
  location = Location.for("Foo#some_class_method")
94
- expect(location.simple_method_name).to eq('#some_class_method')
83
+ expect(location.simple_method_name).to eq("#some_class_method")
95
84
  end
96
-
97
85
  end
98
- context "testing equality" do
86
+ context "testing equality" do
99
87
  before :each do
100
-
101
- @location1 = MetricFu::Location.get('/some/path','some_class','some_method')
88
+ @location1 = MetricFu::Location.get("/some/path", "some_class", "some_method")
102
89
 
103
90
  # ensure that we get a new object
104
- @location2 = MetricFu::Location.new('/some/path','some_class','some_method')
91
+ @location2 = MetricFu::Location.new("/some/path", "some_class", "some_method")
105
92
  end
106
93
  it "should match two locations with the same paths as equal" do
107
-
108
94
  hsh1 = {}
109
95
  hsh1[@location1] = 1
110
96
 
@@ -117,12 +103,8 @@ describe MetricFu::Location do
117
103
  expect(@location1.eql?(@location2)).to be_truthy
118
104
  end
119
105
 
120
-
121
106
  it "should produce the same hash value given the same paths" do
122
-
123
107
  expect(@location1.hash).to eq(@location2.hash)
124
108
  end
125
-
126
109
  end
127
-
128
110
  end
@@ -1,15 +1,14 @@
1
- require 'spec_helper'
2
- require 'shared/configured'
3
-
4
- describe MetricFu::Configuration, 'for formatters' do
5
- it_behaves_like 'configured' do
1
+ require "spec_helper"
2
+ require "shared/configured"
6
3
 
4
+ describe MetricFu::Configuration, "for formatters" do
5
+ it_behaves_like "configured" do
7
6
  describe "#configure_formatter" do
8
7
  before(:each) { get_new_config }
9
8
 
10
9
  context "given a built-in formatter" do
11
10
  before do
12
- @config.configure_formatter('html')
11
+ @config.configure_formatter("html")
13
12
  end
14
13
 
15
14
  it "adds to the list of formatters" do
@@ -19,8 +18,8 @@ describe MetricFu::Configuration, 'for formatters' do
19
18
 
20
19
  context "given a custom formatter by class name" do
21
20
  before do
22
- stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
23
- @config.configure_formatter('MyCustomFormatter')
21
+ stub_const("MyCustomFormatter", Class.new { def initialize(*); end })
22
+ @config.configure_formatter("MyCustomFormatter")
24
23
  end
25
24
 
26
25
  it "adds to the list of formatters" do
@@ -30,10 +29,10 @@ describe MetricFu::Configuration, 'for formatters' do
30
29
 
31
30
  context "given multiple formatters" do
32
31
  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')
32
+ stub_const("MyCustomFormatter", Class.new { def initialize(*); end })
33
+ @config.configure_formatter("html")
34
+ @config.configure_formatter("yaml")
35
+ @config.configure_formatter("MyCustomFormatter")
37
36
  end
38
37
 
39
38
  it "adds each to the list of formatters" do
@@ -41,6 +40,5 @@ describe MetricFu::Configuration, 'for formatters' do
41
40
  end
42
41
  end
43
42
  end
44
-
45
43
  end
46
44
  end
@@ -1,8 +1,7 @@
1
1
  require "spec_helper"
2
- MetricFu.formatter_require { 'html' }
2
+ MetricFu.formatter_require { "html" }
3
3
 
4
4
  describe MetricFu::Formatter::HTML do
5
-
6
5
  before do
7
6
  setup_fs
8
7
 
@@ -12,14 +11,14 @@ describe MetricFu::Formatter::HTML do
12
11
  # for some platforms.
13
12
  config = MetricFu.configuration
14
13
  if config.mri?
15
- @metric_with_graph = :cane
14
+ @metric_with_graph = :cane
16
15
  else
17
- @metric_with_graph = :stats
18
- config.templates_configuration do |c|
19
- c.syntax_highlighting = false
20
- end
16
+ @metric_with_graph = :stats
17
+ config.templates_configuration do |c|
18
+ c.syntax_highlighting = false
19
+ end
21
20
  end
22
- allow(MetricFu::Metric.get_metric(@metric_with_graph)).to receive(:run_external).and_return('')
21
+ allow(MetricFu::Metric.get_metric(@metric_with_graph)).to receive(:run_external).and_return("")
23
22
  @metric_without_graph = :hotspots
24
23
  config.configure_metrics.each do |metric|
25
24
  metric.enabled = true if [@metric_with_graph, @metric_without_graph].include?(metric.name)
@@ -34,30 +33,29 @@ describe MetricFu::Formatter::HTML do
34
33
  end
35
34
 
36
35
  context "In general" do
37
-
38
36
  it "creates a report yaml file" do
39
37
  # For backward compatibility.
40
38
  expect {
41
- MetricFu::Formatter::HTML.new.finish
39
+ MetricFu::Formatter::HTML.new.finish
42
40
  }.to create_file("#{directory('base_directory')}/report.yml")
43
41
  end
44
42
 
45
43
  it "creates a data yaml file" do
46
44
  # For use with graphs.
47
45
  expect {
48
- MetricFu::Formatter::HTML.new.finish
46
+ MetricFu::Formatter::HTML.new.finish
49
47
  }.to create_file("#{directory('data_directory')}/#{MetricFu.report_id}.yml")
50
48
  end
51
49
 
52
50
  it "creates a report index html file" do
53
51
  expect {
54
- MetricFu::Formatter::HTML.new.finish
52
+ MetricFu::Formatter::HTML.new.finish
55
53
  }.to create_file("#{directory('output_directory')}/index.html")
56
54
  end
57
55
 
58
56
  it "creates templatized html files for each metric" do
59
57
  expect {
60
- MetricFu::Formatter::HTML.new.finish
58
+ MetricFu::Formatter::HTML.new.finish
61
59
  }.to create_files([
62
60
  "#{directory('output_directory')}/#{@metric_with_graph}.html",
63
61
  "#{directory('output_directory')}/#{@metric_without_graph}.html"
@@ -66,46 +64,43 @@ describe MetricFu::Formatter::HTML do
66
64
 
67
65
  it "copies common javascripts to the output directory" do
68
66
  expect {
69
- MetricFu::Formatter::HTML.new.finish
67
+ MetricFu::Formatter::HTML.new.finish
70
68
  }.to create_file("#{directory('output_directory')}/highcharts*.js")
71
69
  end
72
70
 
73
71
  it "creates graphs for appropriate metrics" do
74
72
  expect {
75
- MetricFu::Formatter::HTML.new.finish
73
+ MetricFu::Formatter::HTML.new.finish
76
74
  }.to create_files([
77
75
  "#{directory('output_directory')}/#{@metric_with_graph}.js",
78
76
  ])
79
77
  end
80
78
 
81
-
82
79
  it "can open the results in the browser" do
83
80
  allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
84
81
  formatter = MetricFu::Formatter::HTML.new
85
- path = MetricFu.run_path.join(directory('output_directory'))
86
- uri = URI.join(URI.escape("file://#{path}/"), 'index.html')
82
+ path = MetricFu.run_path.join(directory("output_directory"))
83
+ uri = URI.join(URI.escape("file://#{path}/"), "index.html")
87
84
  expect(Launchy).to receive(:open).with(uri)
88
85
  formatter.finish
89
86
  formatter.display_results
90
87
  end
91
-
92
88
  end
93
89
 
94
90
  context "given a custom output directory" do
95
-
96
91
  before do
97
- @output = 'customdir'
92
+ @output = "customdir"
98
93
  end
99
94
 
100
95
  it "creates the report index html file in the custom output directory" do
101
96
  expect {
102
- MetricFu::Formatter::HTML.new(output: @output).finish
97
+ MetricFu::Formatter::HTML.new(output: @output).finish
103
98
  }.to create_file("#{directory('base_directory')}/#{@output}/index.html")
104
99
  end
105
100
 
106
101
  it "creates templatized html files for each metric in the custom output directory" do
107
102
  expect {
108
- MetricFu::Formatter::HTML.new(output: @output).finish
103
+ MetricFu::Formatter::HTML.new(output: @output).finish
109
104
  }.to create_files([
110
105
  "#{directory('base_directory')}/#{@output}/#{@metric_with_graph}.html",
111
106
  "#{directory('base_directory')}/#{@output}/#{@metric_without_graph}.html"
@@ -114,13 +109,13 @@ describe MetricFu::Formatter::HTML do
114
109
 
115
110
  it "copies common javascripts to the custom output directory" do
116
111
  expect {
117
- MetricFu::Formatter::HTML.new(output: @output).finish
112
+ MetricFu::Formatter::HTML.new(output: @output).finish
118
113
  }.to create_file("#{directory('base_directory')}/#{@output}/highcharts*.js")
119
114
  end
120
115
 
121
116
  it "creates graphs for appropriate metrics in the custom output directory " do
122
117
  expect {
123
- MetricFu::Formatter::HTML.new(output: @output).finish
118
+ MetricFu::Formatter::HTML.new(output: @output).finish
124
119
  }.to create_file(
125
120
  "#{directory('base_directory')}/#{@output}/#{@metric_with_graph}.js",
126
121
  )
@@ -130,16 +125,14 @@ describe MetricFu::Formatter::HTML do
130
125
  allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
131
126
  formatter = MetricFu::Formatter::HTML.new(output: @output)
132
127
  path = MetricFu.run_path.join("#{directory('base_directory')}/#{@output}")
133
- uri = URI.join(URI.escape("file://#{path}/"), 'index.html')
128
+ uri = URI.join(URI.escape("file://#{path}/"), "index.html")
134
129
  expect(Launchy).to receive(:open).with(uri)
135
130
  formatter.finish
136
131
  formatter.display_results
137
132
  end
138
-
139
133
  end
140
134
 
141
135
  after do
142
136
  cleanup_fs
143
137
  end
144
-
145
138
  end