spec_coverage 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/README.md +28 -0
- data/Rakefile +2 -0
- data/lib/spec_coverage.rb +55 -0
- data/spec_coverage.gemspec +21 -0
- metadata +78 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# SpecCoverage
|
2
|
+
|
3
|
+
This formatter loads SimpleCov a code coverage reporting tool for Ruby 1.9. SimpleCov already does a good job in making it really easy to configure and load itself, but even good efforts can be improved upon.
|
4
|
+
|
5
|
+
The only problem is that you'll need to have something like a spec_helper to load it. You might not have this or you might find it ugly having to resort to environment variables to turn it off or on.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
If you are using bundler, then don't forget to add simplecov to your `Gemfile`:
|
10
|
+
|
11
|
+
gem 'spec_coverage', :group => :test, :require => false
|
12
|
+
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
With this formatter, SimpleCov will start, and it will load a `.coverage` file in which you can add ruby code to configure SimpleCov in a non-obtrusive way. Configuration for a typical Rails app will look like this:
|
17
|
+
|
18
|
+
SimpleCov.start 'rails'
|
19
|
+
|
20
|
+
This formatter doesn't have any output, so you'll probably want to add another formatter. I prefer the documentation (if the number of specs is limited) or Fuubar formatter (for big spec suites):
|
21
|
+
|
22
|
+
rspec spec -f SpecCoverage -fd
|
23
|
+
rspec spec -f SpecCoverage -f Fuubar
|
24
|
+
|
25
|
+
|
26
|
+
More information on SimpleCov can be found [here](https://github.com/colszowka/simplecov).
|
27
|
+
|
28
|
+
More information on RSpec formatters can be found [here](http://relishapp.com/rspec/rspec-core/v/2-6/dir/command-line/format-option).
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rspec/core/formatters/base_formatter'
|
2
|
+
require 'simplecov'
|
3
|
+
|
4
|
+
# This formatter does nothing else but run SimpleCov. That means that if you run this formatter on
|
5
|
+
# its own, you won't get any output. It is advised to add your favorite formatter, like this, to see
|
6
|
+
# test failures and so on:
|
7
|
+
#
|
8
|
+
# rspec spec -f SpecCoverage -fd
|
9
|
+
#
|
10
|
+
class SpecCoverage < ::RSpec::Core::Formatters::BaseFormatter
|
11
|
+
|
12
|
+
def initialize(*)
|
13
|
+
super
|
14
|
+
add_default_filter
|
15
|
+
load_simplecov_config
|
16
|
+
start_simplecov
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# This is an RSpec filter, so we can safely assume that specs should be ignored
|
22
|
+
def add_default_filter
|
23
|
+
SimpleCov.add_filter '/spec/'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Load a local .coverage file, to customize it yourself
|
27
|
+
#
|
28
|
+
# Example contents of this file:
|
29
|
+
#
|
30
|
+
# SimpleCov.start do
|
31
|
+
# add_filter '/foo/'
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# Rails users might want to add at least something like:
|
35
|
+
#
|
36
|
+
# SimpleCov.start 'rails'
|
37
|
+
#
|
38
|
+
def load_simplecov_config
|
39
|
+
load config_file if config_exists?
|
40
|
+
end
|
41
|
+
|
42
|
+
def config_exists?
|
43
|
+
File.exist?(config_file)
|
44
|
+
end
|
45
|
+
|
46
|
+
def config_file
|
47
|
+
File.expand_path(".coverage", SimpleCov.root)
|
48
|
+
end
|
49
|
+
|
50
|
+
# If you didn't start SimpleCov in your .coverage file, start it now
|
51
|
+
def start_simplecov
|
52
|
+
SimpleCov.start unless SimpleCov.running
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Iain Hecker"]
|
5
|
+
gem.email = ["iain@iain.nl"]
|
6
|
+
gem.description = %q{Use SimpleCov more easily as an RSpec formatter}
|
7
|
+
gem.summary = %q{SpecCoverage allows you to use SimpleCov whenever you want, without having to put it in your spec_helper.rb file. It doesn’t output anything like you’d expect from a normal formatter, so you’re going to have to use another one to see your test output.}
|
8
|
+
gem.homepage = 'https://github.com/iain/spec_coverage'
|
9
|
+
|
10
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
11
|
+
gem.files = `git ls-files`.split("\n")
|
12
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
gem.name = "spec_coverage"
|
14
|
+
gem.require_paths = ['lib']
|
15
|
+
gem.version = '0.0.3'
|
16
|
+
|
17
|
+
gem.add_dependency('rspec', ['~> 2.0'])
|
18
|
+
gem.add_dependency('simplecov', ['~> 0.4.2'])
|
19
|
+
|
20
|
+
gem.required_ruby_version = ">= 1.9"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spec_coverage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Iain Hecker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-07-04 00:00:00.000000000 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: &2173494240 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2173494240
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: simplecov
|
28
|
+
requirement: &2173493600 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2173493600
|
37
|
+
description: Use SimpleCov more easily as an RSpec formatter
|
38
|
+
email:
|
39
|
+
- iain@iain.nl
|
40
|
+
executables: []
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- lib/spec_coverage.rb
|
49
|
+
- spec_coverage.gemspec
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: https://github.com/iain/spec_coverage
|
52
|
+
licenses: []
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.9'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.6.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: SpecCoverage allows you to use SimpleCov whenever you want, without having
|
75
|
+
to put it in your spec_helper.rb file. It doesn’t output anything like you’d expect
|
76
|
+
from a normal formatter, so you’re going to have to use another one to see your
|
77
|
+
test output.
|
78
|
+
test_files: []
|