metric_fu 4.11.1 → 4.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +0 -2
- data/CONTRIBUTORS +12 -11
- data/Gemfile +17 -8
- data/HISTORY.md +8 -1
- data/README.md +1 -1
- data/certs/bf4.pem +20 -20
- data/checksum/metric_fu-4.11.1.gem.sha512 +1 -0
- data/lib/metric_fu/metrics/reek/generator.rb +10 -3
- data/lib/metric_fu/templates/metrics_template.rb +29 -17
- data/lib/metric_fu/version.rb +1 -1
- data/spec/cli/helper_spec.rb +2 -2
- data/spec/metric_fu/configuration_spec.rb +8 -8
- data/spec/metric_fu/formatter/configuration_spec.rb +7 -7
- data/spec/metric_fu/formatter_spec.rb +10 -10
- data/spec/metric_fu/gem_version_spec.rb +1 -1
- data/spec/metric_fu/generator_spec.rb +5 -5
- data/spec/metric_fu/metric_spec.rb +6 -6
- data/spec/metric_fu/metrics/churn/configuration_spec.rb +1 -1
- data/spec/metric_fu/metrics/flay/configuration_spec.rb +1 -1
- data/spec/metric_fu/metrics/flog/configuration_spec.rb +1 -1
- data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +6 -6
- data/spec/metric_fu/metrics/rcov/configuration_spec.rb +1 -1
- data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +1 -1
- data/spec/metric_fu/metrics/reek/configuration_spec.rb +1 -1
- data/spec/metric_fu/metrics/reek/generator_spec.rb +29 -12
- data/spec/metric_fu/metrics/roodi/configuration_spec.rb +1 -1
- data/spec/metric_fu/metrics/stats/generator_spec.rb +1 -1
- data/spec/metric_fu/reporter_spec.rb +5 -5
- data/spec/metric_fu/reporting/result_spec.rb +3 -3
- data/spec/metric_fu/run_spec.rb +1 -1
- data/spec/metric_fu/templates/configuration_spec.rb +7 -7
- data/spec/metric_fu/templates/template_spec.rb +16 -16
- data/spec/metric_fu/utility_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/matcher_create_file.rb +4 -0
- data/spec/support/matcher_create_files.rb +4 -0
- data/spec/usage_test_spec.rb +12 -12
- metadata +81 -88
- metadata.gz.sig +0 -0
- data/gemfiles/Gemfile.travis +0 -10
@@ -3,7 +3,7 @@ MetricFu.lib_require { 'gem_version' }
|
|
3
3
|
|
4
4
|
describe MetricFu::GemVersion do
|
5
5
|
|
6
|
-
it
|
6
|
+
it "has a list of gem deps" do
|
7
7
|
gem_version = MetricFu::GemVersion.new
|
8
8
|
gem_deps = gem_version.gem_runtime_dependencies.map(&:name)
|
9
9
|
MetricFu::Metric.metrics.reject{|metric| metric.name == :hotspots || metric.name == :stats}.map(&:name).map(&:to_s).each do |metric_name|
|
@@ -36,25 +36,25 @@ describe MetricFu::Generator do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
40
|
-
it
|
39
|
+
describe "#metric_directory" do
|
40
|
+
it "should return the results of ConcreteClass#metric_directory" do
|
41
41
|
allow(ConcreteClass).to receive(:metric_directory).and_return('foo')
|
42
42
|
expect(@concrete_class.metric_directory).to eq('foo')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "#generate_result" do
|
47
|
-
it
|
47
|
+
it "should raise an error when calling #emit" do
|
48
48
|
@abstract_class = MetricFu::Generator.new
|
49
49
|
expect { @abstract_class.generate_result }.to raise_error
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
52
|
+
it "should call #analyze" do
|
53
53
|
@abstract_class = MetricFu::Generator.new
|
54
54
|
expect { @abstract_class.generate_result }.to raise_error
|
55
55
|
end
|
56
56
|
|
57
|
-
it
|
57
|
+
it "should call #to_h" do
|
58
58
|
@abstract_class = MetricFu::Generator.new
|
59
59
|
expect { @abstract_class.generate_result }.to raise_error
|
60
60
|
end
|
@@ -6,39 +6,39 @@ describe MetricFu::Metric do
|
|
6
6
|
#@original_options = @metric.run_options.dup
|
7
7
|
end
|
8
8
|
|
9
|
-
#it
|
9
|
+
#it "can have its run_options over-written" do
|
10
10
|
#new_options = {:foo => 'bar'}
|
11
11
|
#@metric.run_options = new_options
|
12
12
|
#expect(@original_options).to_not eq(new_options)
|
13
13
|
#expect(@metric.run_options).to eq(new_options)
|
14
14
|
#end
|
15
15
|
|
16
|
-
#it
|
16
|
+
#it "can have its run_options modified" do
|
17
17
|
#new_options = {:foo => 'bar'}
|
18
18
|
#@metric.run_options.merge!(new_options)
|
19
19
|
#expect(@metric.run_options).to eq(@original_options.merge(new_options))
|
20
20
|
#end
|
21
21
|
|
22
|
-
context
|
22
|
+
context "given a valid configurable option" do
|
23
23
|
|
24
24
|
before do
|
25
25
|
allow(@metric).to receive(:default_run_options).and_return({:foo => 'baz'})
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it "can be configured as an attribute" do
|
29
29
|
@metric.foo = 'qux'
|
30
30
|
expect(@metric.run_options[:foo]).to eq('qux')
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
34
34
|
|
35
|
-
context
|
35
|
+
context "given an invalid configurable option" do
|
36
36
|
|
37
37
|
before do
|
38
38
|
allow(@metric).to receive(:default_run_options).and_return({})
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it "raises an error" do
|
42
42
|
expect { @metric.foo = 'bar' }.to raise_error(RuntimeError, /not a valid configuration option/)
|
43
43
|
end
|
44
44
|
|
@@ -4,7 +4,7 @@ require 'shared/configured'
|
|
4
4
|
describe MetricFu::Configuration, 'for churn' do
|
5
5
|
it_behaves_like 'configured' do
|
6
6
|
|
7
|
-
it
|
7
|
+
it "should set @churn to {}" do
|
8
8
|
load_metric 'churn'
|
9
9
|
expect(MetricFu::Metric.get_metric(:churn).run_options).to eq(
|
10
10
|
{ :start_date => %q("1 year ago"), :minimum_churn_count => 10, :ignore_files=>[], :data_directory=> MetricFu::Io::FileSystem.scratch_directory('churn')}
|
@@ -4,7 +4,7 @@ require 'shared/configured'
|
|
4
4
|
describe MetricFu::Configuration, 'for flay' do
|
5
5
|
it_behaves_like 'configured' do
|
6
6
|
|
7
|
-
it
|
7
|
+
it "should set @flay to {:dirs_to_flay => @code_dirs}" do
|
8
8
|
load_metric 'flay'
|
9
9
|
expect(MetricFu::Metric.get_metric(:flay).run_options).to eq(
|
10
10
|
{:dirs_to_flay => ['lib'], :minimum_score=>nil}
|
@@ -5,7 +5,7 @@ describe MetricFu::Configuration, 'for flog' do
|
|
5
5
|
it_behaves_like 'configured' do
|
6
6
|
|
7
7
|
if MetricFu.configuration.mri?
|
8
|
-
it
|
8
|
+
it "should set @flog to {:dirs_to_flog => @code_dirs}" do
|
9
9
|
load_metric 'flog'
|
10
10
|
expect(MetricFu::Metric.get_metric(:flog).run_options).to eq({
|
11
11
|
:all => true,
|
@@ -4,7 +4,7 @@ require 'shared/configured'
|
|
4
4
|
describe MetricFu::Configuration, 'for rails_best_practices' do
|
5
5
|
it_behaves_like 'configured' do
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe "if #rails? is true " do
|
8
8
|
|
9
9
|
before(:each) do
|
10
10
|
@config = MetricFu.configuration
|
@@ -16,20 +16,20 @@ describe MetricFu::Configuration, 'for rails_best_practices' do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
20
|
-
it
|
19
|
+
describe "#set_graphs " do
|
20
|
+
it "should set the graphs to include rails_best_practices" do
|
21
21
|
expect(MetricFu::Metric.get_metric(:rails_best_practices).has_graph?).to be_truthy
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "should set @rails_best_practices to {}" do
|
26
26
|
load_metric 'rails_best_practices'
|
27
27
|
expect(MetricFu::Metric.get_metric(:rails_best_practices).run_options).to eql({})
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
|
32
|
-
describe
|
32
|
+
describe "if #rails? is false " do
|
33
33
|
before(:each) do
|
34
34
|
get_new_config
|
35
35
|
allow(@config).to receive(:rails?).and_return(false)
|
@@ -38,7 +38,7 @@ describe MetricFu::Configuration, 'for rails_best_practices' do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it "should set the registered code_dirs to ['lib']" do
|
42
42
|
expect(directory('code_dirs')).to eq(['lib'])
|
43
43
|
end
|
44
44
|
end
|
@@ -4,7 +4,7 @@ require 'shared/configured'
|
|
4
4
|
describe MetricFu::Configuration, 'for rcov' do
|
5
5
|
it_behaves_like 'configured' do
|
6
6
|
|
7
|
-
it
|
7
|
+
it "should set rcov run_options" do
|
8
8
|
load_metric 'rcov'
|
9
9
|
expect(
|
10
10
|
MetricFu::Metric.get_metric(:rcov).run_options
|
@@ -37,7 +37,7 @@ describe SimpleCov::Formatter::MetricFu do
|
|
37
37
|
if defined?(JRUBY_VERSION)
|
38
38
|
STDOUT.puts "Skipping spec 'cause JRuby doesn't do Coverage right"
|
39
39
|
else
|
40
|
-
it
|
40
|
+
it "calculates the same coverage from an RCov report as from SimpleCov" do
|
41
41
|
SimpleCov.start # start coverage
|
42
42
|
require 'fixtures/coverage-153'
|
43
43
|
result = SimpleCov.result # end coverage
|
@@ -3,7 +3,7 @@ require 'shared/configured'
|
|
3
3
|
|
4
4
|
describe MetricFu::Configuration, 'for reek' do
|
5
5
|
it_behaves_like 'configured' do
|
6
|
-
it
|
6
|
+
it "should set @reek to {:dirs_to_reek => @code_dirs}" do
|
7
7
|
load_metric 'reek'
|
8
8
|
expect(MetricFu::Metric.get_metric(:reek).run_options).to eq(
|
9
9
|
{:config_file_pattern=>nil, :dirs_to_reek => ['lib']}
|
@@ -13,29 +13,46 @@ describe MetricFu::ReekGenerator do
|
|
13
13
|
|
14
14
|
it "includes config file pattern into reek parameters when specified" do
|
15
15
|
options.merge!({:config_file_pattern => 'lib/config/*.reek' })
|
16
|
-
expect(reek).to receive(:run!)
|
16
|
+
expect(reek).to receive(:run!) do |args|
|
17
|
+
expect(args).to include('--config lib/config/*.reek')
|
18
|
+
end.and_return('')
|
19
|
+
reek.emit
|
20
|
+
end
|
21
|
+
|
22
|
+
it "doesn't add an empty parameter when no config file pattern is specified" do
|
23
|
+
expect(reek).to receive(:run!) do |args|
|
24
|
+
expect(args).not_to include('')
|
25
|
+
end.and_return('')
|
17
26
|
reek.emit
|
18
27
|
end
|
19
28
|
|
20
29
|
it "turns off color output from reek output, for reek 1.3.7 or greater" do
|
21
30
|
allow(reek).to receive(:reek_version).and_return('1.3.7')
|
22
|
-
expect(reek).to receive(:run!)
|
31
|
+
expect(reek).to receive(:run!) do |args|
|
32
|
+
expect(args).to include('--no-color')
|
33
|
+
end.and_return("")
|
23
34
|
reek.emit
|
24
35
|
end
|
25
36
|
|
26
37
|
it "does not set an (invalid) --no-color option for reek < 1.3.7" do
|
27
38
|
allow(reek).to receive(:reek_version).and_return('1.3.6')
|
28
|
-
expect(reek).to receive(:run!)
|
39
|
+
expect(reek).to receive(:run!) do |args|
|
40
|
+
expect(args).not_to include('--no-color')
|
41
|
+
end.and_return("")
|
29
42
|
reek.emit
|
30
43
|
end
|
31
44
|
|
32
45
|
it "disables lines numbers from reek output" do
|
33
|
-
expect(reek).to receive(:run!)
|
46
|
+
expect(reek).to receive(:run!) do |args|
|
47
|
+
expect(args).to include('--no-line-numbers')
|
48
|
+
end.and_return("")
|
34
49
|
reek.emit
|
35
50
|
end
|
36
51
|
|
37
52
|
it "includes files to analyze into reek parameters" do
|
38
|
-
expect(reek).to receive(:run!)
|
53
|
+
expect(reek).to receive(:run!) do |args|
|
54
|
+
expect(args).to include('lib/foo.rb', 'lib/bar.rb')
|
55
|
+
end.and_return("")
|
39
56
|
reek.emit
|
40
57
|
end
|
41
58
|
end
|
@@ -153,29 +170,29 @@ app/controllers/newline_controller.rb -- 1 warnings:
|
|
153
170
|
HERE
|
154
171
|
end
|
155
172
|
|
156
|
-
context
|
157
|
-
it
|
173
|
+
context "with Reek 1.1 output format" do
|
174
|
+
it "reports 1.1 style when the output is empty" do
|
158
175
|
@reek.instance_variable_set(:@output, "")
|
159
176
|
expect(@reek).not_to be_reek_12
|
160
177
|
end
|
161
|
-
it
|
178
|
+
it "detects 1.1 format output" do
|
162
179
|
@reek.instance_variable_set(:@output, @lines11)
|
163
180
|
expect(@reek).not_to be_reek_12
|
164
181
|
end
|
165
182
|
|
166
|
-
it
|
183
|
+
it "massages empty output to be unchanged" do
|
167
184
|
@reek.instance_variable_set(:@output, "")
|
168
185
|
expect(@reek.massage_for_reek_12).to be_empty
|
169
186
|
end
|
170
187
|
end
|
171
188
|
|
172
|
-
context
|
173
|
-
it
|
189
|
+
context "with Reek 1.2 output format" do
|
190
|
+
it "detects 1.2 format output" do
|
174
191
|
@reek.instance_variable_set(:@output, @lines12)
|
175
192
|
expect(@reek).to be_reek_12
|
176
193
|
end
|
177
194
|
|
178
|
-
it
|
195
|
+
it "correctly massages 1.2 output" do
|
179
196
|
@reek.instance_variable_set(:@output, @lines12)
|
180
197
|
expect(@reek.massage_for_reek_12).to eq(@lines11)
|
181
198
|
end
|
@@ -4,7 +4,7 @@ require 'shared/configured'
|
|
4
4
|
describe MetricFu::Configuration, 'for roodi' do
|
5
5
|
it_behaves_like 'configured' do
|
6
6
|
|
7
|
-
it
|
7
|
+
it "should set @roodi to {:dirs_to_roodi => @code_dirs}" do
|
8
8
|
load_metric 'roodi'
|
9
9
|
expect(MetricFu::Metric.get_metric(:roodi).run_options).to eq(
|
10
10
|
{ :dirs_to_roodi => directory('code_dirs'),
|
@@ -64,7 +64,7 @@ describe StatsGenerator do
|
|
64
64
|
expect(model_data[:loc_per_method]).to eq(7)
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
67
|
+
it "handles code to test ratio is ratio is 1:NaN" do
|
68
68
|
lines = <<-HERE.gsub(/^\s*/, "")
|
69
69
|
+----------------------+-------+-------+---------+---------+-----+-------+
|
70
70
|
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
|
@@ -3,34 +3,34 @@ MetricFu.lib_require { 'reporter' }
|
|
3
3
|
|
4
4
|
describe MetricFu::Reporter do
|
5
5
|
|
6
|
-
context
|
6
|
+
context "given a single formatter" do
|
7
7
|
before do
|
8
8
|
@formatter = double('formatter')
|
9
9
|
allow(@formatter).to receive(:to_a).and_return([@formatter])
|
10
10
|
@reporter = Reporter.new(@formatter)
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it "notifies the formatter" do
|
14
14
|
expect(@formatter).to receive(:start)
|
15
15
|
expect(@formatter).to receive(:finish)
|
16
16
|
@reporter.start
|
17
17
|
@reporter.finish
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it "only sends notifications when supported by formatter" do
|
21
21
|
allow(@formatter).to receive(:respond_to?).with(:display_results).and_return(false)
|
22
22
|
expect(@formatter).not_to receive(:display_results)
|
23
23
|
@reporter.display_results
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
context
|
27
|
+
context "given multiple formatters" do
|
28
28
|
before do
|
29
29
|
@formatters = [double('formatter'), double('formatter')]
|
30
30
|
@reporter = Reporter.new(@formatters)
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it "notifies all formatters" do
|
34
34
|
@formatters.each do |formatter|
|
35
35
|
expect(formatter).to receive(:start)
|
36
36
|
expect(formatter).to receive(:finish)
|
@@ -4,7 +4,7 @@ MetricFu.reporting_require { 'result' }
|
|
4
4
|
describe MetricFu do
|
5
5
|
|
6
6
|
describe "#result" do
|
7
|
-
it
|
7
|
+
it "should return an instance of Result" do
|
8
8
|
expect(MetricFu.result.instance_of?(Result)).to be(true)
|
9
9
|
end
|
10
10
|
end
|
@@ -17,7 +17,7 @@ describe MetricFu::Result do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#as_yaml" do
|
20
|
-
it
|
20
|
+
it "should call #result_hash" do
|
21
21
|
result_hash = double('result_hash')
|
22
22
|
expect(result_hash).to receive(:to_yaml)
|
23
23
|
|
@@ -30,7 +30,7 @@ describe MetricFu::Result do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe "#add" do
|
33
|
-
it
|
33
|
+
it "should add a passed hash to the result_hash instance variable" do
|
34
34
|
result_type = double('result_type')
|
35
35
|
allow(result_type).to receive(:to_s).and_return('type')
|
36
36
|
|
data/spec/metric_fu/run_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe MetricFu do
|
|
29
29
|
# limited set, so we can test the basic functionality
|
30
30
|
# without significantly slowing down the specs.
|
31
31
|
MetricFu.configuration.configure_metrics do |metric|
|
32
|
-
if metric.name == :
|
32
|
+
if metric.name == :cane
|
33
33
|
metric.enable
|
34
34
|
metric.activated = true
|
35
35
|
# so this doesn't seem to always be true
|
@@ -3,7 +3,7 @@ require 'shared/configured'
|
|
3
3
|
|
4
4
|
describe MetricFu::Configuration, 'for templates' do
|
5
5
|
it_behaves_like 'configured' do
|
6
|
-
describe
|
6
|
+
describe "when there is no CC_BUILD_ARTIFACTS environment variable" do
|
7
7
|
|
8
8
|
before(:each) do
|
9
9
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
@@ -17,11 +17,11 @@ describe MetricFu::Configuration, 'for templates' do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
|
20
|
-
it
|
20
|
+
it "should set @template_class to MetricFu::Templates::MetricsTemplate by default" do
|
21
21
|
expect(template_class).to eq(MetricFu::Templates::MetricsTemplate)
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
24
|
+
describe "when a templates configuration is given" do
|
25
25
|
|
26
26
|
before do
|
27
27
|
class DummyTemplate;end
|
@@ -34,19 +34,19 @@ describe MetricFu::Configuration, 'for templates' do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it "should set given template_class" do
|
38
38
|
expect(template_class).to eq(DummyTemplate)
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it "should set given link_prefix" do
|
42
42
|
expect(MetricFu::Formatter::Templates.option('link_prefix')).to eq('http:/')
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it "should set given darwin_txmt_protocol_no_thanks" do
|
46
46
|
expect(MetricFu::Formatter::Templates.option('darwin_txmt_protocol_no_thanks')).to be_falsey
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
49
|
+
it "should set given syntax_highlighting" do
|
50
50
|
expect(MetricFu::Formatter::Templates.option('syntax_highlighting')).to be_falsey
|
51
51
|
end
|
52
52
|
|
@@ -9,7 +9,7 @@ describe MetricFu::Template do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#erbify" do
|
12
|
-
it
|
12
|
+
it "should evaluate a erb doc" do
|
13
13
|
section = 'section'
|
14
14
|
erb = double('erb')
|
15
15
|
expect(erb).to receive(:result)
|
@@ -25,8 +25,8 @@ describe MetricFu::Template do
|
|
25
25
|
@section = double('section')
|
26
26
|
end
|
27
27
|
|
28
|
-
describe
|
29
|
-
it
|
28
|
+
describe "if the template exists" do
|
29
|
+
it "should return true" do
|
30
30
|
Tempfile.open('file') do |file|
|
31
31
|
expect(@template).to receive(:template).with(@section).and_return(file.path)
|
32
32
|
result = @template.send(:template_exists?,@section)
|
@@ -35,8 +35,8 @@ describe MetricFu::Template do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
39
|
-
it
|
38
|
+
describe "if the template does not exist" do
|
39
|
+
it "should return false" do
|
40
40
|
path = 'path'
|
41
41
|
expect(@template).to receive(:template).with(@section).and_return(path)
|
42
42
|
result = @template.send(:template_exists?,@section)
|
@@ -46,7 +46,7 @@ describe MetricFu::Template do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "#create_instance_var" do
|
49
|
-
it
|
49
|
+
it "should set an instance variable with the passed contents" do
|
50
50
|
section = 'section'
|
51
51
|
contents = 'contents'
|
52
52
|
@template.send(:create_instance_var, section, contents)
|
@@ -55,7 +55,7 @@ describe MetricFu::Template do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
describe "#template" do
|
58
|
-
it
|
58
|
+
it "should generate the filename of the template file" do
|
59
59
|
section = double('section')
|
60
60
|
allow(section).to receive(:to_s).and_return('section')
|
61
61
|
expect(@template).to receive(:template_directory).and_return('dir')
|
@@ -65,7 +65,7 @@ describe MetricFu::Template do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "#output_filename" do
|
68
|
-
it
|
68
|
+
it "should generate the filename of the output file" do
|
69
69
|
section = double('section')
|
70
70
|
expect(section).to receive(:to_s).and_return('section')
|
71
71
|
result = @template.send(:output_filename, section)
|
@@ -74,7 +74,7 @@ describe MetricFu::Template do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "#inline_css" do
|
77
|
-
it
|
77
|
+
it "should return the contents of a css file" do
|
78
78
|
css = 'mycss.css'
|
79
79
|
dir = File.join(MetricFu.lib_dir, 'templates', css)
|
80
80
|
contents = "css contents"
|
@@ -95,7 +95,7 @@ describe MetricFu::Template do
|
|
95
95
|
allow(MetricFu).to receive(:configuration).and_return(config)
|
96
96
|
end
|
97
97
|
|
98
|
-
it
|
98
|
+
it "should return a textmate protocol link" do
|
99
99
|
expect(@template).to receive(:complete_file_path).with('filename').and_return('/expanded/filename')
|
100
100
|
result = @template.send(:link_to_filename, 'filename')
|
101
101
|
expect(result).to eql("<a href='txmt://open/?url=file://" \
|
@@ -153,7 +153,7 @@ describe MetricFu::Template do
|
|
153
153
|
expect(@template).to receive(:complete_file_path).and_return('filename')
|
154
154
|
end
|
155
155
|
|
156
|
-
it
|
156
|
+
it "should return a file protocol link" do
|
157
157
|
name = "filename"
|
158
158
|
result = @template.send(:link_to_filename, name)
|
159
159
|
expect(result).to eq("<a href='file://filename'>filename</a>")
|
@@ -169,7 +169,7 @@ describe MetricFu::Template do
|
|
169
169
|
expect(@template).to receive(:complete_file_path).and_return('filename')
|
170
170
|
end
|
171
171
|
|
172
|
-
it
|
172
|
+
it "should return a http protocol link" do
|
173
173
|
name = "filename"
|
174
174
|
result = @template.send(:link_to_filename, name)
|
175
175
|
expect(result).to eq("<a href='http://example.org/files/filename'>filename</a>")
|
@@ -178,7 +178,7 @@ describe MetricFu::Template do
|
|
178
178
|
end
|
179
179
|
|
180
180
|
describe "#cycle" do
|
181
|
-
it
|
181
|
+
it "should return the first_value passed if iteration passed is even" do
|
182
182
|
first_val = "first"
|
183
183
|
second_val = "second"
|
184
184
|
iter = 2
|
@@ -186,7 +186,7 @@ describe MetricFu::Template do
|
|
186
186
|
expect(result).to eq(first_val)
|
187
187
|
end
|
188
188
|
|
189
|
-
it
|
189
|
+
it "should return the second_value passed if iteration passed is odd" do
|
190
190
|
first_val = "first"
|
191
191
|
second_val = "second"
|
192
192
|
iter = 1
|
@@ -196,12 +196,12 @@ describe MetricFu::Template do
|
|
196
196
|
end
|
197
197
|
|
198
198
|
describe "#render_partial" do
|
199
|
-
it
|
199
|
+
it "should erbify a partial with the name prefixed with an underscore" do
|
200
200
|
expect(@template).to receive(:erbify).with('_some_partial')
|
201
201
|
@template.send(:render_partial, 'some_partial')
|
202
202
|
end
|
203
203
|
|
204
|
-
it
|
204
|
+
it "should set the given instance variables" do
|
205
205
|
variables = {:answer => 42}
|
206
206
|
allow(@template).to receive(:erbify)
|
207
207
|
expect(@template).to receive(:create_instance_vars).with(variables)
|