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
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YjYyYWU0YTk5NjE5ZDM4M2I1ZmVlNWY2ODM4NzM3Y2M4MTUwM2IxZQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e5a9b2b2a4948535584eff46f652281508cc5de5
|
4
|
+
data.tar.gz: 033ea94132c02ae98f68a8338f860bd0d065e0a8
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
OTM3ZmE1ODlmZjg1Yjg0MDZlYTNiZWNiZjAyMTM5MmQ0MThjNzJmMzkzODcy
|
11
|
-
YjcyZjA3YTYwNGE3ODQ0NzE5NjEwN2FiMWJlNTMyNjIyNjBkZWE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjA1NmJmMDZiYzc2ZDBkODVmNDliNWFkMDllZmQyMTk2NGNhN2YwNTFlNzcx
|
14
|
-
NzI3OGNkMDNmMGFhYjZjYWU5YTFjYmNkYTFlZDM0M2VkNGNlNmRmMmFmN2Iy
|
15
|
-
ZWVmNGRmNWQ2MmIxNDQ0MDg3MzFlZWM5MzM0MGVlZTYxNzM5MWQ=
|
6
|
+
metadata.gz: 2ab4c65b33b1238dbd9d0d49aa1c88da8f2e46d77c27afd39109cb17d5404a4e741589b0ed11ef9860209f641257fc5a47d88decc5c1ab7f92004cb07b64e989
|
7
|
+
data.tar.gz: 8082172a72b8001f5c6b0b5aacf8572922db6eda66ebe00ba554d7a7084e1a7ebd8d1c86c7f5f8a0543fe8ec7967f4f9cf89531a31afa2a64952b095f26fa9c7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
data/CONTRIBUTORS
CHANGED
@@ -9,8 +9,8 @@ Robin Curry
|
|
9
9
|
Sean Soper
|
10
10
|
Delwyn de Villiers
|
11
11
|
Carl Youngblood
|
12
|
-
Andre Arko
|
13
12
|
Martin Gotink
|
13
|
+
Andre Arko
|
14
14
|
Chris Griego
|
15
15
|
Sathish
|
16
16
|
Michael Stark
|
@@ -31,8 +31,9 @@ Josef Šimánek
|
|
31
31
|
Andy Gregorowicz
|
32
32
|
Tarsoly András
|
33
33
|
Benjamin Fleischer / Paul Swagerty
|
34
|
-
unknown
|
35
34
|
Nick Veys
|
35
|
+
unknown
|
36
|
+
Micah Geisel
|
36
37
|
Extrovert
|
37
38
|
Ben Turner
|
38
39
|
KAKUTANI Shintaro
|
@@ -44,8 +45,8 @@ David Barri
|
|
44
45
|
Beau Fabry
|
45
46
|
Chris Mason
|
46
47
|
Andrew Selder
|
47
|
-
Mark Wilden
|
48
48
|
iain
|
49
|
+
Mark Wilden
|
49
50
|
Alessandro Dias
|
50
51
|
Lars E. Hoeg
|
51
52
|
Eric Wollesen
|
@@ -59,17 +60,17 @@ ff-cviradiya
|
|
59
60
|
khall
|
60
61
|
Stefan Huber
|
61
62
|
Todd A. Jacobs
|
62
|
-
|
63
|
+
René Föhring
|
64
|
+
Scyllinice
|
63
65
|
Bitdeli Chef
|
64
66
|
Hans Hasselberg
|
65
|
-
|
67
|
+
jayzes
|
66
68
|
Matthew Gordon
|
67
|
-
Guilherme Simões
|
68
69
|
factorylabs
|
69
|
-
|
70
|
-
Chris Ian Fiel
|
70
|
+
Mike Ball
|
71
71
|
Mike Szyndel
|
72
|
-
|
73
|
-
|
72
|
+
Chris Ian Fiel
|
73
|
+
Greg Allen
|
74
74
|
Paul Elliott
|
75
|
-
|
75
|
+
Guilherme Simões
|
76
|
+
Joel Nimety
|
data/Gemfile
CHANGED
@@ -1,13 +1,28 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
source 'https://rubygems.org'
|
3
3
|
|
4
|
+
if RUBY_VERSION == '1.9.2'
|
5
|
+
# because of https://github.com/railsbp/rails_best_practices/blob/master/rails_best_practices.gemspec
|
6
|
+
gem 'activesupport', '~> 3.2'
|
7
|
+
# because of https://github.com/troessner/reek/issues/334
|
8
|
+
gem 'reek', '~> 1.4.0'
|
9
|
+
# rbp -> as -> i18n
|
10
|
+
gem 'i18n', '0.6.11'
|
11
|
+
end
|
12
|
+
|
13
|
+
gemspec :path => File.expand_path('..', __FILE__)
|
14
|
+
|
15
|
+
platform :jruby do
|
16
|
+
group :jruby do
|
17
|
+
gem 'jruby-openssl', '~> 0.8.5'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
4
21
|
group :test, :local_development do
|
5
22
|
gem 'pry'
|
6
23
|
gem 'pry-nav'
|
7
24
|
end
|
8
25
|
|
9
|
-
gemspec :path => File.expand_path('..', __FILE__)
|
10
|
-
|
11
26
|
# Added by devtools
|
12
27
|
group :development do
|
13
28
|
gem 'rake', '~> 10.1.0'
|
@@ -31,9 +46,3 @@ group :guard do
|
|
31
46
|
gem 'rb-notifu', '~> 0.0.4', require: false
|
32
47
|
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
33
48
|
end
|
34
|
-
|
35
|
-
platform :jruby do
|
36
|
-
group :jruby do
|
37
|
-
gem 'jruby-openssl', '~> 0.8.5'
|
38
|
-
end
|
39
|
-
end
|
data/HISTORY.md
CHANGED
@@ -4,13 +4,20 @@ Each change should fall into categories that would affect whether the release is
|
|
4
4
|
|
5
5
|
As such, a _Feature_ would map to either major (breaking change) or minor. A _bug fix_ to a patch. And _misc_ is either minor or patch, the difference being kind of fuzzy for the purposes of history. Adding tests would be patch level.
|
6
6
|
|
7
|
-
### Master [changes](https://github.com/metricfu/metric_fu/compare/v4.11.
|
7
|
+
### Master [changes](https://github.com/metricfu/metric_fu/compare/v4.11.2...master)
|
8
8
|
|
9
9
|
* Breaking Changes
|
10
10
|
* Features
|
11
11
|
* Fixes
|
12
12
|
* Misc
|
13
13
|
|
14
|
+
### [4.11.2](https://github.com/metricfu/metric_fu/compare/v4.11.1...v4.11.2)
|
15
|
+
|
16
|
+
* Fixes
|
17
|
+
* Use reek as library, otherwise reek >= 1.6.2 hangs while reading input from stdin. (Martin Gotink, #240, fixes #239)
|
18
|
+
* Misc
|
19
|
+
* Refactor MetricFu::Templates::MetricsTemplate#write into a composed method. (#237)
|
20
|
+
|
14
21
|
### [4.11.1](https://github.com/metricfu/metric_fu/compare/v4.11.0...v4.11.1)
|
15
22
|
|
16
23
|
* Fixes
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MetricFu [![Gem Version](https://badge.fury.io/rb/metric_fu.png)](http://badge.fury.io/rb/metric_fu) [![Build Status](https://travis-ci.org/metricfu/metric_fu.png?branch=master)](http://travis-ci.org/metricfu/metric_fu)
|
2
2
|
|
3
|
-
[![Code Climate](https://codeclimate.com/github/metricfu/metric_fu.png)](https://codeclimate.com/github/metricfu/metric_fu) [![Inline docs](http://inch-
|
3
|
+
[![Code Climate](https://codeclimate.com/github/metricfu/metric_fu.png)](https://codeclimate.com/github/metricfu/metric_fu) [![Inline docs](http://inch-ci.org/github/metricfu/metric_fu.png)](http://inch-ci.org/github/metricfu/metric_fu) [![Dependency Status](https://gemnasium.com/metricfu/metric_fu.png)](https://gemnasium.com/metricfu/metric_fu)
|
4
4
|
|
5
5
|
[Rdoc](http://rdoc.info/github/metricfu/metric_fu/)
|
6
6
|
|
data/certs/bf4.pem
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
2
|
+
MIIDmjCCAoKgAwIBAgIBATANBgkqhkiG9w0BAQUFADBJMQ8wDQYDVQQDDAZnaXRo
|
3
|
+
dWIxITAfBgoJkiaJk/IsZAEZFhFiZW5qYW1pbmZsZWlzY2hlcjETMBEGCgmSJomT
|
4
|
+
8ixkARkWA2NvbTAeFw0xNTAxMjIxMzAyNTNaFw0xNjAxMjIxMzAyNTNaMEkxDzAN
|
5
|
+
BgNVBAMMBmdpdGh1YjEhMB8GCgmSJomT8ixkARkWEWJlbmphbWluZmxlaXNjaGVy
|
6
|
+
MRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
|
7
|
+
CgKCAQEA7V1VZBU7Aft01XAoK8I8tdClfv3H/NIauiV0jfyNtXtZEWwaZ6ooZNLk
|
8
|
+
8kmIUsO2xI7I/B3es6w7le9q9xdEowlYjiR/X/yazNvufu5kpM4f6Ri1AKN8xvPk
|
9
|
+
LFlR8aOAd9LptcusYDfE+BjhmAvnLTgMGODcDLJIaJzLJaRywTLUuFv4digpFwCm
|
10
|
+
Zps9VheJnL4hkgI5BDn6DVjxHSCMRnccQM/kX9L34lbP9KkHXXEtQgkQYpElHbnd
|
11
|
+
MtR753aPeLfOBxSGzsso+6Lhe+fz8huD05mzgWaEZN40e6M7dA9FRSsEzL32ZOad
|
12
|
+
0z13MZWj3Yg5srV/cZvzCDCdVvRphwIDAQABo4GMMIGJMAkGA1UdEwQCMAAwCwYD
|
13
|
+
VR0PBAQDAgSwMB0GA1UdDgQWBBQvUrPExdvmdz0Vau0dH3hRh1YQfDAnBgNVHREE
|
14
|
+
IDAegRxnaXRodWJAYmVuamFtaW5mbGVpc2NoZXIuY29tMCcGA1UdEgQgMB6BHGdp
|
15
|
+
dGh1YkBiZW5qYW1pbmZsZWlzY2hlci5jb20wDQYJKoZIhvcNAQEFBQADggEBAEWo
|
16
|
+
g1soMaRTT/OfFklTuP+odV0w+2qJSfJhOY5bIebDjqxb9BN7hZJ9L6WXhcXCvl6r
|
17
|
+
kuXjpcC05TIv1DoWWaSjGK2ADmEBDNVhaFepYidAYuUQN4+ZjVH/gS9V9OkBcE8h
|
18
|
+
3ZwRv+9RkXM0uY1FwuGI6jgbgPeR1AkkfJnhOPohkG+VN5bFo9aK/Stw8Nwhuuiz
|
19
|
+
axCPD3cmaJBguufRXSMC852SDiBT7AtI4Gl2Fyr+0M5TzXHKbQ9xRBxwfE1bWDd6
|
20
|
+
lEs7ndJ1/vd/Hy0zQ1tIRWyql+ITLhqMi161Pw5flsYpQvPlRLR5pGJ4eD0/JdKE
|
21
|
+
ZG9WSFH7QcGLY65mEYc=
|
22
22
|
-----END CERTIFICATE-----
|
@@ -0,0 +1 @@
|
|
1
|
+
2d38eac5067748ee4417ab7088302a9e6c465e5163712cef9a1998bcb7048bf74c1b5c1facaccd8af042d2362693e4774de5b8c2bc6dbae5613eb91920ec58aa
|
@@ -13,12 +13,19 @@ module MetricFu
|
|
13
13
|
mf_log "Skipping Reek, no files found to analyze"
|
14
14
|
@output = ""
|
15
15
|
else
|
16
|
-
args =
|
16
|
+
args = cli_options(files)
|
17
17
|
@output = run!(args)
|
18
18
|
@output = massage_for_reek_12 if reek_12?
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def run!(args)
|
23
|
+
require 'reek/cli/application'
|
24
|
+
|
25
|
+
MetricFu::Utility.capture_output do
|
26
|
+
Reek::Cli::Application.new(args).execute
|
27
|
+
end
|
28
|
+
end
|
22
29
|
|
23
30
|
def analyze
|
24
31
|
@matches = @output.chomp.split("\n\n").map{|m| m.split("\n") }
|
@@ -99,8 +106,8 @@ module MetricFu
|
|
99
106
|
disable_line_number_option,
|
100
107
|
turn_off_color,
|
101
108
|
config_option,
|
102
|
-
files
|
103
|
-
].
|
109
|
+
*files
|
110
|
+
].reject(&:empty?)
|
104
111
|
end
|
105
112
|
|
106
113
|
# TODO: Check that specified line config file exists
|
@@ -11,28 +11,42 @@ module MetricFu
|
|
11
11
|
|
12
12
|
def write
|
13
13
|
self.name = MetricFu.report_name
|
14
|
+
self.metrics = {}
|
15
|
+
|
16
|
+
copy_javascripts
|
17
|
+
|
18
|
+
result.each_pair do |section, contents|
|
19
|
+
write_section(section, contents)
|
20
|
+
end
|
21
|
+
|
22
|
+
write_index
|
23
|
+
write_file_data
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
14
27
|
|
15
|
-
|
28
|
+
def copy_javascripts
|
16
29
|
Dir[File.join(template_directory, 'javascripts', '*')].each do |f|
|
17
30
|
FileUtils.cp(f, File.join(self.output_directory, File.basename(f)))
|
18
31
|
end
|
32
|
+
end
|
19
33
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
mf_debug "no template for section #{section} with #{template(section)} for result #{result.class}"
|
33
|
-
end
|
34
|
+
def write_section(section, contents)
|
35
|
+
if template_exists?(section)
|
36
|
+
create_instance_var(section, contents)
|
37
|
+
self.metrics[section] = contents
|
38
|
+
create_instance_var(:per_file_data, per_file_data)
|
39
|
+
mf_debug "Generating html for section #{section} with #{template(section)} for result #{result.class}"
|
40
|
+
self.html = erbify(section)
|
41
|
+
layout = erbify('layout')
|
42
|
+
fn = output_filename(section)
|
43
|
+
formatter.write_template(layout, fn)
|
44
|
+
else
|
45
|
+
mf_debug "no template for section #{section} with #{template(section)} for result #{result.class}"
|
34
46
|
end
|
47
|
+
end
|
35
48
|
|
49
|
+
def write_index
|
36
50
|
# Instance variables we need should already be created from above
|
37
51
|
if template_exists?('index')
|
38
52
|
self.html = erbify('index')
|
@@ -42,8 +56,6 @@ module MetricFu
|
|
42
56
|
else
|
43
57
|
mf_debug "no template for section index for result #{result.class}"
|
44
58
|
end
|
45
|
-
|
46
|
-
write_file_data
|
47
59
|
end
|
48
60
|
|
49
61
|
def write_file_data
|
data/lib/metric_fu/version.rb
CHANGED
data/spec/cli/helper_spec.rb
CHANGED
@@ -155,13 +155,13 @@ describe MetricFu::Cli::Helper do
|
|
155
155
|
expect(helper.process_options(["--roodi"])[:roodi]).to be_truthy
|
156
156
|
end
|
157
157
|
|
158
|
-
context
|
158
|
+
context "given a single format" do
|
159
159
|
it "sets the format" do
|
160
160
|
expect(helper.process_options(["--format", "json"])[:format]).to eq([['json']])
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
-
context
|
164
|
+
context "given multiple formats" do
|
165
165
|
it "sets multiple formats" do
|
166
166
|
expect(helper.process_options(["--format", "json", "--format", "yaml"])[:format]).to eq([['json'], ['yaml']])
|
167
167
|
end
|
@@ -5,7 +5,7 @@ describe MetricFu::Configuration do
|
|
5
5
|
|
6
6
|
it_behaves_like 'configured' do
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe "#is_cruise_control_rb? " do
|
9
9
|
|
10
10
|
before(:each) { get_new_config }
|
11
11
|
describe "when the CC_BUILD_ARTIFACTS env var is not nil" do
|
@@ -28,7 +28,7 @@ it_behaves_like 'configured' do
|
|
28
28
|
describe "when the CC_BUILD_ARTIFACTS env var is nil" do
|
29
29
|
before(:each) { ENV['CC_BUILD_ARTIFACTS'] = nil }
|
30
30
|
|
31
|
-
it
|
31
|
+
it "should return false" do
|
32
32
|
expect(@config.is_cruise_control_rb?).to be_falsey
|
33
33
|
end
|
34
34
|
end
|
@@ -36,7 +36,7 @@ it_behaves_like 'configured' do
|
|
36
36
|
|
37
37
|
describe "#reset" do
|
38
38
|
|
39
|
-
describe
|
39
|
+
describe "when there is a CC_BUILD_ARTIFACTS environment variable" do
|
40
40
|
|
41
41
|
before do
|
42
42
|
ENV['CC_BUILD_ARTIFACTS'] = 'foo'
|
@@ -44,7 +44,7 @@ it_behaves_like 'configured' do
|
|
44
44
|
@config.reset
|
45
45
|
MetricFu.configure
|
46
46
|
end
|
47
|
-
it
|
47
|
+
it "should return the CC_BUILD_ARTIFACTS environment variable" do
|
48
48
|
compare_paths(base_directory, ENV['CC_BUILD_ARTIFACTS'])
|
49
49
|
end
|
50
50
|
after do
|
@@ -53,13 +53,13 @@ it_behaves_like 'configured' do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe
|
56
|
+
describe "when there is no CC_BUILD_ARTIFACTS environment variable" do
|
57
57
|
|
58
58
|
before(:each) do
|
59
59
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
60
60
|
get_new_config
|
61
61
|
end
|
62
|
-
it
|
62
|
+
it "should return 'tmp/metric_fu'" do
|
63
63
|
expect(base_directory).to eq(MetricFu.artifact_dir)
|
64
64
|
end
|
65
65
|
|
@@ -88,11 +88,11 @@ it_behaves_like 'configured' do
|
|
88
88
|
|
89
89
|
end
|
90
90
|
|
91
|
-
describe
|
91
|
+
describe "#platform" do
|
92
92
|
|
93
93
|
before(:each) { get_new_config }
|
94
94
|
|
95
|
-
it
|
95
|
+
it "should return the value of the PLATFORM constant" do
|
96
96
|
this_platform = RUBY_PLATFORM
|
97
97
|
expect(@config.platform).to eq(this_platform)
|
98
98
|
end
|
@@ -4,31 +4,31 @@ require 'shared/configured'
|
|
4
4
|
describe MetricFu::Configuration, 'for formatters' do
|
5
5
|
it_behaves_like 'configured' do
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe "#configure_formatter" do
|
8
8
|
before(:each) { get_new_config }
|
9
9
|
|
10
|
-
context
|
10
|
+
context "given a built-in formatter" do
|
11
11
|
before do
|
12
12
|
@config.configure_formatter('html')
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it "adds to the list of formatters" do
|
16
16
|
expect(@config.formatters.first).to be_an_instance_of(MetricFu::Formatter::HTML)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
context
|
20
|
+
context "given a custom formatter by class name" do
|
21
21
|
before do
|
22
22
|
stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
|
23
23
|
@config.configure_formatter('MyCustomFormatter')
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it "adds to the list of formatters" do
|
27
27
|
expect(@config.formatters.first).to be_an_instance_of(MyCustomFormatter)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
context
|
31
|
+
context "given multiple formatters" do
|
32
32
|
before do
|
33
33
|
stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
|
34
34
|
@config.configure_formatter('html')
|
@@ -36,7 +36,7 @@ describe MetricFu::Configuration, 'for formatters' do
|
|
36
36
|
@config.configure_formatter('MyCustomFormatter')
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it "adds each to the list of formatters" do
|
40
40
|
expect(@config.formatters.count).to eq(3)
|
41
41
|
end
|
42
42
|
end
|
@@ -2,46 +2,46 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe MetricFu::Formatter do
|
4
4
|
describe "formatter class loading" do
|
5
|
-
context
|
5
|
+
context "given a built-in formatter (string)" do
|
6
6
|
subject { MetricFu::Formatter.class_for('html') }
|
7
7
|
|
8
|
-
it
|
8
|
+
it "returns the formatter class" do
|
9
9
|
expect(subject).to eq(MetricFu::Formatter::HTML)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
context
|
13
|
+
context "given a built-in formatter (symbol)" do
|
14
14
|
subject { MetricFu::Formatter.class_for(:yaml) }
|
15
15
|
|
16
|
-
it
|
16
|
+
it "returns the formatter class" do
|
17
17
|
expect(subject).to eq(MetricFu::Formatter::YAML)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
context
|
21
|
+
context "given an unknown built-in formatter" do
|
22
22
|
subject { MetricFu::Formatter.class_for(:unknown) }
|
23
23
|
|
24
|
-
it
|
24
|
+
it "raises an error" do
|
25
25
|
expect{ subject }.to raise_error(NameError)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
context
|
29
|
+
context "given a custom formatter that exists" do
|
30
30
|
subject { MetricFu::Formatter.class_for('MyCustomFormatter') }
|
31
31
|
|
32
32
|
before do
|
33
33
|
stub_const('MyCustomFormatter', Class.new() { def initialize(*);end })
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it "returns the formatter class" do
|
37
37
|
expect(subject).to eq(MyCustomFormatter)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
context
|
41
|
+
context "given a custom formatter that doesnt exist" do
|
42
42
|
subject { MetricFu::Formatter.class_for('MyNonExistentCustomFormatter') }
|
43
43
|
|
44
|
-
it
|
44
|
+
it "raises an error" do
|
45
45
|
expect{ subject }.to raise_error(NameError)
|
46
46
|
end
|
47
47
|
end
|