hexx-rspec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +67 -0
- data/.travis.yml +17 -0
- data/.yardopts +3 -0
- data/Gemfile +3 -0
- data/Guardfile +29 -0
- data/LICENSE +21 -0
- data/README.md +85 -0
- data/Rakefile +18 -0
- data/bin/hexx-rspec +14 -0
- data/config/initializer.rb +8 -0
- data/config/initializers/focus.rb +5 -0
- data/config/initializers/garbage_collection.rb +11 -0
- data/config/initializers/i18n.rb +3 -0
- data/config/initializers/random_order.rb +4 -0
- data/config/initializers/rspec.rb +11 -0
- data/hexx-rspec.gemspec +29 -0
- data/lib/hexx/rspec/install/Rakefile +17 -0
- data/lib/hexx/rspec/install/_rspec +2 -0
- data/lib/hexx/rspec/install/simplecov.yml +8 -0
- data/lib/hexx/rspec/install.rb +43 -0
- data/lib/hexx/rspec/metrics/base.rb +87 -0
- data/lib/hexx/rspec/metrics/simplecov.rb +123 -0
- data/lib/hexx/rspec/metrics.rb +23 -0
- data/lib/hexx/rspec/system.rb +68 -0
- data/lib/hexx/rspec/version.rb +13 -0
- data/lib/hexx/rspec.rb +65 -0
- data/lib/hexx-rspec.rb +16 -0
- data/lib/tasks/test/coverage.rake +29 -0
- data/lib/tasks/test.rake +6 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/config/sandbox.rb +16 -0
- data/spec/support/config/tasks.rb +32 -0
- data/spec/support/sandbox/helpers.rb +62 -0
- data/spec/support/sandbox/matchers.rb +21 -0
- data/spec/tests/bin/install_spec.rb +15 -0
- data/spec/tests/lib/install_spec.rb +21 -0
- data/spec/tests/lib/metrics/simplecov_spec.rb +108 -0
- data/spec/tests/lib/system_spec.rb +99 -0
- data/spec/tests/rspec_spec.rb +57 -0
- data/spec/tests/tasks/test/coverage/display_spec.rb +49 -0
- data/spec/tests/tasks/test/coverage/run_spec.rb +25 -0
- data/spec/tests/tasks/test/coverage_spec.rb +26 -0
- data/spec/tests/tasks/test_spec.rb +21 -0
- metadata +194 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b7a7c03eb865178f4ad9bfd55718a5b2c38ce7cc
|
4
|
+
data.tar.gz: c15856816912ae234a1f47ed6d0a0a54e01320d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c8d933bec15d75b8e14953fad124332d520d301251403059f1ad641384afac6ba9aea31c7244f57895b0c13faf5c00b5fb7af36758e0a084011198fddfef037b
|
7
|
+
data.tar.gz: f402fcb1ec81a89227e52d758cf2b528a32558e6113db94c8e643f2d34300d471d9a760aafd6e133a314a314eb958fe9c33f159e18808cfd4949ab1fcec4aa32
|
data/.coveralls.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- '**/db/schema.rb'
|
4
|
+
|
5
|
+
Lint/HandleExceptions:
|
6
|
+
Exclude:
|
7
|
+
- '**/*_spec.rb'
|
8
|
+
|
9
|
+
Lint/RescueException:
|
10
|
+
Exclude:
|
11
|
+
- '**/*_spec.rb'
|
12
|
+
|
13
|
+
Style/AccessorMethodName:
|
14
|
+
Exclude:
|
15
|
+
- '**/*_spec.rb'
|
16
|
+
|
17
|
+
Style/AsciiComments:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Style/ClassAndModuleChildren:
|
21
|
+
Exclude:
|
22
|
+
- '**/*_spec.rb'
|
23
|
+
|
24
|
+
Style/Documentation:
|
25
|
+
Exclude:
|
26
|
+
- '**/version.rb'
|
27
|
+
- '**/*_spec.rb'
|
28
|
+
|
29
|
+
Style/EmptyLinesAroundBlockBody:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/EmptyLinesAroundClassBody:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Style/EmptyLinesAroundMethodBody:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
Style/EmptyLinesAroundModuleBody:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Style/EmptyLineBetweenDefs:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Style/FileName:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
Style/RaiseArgs:
|
48
|
+
EnforcedStyle: compact
|
49
|
+
|
50
|
+
Style/SingleLineMethods:
|
51
|
+
Exclude:
|
52
|
+
- '**/*_spec.rb'
|
53
|
+
|
54
|
+
Style/SpecialGlobalVars:
|
55
|
+
Exclude:
|
56
|
+
- '**/Gemfile'
|
57
|
+
- '**/*.gemspec'
|
58
|
+
|
59
|
+
Style/StringLiterals:
|
60
|
+
EnforcedStyle: double_quotes
|
61
|
+
|
62
|
+
Style/SingleSpaceBeforeFirstArg:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
Style/TrivialAccessors:
|
66
|
+
Exclude:
|
67
|
+
- '**/*_spec.rb'
|
data/.travis.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
language: ruby
|
3
|
+
script: bundle exec rspec spec
|
4
|
+
matrix:
|
5
|
+
include:
|
6
|
+
- rvm: '1.9.3'
|
7
|
+
env: 'rspec=3.0'
|
8
|
+
- rvm: 'ruby-head'
|
9
|
+
env: 'rspec=master'
|
10
|
+
- rvm: 'rbx-2 --1.9'
|
11
|
+
env: 'rspec=3.0'
|
12
|
+
- rvm: 'rbx-2 --2.0'
|
13
|
+
env: 'rspec=master'
|
14
|
+
- rvm: 'jruby-19mode'
|
15
|
+
env: 'rspec=3.0'
|
16
|
+
- rvm: 'jruby-21mode'
|
17
|
+
env: 'rspec=master'
|
data/.yardopts
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
2
|
+
|
3
|
+
watch("bin/hexx-rspec") { "spec/tests/bin/install_spec.rb" }
|
4
|
+
|
5
|
+
watch(%r{^lib/tasks/(.+)\.rb$}) do |m|
|
6
|
+
[
|
7
|
+
"spec/tests/tasks/#{ m[1] }_spec.rb",
|
8
|
+
"spec/tests/tasks/#{ m[1] }/**/*_spec.rb"
|
9
|
+
]
|
10
|
+
end
|
11
|
+
|
12
|
+
watch(%r{^lib/hexx/rspec/(.+)\.rb$}) do |m|
|
13
|
+
"spec/tests/lib/#{ m[1] }_spec.rb"
|
14
|
+
end
|
15
|
+
|
16
|
+
watch(%r{^lib/hexx/rspec/(.+)/base\.rb$}) do |m|
|
17
|
+
"spec/tests/lib/#{ m[1] }/*_spec.rb"
|
18
|
+
end
|
19
|
+
|
20
|
+
watch("lib/hexx/rspec.rb") { "spec" }
|
21
|
+
|
22
|
+
watch("lib/hexx-rspec.rb") { "spec" }
|
23
|
+
|
24
|
+
watch(/^spec.+_spec\.rb$/)
|
25
|
+
|
26
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
27
|
+
|
28
|
+
watch("spec/spec_helper*.rb") { "spec" }
|
29
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2015 Andrew Kozin, https://github.com/nepalez
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# Hexx::RSpec
|
2
|
+
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/hexx-rspec.svg?style=flat)][gem]
|
4
|
+
[![Build Status](https://img.shields.io/travis/nepalez/hexx-rspec/master.svg?style=flat)][travis]
|
5
|
+
[![Dependency Status](https://img.shields.io/gemnasium/nepalez/hexx-rspec.svg?style=flat)][gemnasium]
|
6
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/nepalez/hexx-rspec.svg?style=flat)][codeclimate]
|
7
|
+
[![Coverage](https://img.shields.io/coveralls/nepalez/hexx-rspec.svg?style=flat)][coveralls]
|
8
|
+
|
9
|
+
[gem]: https://rubygems.org/gems/hexx-rspec
|
10
|
+
[travis]: https://travis-ci.org/nepalez/hexx-rspec
|
11
|
+
[gemnasium]: https://gemnasium.com/nepalez/hexx-rspec
|
12
|
+
[codeclimate]: https://codeclimate.com/github/nepalez/hexx-rspec
|
13
|
+
[coveralls]: https://coveralls.io/r/nepalez/hexx-rspec
|
14
|
+
|
15
|
+
The module adds RSpec, Coveralls and Simplecov dependencies to the gem, and adds their default settings.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
group :test, :development do
|
23
|
+
gem "hexx-rspec"
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
Then execute:
|
28
|
+
|
29
|
+
```
|
30
|
+
bundle
|
31
|
+
```
|
32
|
+
|
33
|
+
And run the task from the application root:
|
34
|
+
|
35
|
+
```
|
36
|
+
hexx-rspec install
|
37
|
+
```
|
38
|
+
|
39
|
+
Require the gem in the `spec_helper.rb` **before** loading application:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
# spec/spec_helper.rb
|
43
|
+
require "hexx-rspec"
|
44
|
+
|
45
|
+
# Loads coveralls runtime metric in the application's scope.
|
46
|
+
Hexx::RSpec.load_metrics_for(self)
|
47
|
+
|
48
|
+
# Loads the application under the test.
|
49
|
+
require "my_app"
|
50
|
+
```
|
51
|
+
|
52
|
+
Review the `config/metrics/simplecov.yml` for coverage report settings.
|
53
|
+
|
54
|
+
## Usage
|
55
|
+
|
56
|
+
Use `rake test` of `rake test:coverage` respectively.
|
57
|
+
|
58
|
+
Or run `rake test:coverage:run` and `rake test:coverage:display` separately.
|
59
|
+
|
60
|
+
## Compatibility
|
61
|
+
|
62
|
+
Tested under rubies with API 1.9.3+:
|
63
|
+
|
64
|
+
* MRI 1.9.3+
|
65
|
+
* JRuby 1.7+ (1.9 and 2.0+ modes)
|
66
|
+
* Rubinius 2+ (1.9 and 2.0+ modes)
|
67
|
+
|
68
|
+
[RSpec] 3.0+ used for testing
|
69
|
+
|
70
|
+
[RSpec]: http://rspec.info
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
* Fork the project.
|
75
|
+
* Make your feature addition or bug fix.
|
76
|
+
* Add tests for it. This is important so I don't break it in a
|
77
|
+
future version unintentionally.
|
78
|
+
* Commit, do not mess with Rakefile or version
|
79
|
+
(if you want to have your own version, that is fine but bump version
|
80
|
+
in a commit by itself I can ignore when I pull)
|
81
|
+
* Send me a pull request. Bonus points for topic branches.
|
82
|
+
|
83
|
+
## License
|
84
|
+
|
85
|
+
See [MIT LICENSE](file: LICENSE).
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
begin
|
3
|
+
require "bundler/setup"
|
4
|
+
rescue LoadError
|
5
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
6
|
+
exit
|
7
|
+
end
|
8
|
+
|
9
|
+
# Loads bundler tasks
|
10
|
+
Bundler::GemHelper.install_tasks
|
11
|
+
|
12
|
+
# Loads the Hexx::RSpec without tasks
|
13
|
+
require "hexx-rspec"
|
14
|
+
|
15
|
+
# Sets the :spec task to default
|
16
|
+
task :default do
|
17
|
+
system "bundle exec rspec spec"
|
18
|
+
end
|
data/bin/hexx-rspec
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Loads configuration files
|
4
|
+
require_relative "initializers/rspec"
|
5
|
+
require_relative "initializers/i18n"
|
6
|
+
require_relative "initializers/focus"
|
7
|
+
require_relative "initializers/random_order"
|
8
|
+
require_relative "initializers/garbage_collection"
|
data/hexx-rspec.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "hexx/rspec/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
|
6
|
+
gem.name = "hexx-rspec"
|
7
|
+
gem.version = Hexx::RSpec::VERSION.dup
|
8
|
+
gem.author = "Andrew Kozin"
|
9
|
+
gem.email = "andrew.kozin@gmail.com"
|
10
|
+
gem.homepage = "https://github.com/nepalez/hexx-rspec"
|
11
|
+
gem.summary = "RSpec settings."
|
12
|
+
gem.description = "RSpec, Coveralls and Simplecov settings."
|
13
|
+
gem.license = "MIT"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
|
+
gem.executables = ["hexx-rspec"]
|
17
|
+
gem.test_files = Dir["spec/**/*", "Rakefile", "Guardfile"]
|
18
|
+
gem.extra_rdoc_files = Dir["LICENSE", "README.md", ".yardopts"]
|
19
|
+
|
20
|
+
gem.required_ruby_version = ">= 1.9.3"
|
21
|
+
|
22
|
+
gem.add_runtime_dependency "coveralls", "~> 0.7"
|
23
|
+
gem.add_runtime_dependency "i18n", "~> 0.7"
|
24
|
+
gem.add_runtime_dependency "rake", "~> 10.3"
|
25
|
+
gem.add_runtime_dependency "rspec", "~> 3.0"
|
26
|
+
gem.add_runtime_dependency "simplecov", "~> 0.9"
|
27
|
+
gem.add_runtime_dependency "thor", "~> 0.19"
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
begin
|
3
|
+
require "bundler/setup"
|
4
|
+
rescue LoadError
|
5
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
6
|
+
exit
|
7
|
+
end
|
8
|
+
|
9
|
+
# Loads bundler tasks
|
10
|
+
Bundler::GemHelper.install_tasks
|
11
|
+
|
12
|
+
# Loads the Hexx::RSpec and its tasks
|
13
|
+
require "hexx-rspec"
|
14
|
+
Hexx::RSpec.install_tasks
|
15
|
+
|
16
|
+
# Sets the Hexx::RSpec :test task to default
|
17
|
+
task default: :test
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Hexx
|
2
|
+
module RSpec
|
3
|
+
|
4
|
+
# The generator creates a Rakefile in a destination root
|
5
|
+
class Install < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
# @!scope class
|
9
|
+
# @!method start
|
10
|
+
# Populates files into current directory
|
11
|
+
#
|
12
|
+
# @return [undefined]
|
13
|
+
#
|
14
|
+
# @api public
|
15
|
+
|
16
|
+
# @private
|
17
|
+
def self.source_root
|
18
|
+
@source_root ||= File.expand_path "../install", __FILE__
|
19
|
+
end
|
20
|
+
|
21
|
+
namespace :install
|
22
|
+
desc "Installs the 'hexx-rspec' gem."
|
23
|
+
|
24
|
+
# @private
|
25
|
+
def create_rakefile
|
26
|
+
copy_file "Rakefile"
|
27
|
+
end
|
28
|
+
|
29
|
+
# @private
|
30
|
+
def create_rspec
|
31
|
+
copy_file "_rspec", ".rspec"
|
32
|
+
end
|
33
|
+
|
34
|
+
# @private
|
35
|
+
def create_simplecov
|
36
|
+
copy_file "simplecov.yml", "config/metrics/simplecov.yml"
|
37
|
+
end
|
38
|
+
|
39
|
+
end # class Install
|
40
|
+
|
41
|
+
end # module RSpec
|
42
|
+
|
43
|
+
end # module Hexx
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hexx
|
4
|
+
|
5
|
+
module RSpec
|
6
|
+
|
7
|
+
module Metrics
|
8
|
+
|
9
|
+
# Base class for metrics configurators
|
10
|
+
#
|
11
|
+
# To be used by the 'hexx-suit' module as well
|
12
|
+
class Base
|
13
|
+
|
14
|
+
# The utility class for sending commands to the system
|
15
|
+
SYSTEM = System
|
16
|
+
|
17
|
+
# Loads metric settings and configures the current metric
|
18
|
+
#
|
19
|
+
# @return [Hexx::RSpec::Metrics]
|
20
|
+
# the configured metric object
|
21
|
+
def self.load
|
22
|
+
__send__(:new).load
|
23
|
+
end
|
24
|
+
|
25
|
+
# Configures and runs the current metric
|
26
|
+
#
|
27
|
+
# @return (see #run)
|
28
|
+
def self.run
|
29
|
+
load.run
|
30
|
+
end
|
31
|
+
|
32
|
+
# Loads the configuration file and configures the metric
|
33
|
+
#
|
34
|
+
# @return [self]
|
35
|
+
#
|
36
|
+
# @api private
|
37
|
+
def load
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
# Runs the metric
|
42
|
+
#
|
43
|
+
# @abstract
|
44
|
+
#
|
45
|
+
# @return [undefined]
|
46
|
+
#
|
47
|
+
# @api private
|
48
|
+
def run; end
|
49
|
+
|
50
|
+
# @note
|
51
|
+
# The class has a private constructor.
|
52
|
+
# Use methods {.load} or {.run}.
|
53
|
+
private_class_method :new
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
# Extracts a hash of settings from the current file
|
58
|
+
#
|
59
|
+
# @return [Hash]
|
60
|
+
#
|
61
|
+
# @api private
|
62
|
+
def settings
|
63
|
+
@settings ||= file ? YAML.load_file(file) : {}
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns the name of the settings file
|
67
|
+
#
|
68
|
+
# @return [String]
|
69
|
+
# when the file is present in the config/metrics folder
|
70
|
+
# @return [nil]
|
71
|
+
# when the file is absent in the config/metrics folder
|
72
|
+
#
|
73
|
+
# @api private
|
74
|
+
def file
|
75
|
+
@file ||= Dir["config/metrics/#{ name }.yml"].first
|
76
|
+
end
|
77
|
+
|
78
|
+
# The name of the current metric
|
79
|
+
#
|
80
|
+
# @abstract
|
81
|
+
#
|
82
|
+
# @return [Symbol]
|
83
|
+
attr_reader :name
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hexx
|
4
|
+
|
5
|
+
module RSpec
|
6
|
+
|
7
|
+
module Metrics
|
8
|
+
|
9
|
+
# Prepares and runs test coverage environment
|
10
|
+
#
|
11
|
+
# @api private
|
12
|
+
class SimpleCov < Base
|
13
|
+
|
14
|
+
# Loads the simplecov and coveralls gem
|
15
|
+
#
|
16
|
+
# @return [Hexx::RSpec::Metrics::SimpleCov]
|
17
|
+
#
|
18
|
+
# @api private
|
19
|
+
def self.new
|
20
|
+
%w(simplecov coveralls).each { |gem| require gem }
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
# @!scope class
|
25
|
+
# Configures the SimpleCov metric
|
26
|
+
#
|
27
|
+
# @return [self]
|
28
|
+
def load
|
29
|
+
set_environment
|
30
|
+
configure_metric
|
31
|
+
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
# @!scope class
|
36
|
+
# Configures simplecov from the simplecov.yml file and starts
|
37
|
+
# the metric
|
38
|
+
#
|
39
|
+
# @return [undefined]
|
40
|
+
def run
|
41
|
+
metric.start
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# simplecov metric definitions
|
47
|
+
|
48
|
+
def name
|
49
|
+
"simplecov"
|
50
|
+
end
|
51
|
+
|
52
|
+
def metric
|
53
|
+
::SimpleCov
|
54
|
+
end
|
55
|
+
|
56
|
+
def default_options
|
57
|
+
{
|
58
|
+
"output" => "tmp/coverage",
|
59
|
+
"filters" => ["spec/", "config/"],
|
60
|
+
"groups" => {
|
61
|
+
"Libraries" => "lib/",
|
62
|
+
"Application" => "app/"
|
63
|
+
}
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# operations
|
68
|
+
|
69
|
+
def set_environment
|
70
|
+
ENV["USE_SIMPLECOV"] = "true"
|
71
|
+
ENV["SIMPLECOV_OUTPUT"] = "#{ output }/index.html"
|
72
|
+
end
|
73
|
+
|
74
|
+
def configure_metric
|
75
|
+
add_filters
|
76
|
+
add_groups
|
77
|
+
set_formatters
|
78
|
+
set_output
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_filters
|
82
|
+
filters.each(&metric.method(:add_filter))
|
83
|
+
end
|
84
|
+
|
85
|
+
def add_groups
|
86
|
+
groups.each { |key, value| metric.add_group(key, value) }
|
87
|
+
end
|
88
|
+
|
89
|
+
def set_formatters
|
90
|
+
metric.formatter = metric::Formatter::MultiFormatter[
|
91
|
+
metric::Formatter::HTMLFormatter,
|
92
|
+
::Coveralls::SimpleCov::Formatter
|
93
|
+
]
|
94
|
+
end
|
95
|
+
|
96
|
+
def set_output
|
97
|
+
metric.coverage_dir output
|
98
|
+
end
|
99
|
+
|
100
|
+
# helpers
|
101
|
+
|
102
|
+
def options
|
103
|
+
@options ||= default_options.merge settings.to_hash
|
104
|
+
end
|
105
|
+
|
106
|
+
def output
|
107
|
+
@output = options["output"]
|
108
|
+
end
|
109
|
+
|
110
|
+
def filters
|
111
|
+
@filters ||= Array(options["filters"]).flatten.map(&:to_s)
|
112
|
+
end
|
113
|
+
|
114
|
+
def groups
|
115
|
+
@groups ||= begin
|
116
|
+
list = options["groups"]
|
117
|
+
list.is_a?(Hash) ? list : {}
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hexx
|
4
|
+
|
5
|
+
module RSpec
|
6
|
+
|
7
|
+
# Contains metric configurators
|
8
|
+
#
|
9
|
+
# Any configurator loads metric settings from a corresponding yaml,
|
10
|
+
# sets necessary environments via {.load} method,
|
11
|
+
# and then runs the metric via {.run} method.
|
12
|
+
#
|
13
|
+
# Configurators loads their own dependencies in a corresponding constructor.
|
14
|
+
module Metrics
|
15
|
+
|
16
|
+
require_relative "metrics/base"
|
17
|
+
require_relative "metrics/simplecov.rb"
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end # module RSpec
|
22
|
+
|
23
|
+
end # mdoule Hexx
|