metric_fu 4.6.0 → 4.7.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 (97) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.metrics +6 -0
  3. data/.travis.yml +6 -5
  4. data/CONTRIBUTING.md +15 -3
  5. data/Gemfile +3 -8
  6. data/Gemfile.devtools +3 -3
  7. data/HISTORY.md +23 -2
  8. data/README.md +42 -38
  9. data/checksum/metric_fu-4.6.0.gem.sha512 +1 -0
  10. data/gemfiles/Gemfile.travis +7 -0
  11. data/lib/metric_fu/cli/helper.rb +2 -1
  12. data/lib/metric_fu/configuration.rb +0 -2
  13. data/lib/metric_fu/formatter/html.rb +2 -0
  14. data/lib/metric_fu/formatter/syntax.rb +47 -0
  15. data/lib/metric_fu/gem_version.rb +44 -11
  16. data/lib/metric_fu/io.rb +5 -5
  17. data/lib/metric_fu/loader.rb +12 -5
  18. data/lib/metric_fu/metric.rb +10 -0
  19. data/lib/metric_fu/metrics/base_template.rb +2 -2
  20. data/lib/metric_fu/metrics/cane/cane.rb +1 -0
  21. data/lib/metric_fu/metrics/churn/churn.rb +16 -42
  22. data/lib/metric_fu/metrics/churn/init.rb +7 -1
  23. data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -0
  24. data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +1 -0
  25. data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +2 -0
  26. data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +5 -0
  27. data/lib/metric_fu/metrics/hotspots/hotspot.rb +3 -0
  28. data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +8 -4
  29. data/lib/metric_fu/metrics/hotspots/hotspots.rb +11 -0
  30. data/lib/metric_fu/metrics/reek/reek.rb +1 -1
  31. data/lib/metric_fu/metrics/reek/reek_hotspot.rb +0 -1
  32. data/lib/metric_fu/metrics/saikuro/saikuro.rb +1 -0
  33. data/lib/metric_fu/reporting/graphs/grapher.rb +0 -1
  34. data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +8 -59
  35. data/lib/metric_fu/run.rb +1 -1
  36. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/bluff.css +0 -0
  37. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/buttons.css +0 -0
  38. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/default.css +0 -0
  39. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/integrity.css +0 -0
  40. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/rcov.css +0 -0
  41. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/reset.css +0 -0
  42. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/syntax.css +0 -0
  43. data/lib/metric_fu/templates/report.html.erb +32 -0
  44. data/lib/metric_fu/templates/report.rb +36 -0
  45. data/lib/metric_fu/utility.rb +4 -0
  46. data/lib/metric_fu/version.rb +1 -1
  47. data/metric_fu.gemspec +11 -2
  48. data/spec/cli/helper_spec.rb +33 -33
  49. data/spec/metric_fu/configuration_spec.rb +20 -20
  50. data/spec/metric_fu/data_structures/line_numbers_spec.rb +12 -11
  51. data/spec/metric_fu/data_structures/location_spec.rb +27 -26
  52. data/spec/metric_fu/formatter/html_spec.rb +18 -8
  53. data/spec/metric_fu/formatter/yaml_spec.rb +14 -3
  54. data/spec/metric_fu/formatter_spec.rb +5 -5
  55. data/spec/metric_fu/loader_spec.rb +1 -1
  56. data/spec/metric_fu/metric_spec.rb +2 -2
  57. data/spec/metric_fu/metrics/base_template_spec.rb +50 -50
  58. data/spec/metric_fu/metrics/cane/cane_spec.rb +29 -28
  59. data/spec/metric_fu/metrics/churn/churn_spec.rb +10 -33
  60. data/spec/metric_fu/metrics/flay/flay_grapher_spec.rb +9 -8
  61. data/spec/metric_fu/metrics/flay/flay_spec.rb +14 -13
  62. data/spec/metric_fu/metrics/flog/flog_grapher_spec.rb +16 -15
  63. data/spec/metric_fu/metrics/flog/flog_spec.rb +10 -9
  64. data/spec/metric_fu/metrics/generator_spec.rb +19 -19
  65. data/spec/metric_fu/metrics/graph_spec.rb +11 -9
  66. data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +5 -0
  67. data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +11 -6
  68. data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +4 -3
  69. data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +16 -10
  70. data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +2 -1
  71. data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +2 -1
  72. data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +8 -2
  73. data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +4 -8
  74. data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher_spec.rb +10 -9
  75. data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +8 -7
  76. data/spec/metric_fu/metrics/rcov/rcov_grapher_spec.rb +8 -8
  77. data/spec/metric_fu/metrics/rcov/rcov_hotspot_spec.rb +7 -4
  78. data/spec/metric_fu/metrics/rcov/rcov_spec.rb +15 -14
  79. data/spec/metric_fu/metrics/reek/reek_grapher_spec.rb +10 -9
  80. data/spec/metric_fu/metrics/reek/reek_spec.rb +17 -15
  81. data/spec/metric_fu/metrics/roodi/roodi_grapher_spec.rb +9 -8
  82. data/spec/metric_fu/metrics/roodi/roodi_spec.rb +4 -3
  83. data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +13 -10
  84. data/spec/metric_fu/metrics/stats/stats_grapher_spec.rb +13 -12
  85. data/spec/metric_fu/metrics/stats/stats_spec.rb +16 -14
  86. data/spec/metric_fu/reporter_spec.rb +8 -7
  87. data/spec/metric_fu/reporting/graphs/grapher_spec.rb +1 -1
  88. data/spec/metric_fu/reporting/result_spec.rb +12 -11
  89. data/spec/metric_fu/run_spec.rb +24 -8
  90. data/spec/spec_helper.rb +1 -2
  91. data/spec/support/helper_methods.rb +14 -1
  92. metadata +124 -57
  93. metadata.gz.sig +0 -0
  94. checksums.yaml +0 -7
  95. checksums.yaml.gz.sig +0 -0
  96. data/lib/metric_fu/initial_requires.rb +0 -13
  97. data/lib/metric_fu/load_files.rb +0 -34
@@ -1,9 +1,10 @@
1
1
  require "spec_helper"
2
+ MetricFu.data_structures_require { 'location' }
2
3
 
3
4
  describe MetricFu::Location do
4
5
 
5
6
  context "with non-standard Reek method names" do
6
- # reek reports the method with :: not # on modules like
7
+ # reek reports the method with :: not # on modules like
7
8
  # module ApplicationHelper \n def signed_in?, convert it so it records correctly
8
9
  # class_or_method_name = class_or_method_name.gsub(/\:\:/,"#") if method_bug_conversion
9
10
 
@@ -12,85 +13,85 @@ describe MetricFu::Location do
12
13
  end
13
14
 
14
15
  it "has method name" do
15
- @location.method_name.should == 'ApplicationHelper#section_link'
16
+ expect(@location.method_name).to eq('ApplicationHelper#section_link')
16
17
  end
17
18
 
18
19
  it "has nil file path" do
19
- @location.file_path.should == nil
20
+ expect(@location.file_path).to eq(nil)
20
21
  end
21
22
 
22
23
  it "has class name" do
23
- @location.class_name.should == 'ApplicationHelper'
24
+ expect(@location.class_name).to eq('ApplicationHelper')
24
25
  end
25
-
26
+
26
27
  end
27
28
 
28
29
  context "using new" do
29
-
30
- before do
30
+
31
+ before do
31
32
  @location = Location.new("lib/foo.rb", "Foo", "Foo#some_method")
32
33
  end
33
34
 
34
35
  it "should return fully qualified method" do
35
- @location.method_name.should == 'Foo#some_method'
36
+ expect(@location.method_name).to eq('Foo#some_method')
36
37
  end
37
-
38
+
38
39
  end
39
40
 
40
41
  context "using .for with class" do
41
42
 
42
- before do
43
+ before do
43
44
  @location = Location.for("Module::Foo")
44
45
  end
45
46
 
46
47
  it "has nil method_name" do
47
- @location.method_name.should be nil
48
+ expect(@location.method_name).to be nil
48
49
  end
49
50
 
50
51
  it "has nil file_path" do
51
- @location.file_path.should be nil
52
+ expect(@location.file_path).to be nil
52
53
  end
53
54
 
54
55
  it "has class_name" do
55
- @location.class_name.should == 'Foo'
56
+ expect(@location.class_name).to eq('Foo')
56
57
  end
57
58
 
58
59
  end
59
60
 
60
61
  context "using .for with method" do
61
-
62
- before do
62
+
63
+ before do
63
64
  @location = Location.for("Module::Foo#some_method")
64
65
  end
65
66
 
66
67
  it "strips module from class name" do
67
- @location.class_name.should == 'Foo'
68
+ expect(@location.class_name).to eq('Foo')
68
69
  end
69
70
 
70
71
  it "strips module from method name" do
71
- @location.method_name.should == 'Foo#some_method'
72
+ expect(@location.method_name).to eq('Foo#some_method')
72
73
  end
73
74
 
74
75
  it "has nil file_path" do
75
- @location.file_path.should be nil
76
+ expect(@location.file_path).to be nil
76
77
  end
77
78
 
78
79
  end
79
80
 
80
81
  context "with class method" do
81
-
82
+
82
83
  it "provides non-qualified name" do
83
84
  location = Location.for("Foo.some_class_method")
84
- location.simple_method_name.should == '.some_class_method'
85
+ expect(location.simple_method_name).to eq('.some_class_method')
85
86
  end
86
87
 
87
88
  end
88
89
 
89
90
  context "with instance method" do
90
-
91
+
91
92
  it "provides non-qualified name" do
92
93
  location = Location.for("Foo#some_class_method")
93
- location.simple_method_name.should == '#some_class_method'
94
+ expect(location.simple_method_name).to eq('#some_class_method')
94
95
  end
95
96
 
96
97
  end
@@ -110,16 +111,16 @@ describe MetricFu::Location do
110
111
  hsh2 = {}
111
112
  hsh2[@location2] = 1
112
113
 
113
- hsh1.should == hsh2
114
- hsh1.eql?(hsh2).should be_true
114
+ expect(hsh1).to eq(hsh2)
115
+ expect(hsh1.eql?(hsh2)).to be_truthy
115
116
 
116
- @location1.eql?(@location2).should be_true
117
+ expect(@location1.eql?(@location2)).to be_truthy
117
118
  end
118
119
 
119
120
 
120
121
  it "should produce the same hash value given the same paths" do
121
122
 
122
- @location1.hash.should == @location2.hash
123
+ expect(@location1.hash).to eq(@location2.hash)
123
124
  end
124
125
 
125
126
  end
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+ MetricFu.formatter_require { 'html' }
2
3
 
3
4
  describe MetricFu::Formatter::HTML do
4
5
 
@@ -9,9 +10,18 @@ describe MetricFu::Formatter::HTML do
9
10
  # Right now, have to select from metrics
10
11
  # based on platform, resulting in slow specs
11
12
  # for some platforms.
12
- @metric_with_graph = MetricFu.configuration.mri? ? :cane : :flay
13
+ config = MetricFu.configuration
14
+ if config.mri?
15
+ @metric_with_graph = :cane
16
+ else
17
+ @metric_with_graph = :stats
18
+ config.templates_configuration do |c|
19
+ c.syntax_highlighting = false
20
+ end
21
+ end
22
+ allow(MetricFu::Metric.get_metric(@metric_with_graph)).to receive(:run_external).and_return('')
13
23
  @metric_without_graph = :hotspots
14
- MetricFu.configuration.configure_metrics.each do |metric|
24
+ config.configure_metrics.each do |metric|
15
25
  metric.enabled = true if [@metric_with_graph, @metric_without_graph].include?(metric.name)
16
26
  end
17
27
 
@@ -70,13 +80,13 @@ describe MetricFu::Formatter::HTML do
70
80
 
71
81
  context 'when on OS X' do
72
82
  before do
73
- MetricFu.configuration.stub(:osx?).and_return(true)
74
- MetricFu.configuration.stub(:is_cruise_control_rb?).and_return(false)
83
+ allow(MetricFu.configuration).to receive(:osx?).and_return(true)
84
+ allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
75
85
  end
76
86
 
77
87
  it "can open the results in the browser" do
78
88
  formatter = MetricFu::Formatter::HTML.new
79
- formatter.should_receive(:system).with("open #{MetricFu.run_path.join(directory('output_directory')).join('index.html')}")
89
+ expect(formatter).to receive(:system).with("open #{MetricFu.run_path.join(directory('output_directory')).join('index.html')}")
80
90
  formatter.finish
81
91
  formatter.display_results
82
92
  end
@@ -121,14 +131,14 @@ describe MetricFu::Formatter::HTML do
121
131
 
122
132
  context 'when on OS X' do
123
133
  before do
124
- MetricFu.configuration.stub(:osx?).and_return(true)
125
- MetricFu.configuration.stub(:is_cruise_control_rb?).and_return(false)
134
+ allow(MetricFu.configuration).to receive(:osx?).and_return(true)
135
+ allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
126
136
  end
127
137
 
128
138
  it "can open the results in the browser from the custom output directory" do
129
139
  formatter = MetricFu::Formatter::HTML.new(output: @output)
130
140
  path = MetricFu.run_path.join("#{directory('base_directory')}/#{@output}/index.html")
131
- formatter.should_receive(:system).with("open #{path}")
141
+ expect(formatter).to receive(:system).with("open #{path}")
132
142
  formatter.finish
133
143
  formatter.display_results
134
144
  end
@@ -1,11 +1,22 @@
1
1
  require "spec_helper"
2
+ MetricFu.formatter_require { 'yaml' }
2
3
 
3
4
  describe MetricFu::Formatter::YAML do
4
5
 
5
6
  before do
6
7
  setup_fs
7
8
 
8
- @metric1 = MetricFu.configuration.mri? ? :cane : :flay
9
+ config = MetricFu.configuration
10
+
11
+ if config.mri?
12
+ @metric1 = :cane
13
+ else
14
+ @metric1 = :stats
15
+ config.templates_configuration do |c|
16
+ c.syntax_highlighting = false
17
+ end
18
+ end
19
+ allow(MetricFu::Metric.get_metric(@metric1)).to receive(:run_external).and_return('')
9
20
  @metric2 = :hotspots
10
21
  MetricFu.result.add(@metric1)
11
22
  MetricFu.result.add(@metric2)
@@ -45,8 +56,8 @@ describe MetricFu::Formatter::YAML do
45
56
  out = MfDebugger::Logger.capture_output {
46
57
  MetricFu::Formatter::YAML.new(output: @output).finish
47
58
  }
48
- out.should include ":#{@metric1}:"
49
- out.should include ":#{@metric2}:"
59
+ expect(out).to include ":#{@metric1}:"
60
+ expect(out).to include ":#{@metric2}:"
50
61
  end
51
62
 
52
63
  end
@@ -6,7 +6,7 @@ describe MetricFu::Formatter do
6
6
  subject { MetricFu::Formatter.class_for('html') }
7
7
 
8
8
  it 'returns the formatter class' do
9
- subject.should eq(MetricFu::Formatter::HTML)
9
+ expect(subject).to eq(MetricFu::Formatter::HTML)
10
10
  end
11
11
  end
12
12
 
@@ -14,7 +14,7 @@ describe MetricFu::Formatter do
14
14
  subject { MetricFu::Formatter.class_for(:yaml) }
15
15
 
16
16
  it 'returns the formatter class' do
17
- subject.should eq(MetricFu::Formatter::YAML)
17
+ expect(subject).to eq(MetricFu::Formatter::YAML)
18
18
  end
19
19
  end
20
20
 
@@ -22,7 +22,7 @@ describe MetricFu::Formatter do
22
22
  subject { MetricFu::Formatter.class_for(:unknown) }
23
23
 
24
24
  it 'raises an error' do
25
- lambda{ subject }.should raise_error(NameError)
25
+ expect{ subject }.to raise_error(NameError)
26
26
  end
27
27
  end
28
28
 
@@ -34,7 +34,7 @@ describe MetricFu::Formatter do
34
34
  end
35
35
 
36
36
  it 'returns the formatter class' do
37
- subject.should eq(MyCustomFormatter)
37
+ expect(subject).to eq(MyCustomFormatter)
38
38
  end
39
39
  end
40
40
 
@@ -42,7 +42,7 @@ describe MetricFu::Formatter do
42
42
  subject { MetricFu::Formatter.class_for('MyNonExistentCustomFormatter') }
43
43
 
44
44
  it 'raises an error' do
45
- lambda{ subject }.should raise_error(NameError)
45
+ expect{ subject }.to raise_error(NameError)
46
46
  end
47
47
  end
48
48
  end
@@ -6,7 +6,7 @@ describe MetricFu do
6
6
  # Global only for testing that this file gets loaded
7
7
  $metric_file_loaded = false
8
8
  MetricFu.loader.load_user_configuration
9
- $metric_file_loaded.should be_true
9
+ expect($metric_file_loaded).to be_truthy
10
10
  end
11
11
 
12
12
  end
@@ -22,7 +22,7 @@ describe MetricFu::Metric do
22
22
  context 'given a valid configurable option' do
23
23
 
24
24
  before do
25
- @metric.stub(:default_run_options).and_return({:foo => 'baz'})
25
+ allow(@metric).to receive(:default_run_options).and_return({:foo => 'baz'})
26
26
  end
27
27
 
28
28
  it 'can be configured as an attribute' do
@@ -35,7 +35,7 @@ describe MetricFu::Metric do
35
35
  context 'given an invalid configurable option' do
36
36
 
37
37
  before do
38
- @metric.stub(:default_run_options).and_return({})
38
+ allow(@metric).to receive(:default_run_options).and_return({})
39
39
  end
40
40
 
41
41
  it 'raises an error' do
@@ -12,9 +12,9 @@ describe MetricFu::Template do
12
12
  it 'should evaluate a erb doc' do
13
13
  section = 'section'
14
14
  erb = double('erb')
15
- erb.should_receive(:result)
16
- @template.should_receive(:template).and_return('foo')
17
- @template.should_receive(:erb_template_source).with('foo').and_return(erb)
15
+ expect(erb).to receive(:result)
16
+ expect(@template).to receive(:template).and_return('foo')
17
+ expect(@template).to receive(:erb_template_source).with('foo').and_return(erb)
18
18
  @template.send(:erbify, section)
19
19
  end
20
20
  end
@@ -28,9 +28,9 @@ describe MetricFu::Template do
28
28
  describe 'if the template exists' do
29
29
  it 'should return true' do
30
30
  Tempfile.open('file') do |file|
31
- @template.should_receive(:template).with(@section).and_return(file.path)
31
+ expect(@template).to receive(:template).with(@section).and_return(file.path)
32
32
  result = @template.send(:template_exists?,@section)
33
- result.should be_true
33
+ expect(result).to be_truthy
34
34
  end
35
35
  end
36
36
  end
@@ -38,9 +38,9 @@ describe MetricFu::Template do
38
38
  describe 'if the template does not exist' do
39
39
  it 'should return false' do
40
40
  path = 'path'
41
- @template.should_receive(:template).with(@section).and_return(path)
41
+ expect(@template).to receive(:template).with(@section).and_return(path)
42
42
  result = @template.send(:template_exists?,@section)
43
- result.should be_false
43
+ expect(result).to be_falsey
44
44
  end
45
45
  end
46
46
  end
@@ -50,37 +50,37 @@ describe MetricFu::Template do
50
50
  section = 'section'
51
51
  contents = 'contents'
52
52
  @template.send(:create_instance_var, section, contents)
53
- @template.instance_variable_get(:@section).should == contents
53
+ expect(@template.instance_variable_get(:@section)).to eq(contents)
54
54
  end
55
55
  end
56
56
 
57
57
  describe "#template" do
58
58
  it 'should generate the filename of the template file' do
59
59
  section = double('section')
60
- section.stub(:to_s).and_return('section')
61
- @template.should_receive(:template_directory).and_return('dir')
60
+ allow(section).to receive(:to_s).and_return('section')
61
+ expect(@template).to receive(:template_directory).and_return('dir')
62
62
  result = @template.send(:template, section)
63
- result.should == "dir/section.html.erb"
63
+ expect(result).to eq("dir/section.html.erb")
64
64
  end
65
65
  end
66
66
 
67
67
  describe "#output_filename" do
68
68
  it 'should generate the filename of the output file' do
69
69
  section = double('section')
70
- section.should_receive(:to_s).and_return('section')
70
+ expect(section).to receive(:to_s).and_return('section')
71
71
  result = @template.send(:output_filename, section)
72
- result.should == "section.html"
72
+ expect(result).to eq("section.html")
73
73
  end
74
74
  end
75
75
 
76
76
  describe "#inline_css" do
77
77
  it 'should return the contents of a css file' do
78
78
  css = 'mycss.css'
79
- @template.should_receive(:template_directory).and_return('dir')
80
- io = double('io', :read => "css contents")
81
- @template.should_receive(:open).and_yield(io)
79
+ dir = File.join(MetricFu.lib_dir, 'templates', css)
80
+ contents = "css contents"
81
+ expect(MetricFu::Utility).to receive(:binread).with(dir).and_return(contents)
82
82
  result = @template.send(:inline_css, css)
83
- result.should == 'css contents'
83
+ expect(result).to eq(contents)
84
84
  end
85
85
  end
86
86
 
@@ -88,57 +88,57 @@ describe MetricFu::Template do
88
88
  describe "when on OS X" do
89
89
  before(:each) do
90
90
  config = double("configuration")
91
- config.stub(:osx?).and_return(true)
92
- config.stub(:platform).and_return('universal-darwin-9.0')
93
- config.stub(:templates_option).with('darwin_txmt_protocol_no_thanks').and_return(false)
94
- config.stub(:templates_option).with('link_prefix').and_return(nil)
95
- MetricFu.stub(:configuration).and_return(config)
91
+ allow(config).to receive(:osx?).and_return(true)
92
+ allow(config).to receive(:platform).and_return('universal-darwin-9.0')
93
+ allow(config).to receive(:templates_option).with('darwin_txmt_protocol_no_thanks').and_return(false)
94
+ allow(config).to receive(:templates_option).with('link_prefix').and_return(nil)
95
+ allow(MetricFu).to receive(:configuration).and_return(config)
96
96
  end
97
97
 
98
98
  it 'should return a textmate protocol link' do
99
- @template.should_receive(:complete_file_path).with('filename').and_return('/expanded/filename')
99
+ expect(@template).to receive(:complete_file_path).with('filename').and_return('/expanded/filename')
100
100
  result = @template.send(:link_to_filename, 'filename')
101
- result.should eql("<a href='txmt://open/?url=file://" \
101
+ expect(result).to eql("<a href='txmt://open/?url=file://" \
102
102
  + "/expanded/filename'>filename</a>")
103
103
  end
104
104
 
105
105
  it "should do the right thing with a filename that starts with a slash" do
106
- @template.should_receive(:complete_file_path).with('/filename').and_return('/expanded/filename')
106
+ expect(@template).to receive(:complete_file_path).with('/filename').and_return('/expanded/filename')
107
107
  result = @template.send(:link_to_filename, '/filename')
108
- result.should eql("<a href='txmt://open/?url=file://" \
108
+ expect(result).to eql("<a href='txmt://open/?url=file://" \
109
109
  + "/expanded/filename'>/filename</a>")
110
110
  end
111
111
 
112
112
  it "should include a line number" do
113
- @template.should_receive(:complete_file_path).with('filename').and_return('/expanded/filename')
113
+ expect(@template).to receive(:complete_file_path).with('filename').and_return('/expanded/filename')
114
114
  result = @template.send(:link_to_filename, 'filename', 6)
115
- result.should eql("<a href='txmt://open/?url=file://" \
115
+ expect(result).to eql("<a href='txmt://open/?url=file://" \
116
116
  + "/expanded/filename&line=6'>filename:6</a>")
117
117
  end
118
118
 
119
119
  describe "but no thanks for txtmt" do
120
120
  before(:each) do
121
121
  config = double("configuration")
122
- config.stub(:osx?).and_return(true)
123
- config.stub(:platform).and_return('universal-darwin-9.0')
124
- config.stub(:templates_option).with('darwin_txmt_protocol_no_thanks').and_return(true)
125
- config.stub(:templates_option).with('link_prefix').and_return('file:/')
126
- MetricFu.stub(:configuration).and_return(config)
127
- @template.should_receive(:complete_file_path).and_return('filename')
122
+ allow(config).to receive(:osx?).and_return(true)
123
+ allow(config).to receive(:platform).and_return('universal-darwin-9.0')
124
+ allow(config).to receive(:templates_option).with('darwin_txmt_protocol_no_thanks').and_return(true)
125
+ allow(config).to receive(:templates_option).with('link_prefix').and_return('file:/')
126
+ allow(MetricFu).to receive(:configuration).and_return(config)
127
+ expect(@template).to receive(:complete_file_path).and_return('filename')
128
128
  end
129
129
 
130
130
  it "should return a file protocol link" do
131
131
  name = "filename"
132
132
  result = @template.send(:link_to_filename, name)
133
- result.should == "<a href='file://filename'>filename</a>"
133
+ expect(result).to eq("<a href='file://filename'>filename</a>")
134
134
  end
135
135
  end
136
136
 
137
137
  describe "and given link text" do
138
138
  it "should use the submitted link text" do
139
- @template.should_receive(:complete_file_path).with('filename').and_return('/expanded/filename')
139
+ expect(@template).to receive(:complete_file_path).with('filename').and_return('/expanded/filename')
140
140
  result = @template.send(:link_to_filename, 'filename', 6, 'link content')
141
- result.should eql("<a href='txmt://open/?url=file://" \
141
+ expect(result).to eql("<a href='txmt://open/?url=file://" \
142
142
  + "/expanded/filename&line=6'>link content</a>")
143
143
  end
144
144
  end
@@ -147,32 +147,32 @@ describe MetricFu::Template do
147
147
  describe "when on other platforms" do
148
148
  before(:each) do
149
149
  config = double("configuration")
150
- config.should_receive(:osx?).and_return(false)
151
- config.stub(:templates_option).with('link_prefix').and_return('file:/')
152
- MetricFu.stub(:configuration).and_return(config)
153
- @template.should_receive(:complete_file_path).and_return('filename')
150
+ expect(config).to receive(:osx?).and_return(false)
151
+ allow(config).to receive(:templates_option).with('link_prefix').and_return('file:/')
152
+ allow(MetricFu).to receive(:configuration).and_return(config)
153
+ expect(@template).to receive(:complete_file_path).and_return('filename')
154
154
  end
155
155
 
156
156
  it 'should return a file protocol link' do
157
157
  name = "filename"
158
158
  result = @template.send(:link_to_filename, name)
159
- result.should == "<a href='file://filename'>filename</a>"
159
+ expect(result).to eq("<a href='file://filename'>filename</a>")
160
160
  end
161
161
  end
162
162
  describe "when configured with a link_prefix" do
163
163
  before(:each) do
164
164
  config = double("configuration")
165
- config.stub(:templates_option).with('darwin_txmt_protocol_no_thanks').and_return(true)
166
- config.stub(:templates_option).with('link_prefix').and_return('http://example.org/files')
167
- config.stub(:osx?).and_return(true)
168
- MetricFu.stub(:configuration).and_return(config)
169
- @template.should_receive(:complete_file_path).and_return('filename')
165
+ allow(config).to receive(:templates_option).with('darwin_txmt_protocol_no_thanks').and_return(true)
166
+ allow(config).to receive(:templates_option).with('link_prefix').and_return('http://example.org/files')
167
+ allow(config).to receive(:osx?).and_return(true)
168
+ allow(MetricFu).to receive(:configuration).and_return(config)
169
+ expect(@template).to receive(:complete_file_path).and_return('filename')
170
170
  end
171
171
 
172
172
  it 'should return a http protocol link' do
173
173
  name = "filename"
174
174
  result = @template.send(:link_to_filename, name)
175
- result.should == "<a href='http://example.org/files/filename'>filename</a>"
175
+ expect(result).to eq("<a href='http://example.org/files/filename'>filename</a>")
176
176
  end
177
177
  end
178
178
  end
@@ -183,7 +183,7 @@ describe MetricFu::Template do
183
183
  second_val = "second"
184
184
  iter = 2
185
185
  result = @template.send(:cycle, first_val, second_val, iter)
186
- result.should == first_val
186
+ expect(result).to eq(first_val)
187
187
  end
188
188
 
189
189
  it 'should return the second_value passed if iteration passed is odd' do
@@ -191,7 +191,7 @@ describe MetricFu::Template do
191
191
  second_val = "second"
192
192
  iter = 1
193
193
  result = @template.send(:cycle, first_val, second_val, iter)
194
- result.should == second_val
194
+ expect(result).to eq(second_val)
195
195
  end
196
196
  end
197
197