rspec-simplecov 0.1.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.
- checksums.yaml +7 -0
- data/lib/rspec/simplecov.rb +17 -0
- data/lib/rspec/simplecov/configuration.rb +37 -0
- data/lib/rspec/simplecov/setup.rb +68 -0
- data/lib/rspec/simplecov/version.rb +5 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5b3e8e58865e6653984e21f918c756c7f7234264
|
4
|
+
data.tar.gz: bfd8de2641ea034bad0b2586e88efff53e577b4f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8e97548a1f154c40d4a0ae85cca33b203275d96a4de813cdc2a2456f3f937553b9bb7996dd8646595f0af1bf52b7f88ea9203b6c90ec76dddf87666cc28ef8f8
|
7
|
+
data.tar.gz: dad045c58dcc031b3c446c54cfadc86c38393a1b9aa45cf7123f287fa35bbc3e3fe4ccc91171fe7ffff4943d9e27f8bd613c00f3fa50630fac918843ec76f9a8
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "rspec/simplecov/configuration"
|
2
|
+
require "rspec/simplecov/setup"
|
3
|
+
require "rspec/simplecov/version"
|
4
|
+
|
5
|
+
module RSpec
|
6
|
+
module SimpleCov
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def start( simplecov_instance = ::SimpleCov, &block )
|
10
|
+
configuration = Configuration.new( simplecov_instance, caller.to_a, &block )
|
11
|
+
|
12
|
+
Setup.do( configuration )
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "docile"
|
2
|
+
require "simplecov"
|
3
|
+
|
4
|
+
module RSpec
|
5
|
+
module SimpleCov
|
6
|
+
class Configuration
|
7
|
+
|
8
|
+
attr_accessor :described_thing, :context_text, :test_case_text,
|
9
|
+
:caller_path, :backtrace
|
10
|
+
|
11
|
+
def describe thing
|
12
|
+
@described_thing = thing
|
13
|
+
end
|
14
|
+
|
15
|
+
def context text
|
16
|
+
@context_text = text
|
17
|
+
end
|
18
|
+
|
19
|
+
def it what
|
20
|
+
@test_case_text = what
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize( simplecov_instance, backtrace = [], &block )
|
24
|
+
@described_thing = simplecov_instance
|
25
|
+
|
26
|
+
@caller_path = backtrace[0].split(':').first
|
27
|
+
@backtrace = backtrace
|
28
|
+
|
29
|
+
@context_text = "#minimum_coverage"
|
30
|
+
@test_case_text = "must be at least #{simplecov_instance.minimum_coverage}%"
|
31
|
+
|
32
|
+
Docile.dsl_eval( self, &block ) if block_given?
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'simplecov'
|
3
|
+
|
4
|
+
module RSpec
|
5
|
+
module SimpleCov
|
6
|
+
module Setup
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
# Ugly hack ...
|
11
|
+
def with_metadata_key_location_unreserved
|
12
|
+
RSpec::Core::Metadata::RESERVED_KEYS.delete(:location)
|
13
|
+
yield
|
14
|
+
RSpec::Core::Metadata::RESERVED_KEYS.push(:location)
|
15
|
+
end
|
16
|
+
|
17
|
+
def do( configuration )
|
18
|
+
RSpec.configure do |config|
|
19
|
+
|
20
|
+
config.after(:suite) do
|
21
|
+
# Setup empty vars to hold the group and example refs.
|
22
|
+
coverage_example_group = nil
|
23
|
+
coverage_example_context = nil
|
24
|
+
coverage_example = nil
|
25
|
+
|
26
|
+
# Build the fake test for coverage
|
27
|
+
RSpec::SimpleCov::Setup.with_metadata_key_location_unreserved do
|
28
|
+
coverage_example_group = RSpec.describe( configuration.described_thing, location: 'spec_helper_spec.rb') do
|
29
|
+
coverage_example_context = context configuration.context_text do
|
30
|
+
coverage_example = it configuration.test_case_text do
|
31
|
+
expect( configuration.described_thing.result.covered_percent ).to be >= configuration.described_thing.minimum_coverage
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Run the test
|
38
|
+
RSpec.configuration.reporter.example_group_started coverage_example_group
|
39
|
+
RSpec.configuration.reporter.example_group_started coverage_example_context
|
40
|
+
RSpec.configuration.reporter.example_started coverage_example
|
41
|
+
coverage_example_group.run
|
42
|
+
|
43
|
+
coverage_example_group.metadata[ :absolute_file_path ] = configuration.caller_path
|
44
|
+
coverage_example_group.metadata[ :rerun_file_path ] = configuration.caller_path
|
45
|
+
coverage_example_group.metadata[ :file_path ] = configuration.caller_path
|
46
|
+
|
47
|
+
coverage_example.execution_result.exception.backtrace.push( *configuration.backtrace )
|
48
|
+
|
49
|
+
# Evaluate the result
|
50
|
+
passed = coverage_example.execution_result.status == :passed
|
51
|
+
failed = !passed
|
52
|
+
|
53
|
+
# Message the reporter to have it show up in the results
|
54
|
+
RSpec.configuration.reporter.example_failed coverage_example if failed
|
55
|
+
RSpec.configuration.reporter.example_passed coverage_example if passed
|
56
|
+
|
57
|
+
# Close out the reporter groups
|
58
|
+
RSpec.configuration.reporter.example_group_finished coverage_example_context
|
59
|
+
RSpec.configuration.reporter.example_group_finished coverage_example_group
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-simplecov
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonas Schubert Erlandsson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: simplecov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.6'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.6'
|
83
|
+
description: Creates an after suite hook in RSpect that dynamically creates and injects
|
84
|
+
a new test case that expects the actual code coverage to be at least the lower limit
|
85
|
+
set in SimpleCov.
|
86
|
+
email:
|
87
|
+
- jonas.schubert.erlandsson@my-codeworks.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- lib/rspec/simplecov.rb
|
93
|
+
- lib/rspec/simplecov/configuration.rb
|
94
|
+
- lib/rspec/simplecov/setup.rb
|
95
|
+
- lib/rspec/simplecov/version.rb
|
96
|
+
homepage: https://github.com/replaygaming/rspec-simplecov
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.4.5
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Integrates SimpleCov with RSpec so that low code coverage fails the test
|
120
|
+
suite.
|
121
|
+
test_files: []
|