mutant-rspec 0.7.8 → 0.7.9
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 +4 -4
- data/lib/mutant/integration/rspec.rb +38 -8
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72406849fd8b2dec6ae91df43cdc7c8b07ec262b
|
4
|
+
data.tar.gz: b46c5ace26939895523b29a58fbd62877f8f5ec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38c27e114a09161c1725d0d3ff46e990c3269bf0473286585a7cf55f40c452c449a3dc3d8f2b9efeab277df710a0b8f8b1f839724605ef650dfb7ba50b463d69
|
7
|
+
data.tar.gz: 9e75774048aa4fbb817dd76d58f7510760df53ecf54185cc1e9be519a4a4489f1b9a0aef86bb2db9fda88f5c1d476ea82e928126245d98c7b304de42176b0354
|
@@ -2,11 +2,25 @@ require 'rspec/core'
|
|
2
2
|
|
3
3
|
module Mutant
|
4
4
|
class Integration
|
5
|
-
#
|
5
|
+
# Rspec integration
|
6
|
+
#
|
7
|
+
# This looks so complicated, because rspec:
|
8
|
+
#
|
9
|
+
# * Keeps its state global in RSpec.world and lots of other places
|
10
|
+
# * There is no API to "just run a subset of examples", the examples
|
11
|
+
# need to be selected in-place via mutating the `RSpec.filtered_examples`
|
12
|
+
# datastructure
|
13
|
+
# * Does not maintain a unique identification for an example,
|
14
|
+
# aside the instances of `RSpec::Core::Example` objects itself.
|
15
|
+
# For that reason identifing examples by:
|
16
|
+
# * full description
|
17
|
+
# * location
|
18
|
+
# Is NOT enough. It would not be uniqe. So we add an "example index"
|
19
|
+
# for unique reference.
|
6
20
|
class Rspec < self
|
7
21
|
|
8
22
|
ALL = Mutant::Expression.parse('*')
|
9
|
-
|
23
|
+
EXPRESSION_CANDIDATE = /\A([^ ]+)(?: )?/.freeze
|
10
24
|
LOCATION_DELIMITER = ':'.freeze
|
11
25
|
EXIT_SUCCESS = 0
|
12
26
|
CLI_OPTIONS = IceNine.deep_freeze(%w[spec --fail-fast])
|
@@ -48,10 +62,10 @@ module Mutant
|
|
48
62
|
# rubocop:disable MethodLength
|
49
63
|
#
|
50
64
|
def call(tests)
|
51
|
-
examples = tests.map(&all_tests_index.method(:fetch))
|
65
|
+
examples = tests.map(&all_tests_index.method(:fetch))
|
52
66
|
filter_examples(&examples.method(:include?))
|
53
67
|
start = Time.now
|
54
|
-
passed = @runner.run_specs(
|
68
|
+
passed = @runner.run_specs(@world.ordered_example_groups).equal?(EXIT_SUCCESS)
|
55
69
|
@output.rewind
|
56
70
|
Result::Test.new(
|
57
71
|
tests: tests,
|
@@ -97,17 +111,33 @@ module Mutant
|
|
97
111
|
# @api private
|
98
112
|
#
|
99
113
|
def parse_example(example, index)
|
100
|
-
metadata
|
101
|
-
location
|
114
|
+
metadata = example.metadata
|
115
|
+
location = metadata.fetch(:location)
|
102
116
|
full_description = metadata.fetch(:full_description)
|
103
|
-
expression = Expression.try_parse(full_description.split(EXPRESSION_DELIMITER, 2).first) || ALL
|
104
117
|
|
105
118
|
Test.new(
|
106
119
|
id: "rspec:#{index}:#{location}/#{full_description}",
|
107
|
-
expression:
|
120
|
+
expression: parse_expression(metadata)
|
108
121
|
)
|
109
122
|
end
|
110
123
|
|
124
|
+
# Parse metadata into expression
|
125
|
+
#
|
126
|
+
# @param [RSpec::Core::Example::Medatada] metadata
|
127
|
+
#
|
128
|
+
# @return [Expression]
|
129
|
+
#
|
130
|
+
# @api private
|
131
|
+
#
|
132
|
+
def parse_expression(metadata)
|
133
|
+
if metadata.key?(:mutant_expression)
|
134
|
+
Expression.parse(metadata.fetch(:mutant_expression))
|
135
|
+
else
|
136
|
+
match = EXPRESSION_CANDIDATE.match(metadata.fetch(:full_description))
|
137
|
+
Expression.try_parse(match.captures.first) || ALL
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
111
141
|
# Return all examples
|
112
142
|
#
|
113
143
|
# @return [Array<String, RSpec::Core::Example]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mutant-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mutant
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.7.
|
19
|
+
version: 0.7.9
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.7.
|
26
|
+
version: 0.7.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.4.5
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Rspec integration for mutant
|