mutant-rspec 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mutant/integration/rspec.rb +14 -20
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ce61b03bc84a18f1aeefa23525c4528f46bfba0
|
4
|
+
data.tar.gz: e56f72c8e904b9dfc8bd78fa80ba87bbe04d48db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1892d1ae766c77ab5ce6382cfb31260c79e8c1e7aeeb3a9d364bcabb6f4adb04e77c7de7e6e92528f5dd49dbb3a59ff97139e8ab7ea33b6cb4583fc0c67b1e7
|
7
|
+
data.tar.gz: 1290c76e15452c0e6e81c137c74c71aea8e28d5cf500169058caf61acf45770cb5ac9c7b8a555fc8aba666cabf8bc7314be183d024d0eaced5bab20382d78990
|
@@ -12,19 +12,21 @@ module Mutant
|
|
12
12
|
# datastructure
|
13
13
|
# * Does not maintain a unique identification for an example,
|
14
14
|
# aside the instances of `RSpec::Core::Example` objects itself.
|
15
|
-
# For that reason
|
15
|
+
# For that reason identifying examples by:
|
16
16
|
# * full description
|
17
17
|
# * location
|
18
|
-
# Is NOT enough. It would not be
|
18
|
+
# Is NOT enough. It would not be unique. So we add an "example index"
|
19
19
|
# for unique reference.
|
20
20
|
class Rspec < self
|
21
21
|
|
22
|
-
|
22
|
+
ALL_EXPRESSION = Expression::Namespace::Recursive.new(scope_name: nil)
|
23
23
|
EXPRESSION_CANDIDATE = /\A([^ ]+)(?: )?/.freeze
|
24
24
|
LOCATION_DELIMITER = ':'.freeze
|
25
25
|
EXIT_SUCCESS = 0
|
26
26
|
CLI_OPTIONS = IceNine.deep_freeze(%w[spec --fail-fast])
|
27
27
|
|
28
|
+
private_constant(*constants(false))
|
29
|
+
|
28
30
|
register 'rspec'
|
29
31
|
|
30
32
|
# Initialize rspec integration
|
@@ -32,8 +34,8 @@ module Mutant
|
|
32
34
|
# @return [undefined]
|
33
35
|
#
|
34
36
|
# @api private
|
35
|
-
|
36
|
-
|
37
|
+
def initialize(*)
|
38
|
+
super
|
37
39
|
@output = StringIO.new
|
38
40
|
@runner = RSpec::Core::Runner.new(RSpec::Core::ConfigurationOptions.new(CLI_OPTIONS))
|
39
41
|
@world = RSpec.world
|
@@ -44,23 +46,21 @@ module Mutant
|
|
44
46
|
# @return [self]
|
45
47
|
#
|
46
48
|
# @api private
|
47
|
-
#
|
48
49
|
def setup
|
49
50
|
@runner.setup($stderr, @output)
|
50
51
|
self
|
51
52
|
end
|
52
53
|
memoize :setup
|
53
54
|
|
54
|
-
#
|
55
|
+
# Run a collection of tests
|
55
56
|
#
|
56
57
|
# @param [Enumerable<Mutant::Test>] tests
|
57
58
|
#
|
58
59
|
# @return [Result::Test]
|
59
60
|
#
|
60
|
-
# @api private
|
61
|
-
#
|
62
61
|
# rubocop:disable MethodLength
|
63
62
|
#
|
63
|
+
# @api private
|
64
64
|
def call(tests)
|
65
65
|
examples = tests.map(&all_tests_index.method(:fetch))
|
66
66
|
filter_examples(&examples.method(:include?))
|
@@ -75,12 +75,11 @@ module Mutant
|
|
75
75
|
)
|
76
76
|
end
|
77
77
|
|
78
|
-
#
|
78
|
+
# Available tests
|
79
79
|
#
|
80
80
|
# @return [Enumerable<Test>]
|
81
81
|
#
|
82
82
|
# @api private
|
83
|
-
#
|
84
83
|
def all_tests
|
85
84
|
all_tests_index.keys
|
86
85
|
end
|
@@ -88,12 +87,11 @@ module Mutant
|
|
88
87
|
|
89
88
|
private
|
90
89
|
|
91
|
-
#
|
90
|
+
# Index of available tests
|
92
91
|
#
|
93
92
|
# @return [Hash<Test, RSpec::Core::Example]
|
94
93
|
#
|
95
94
|
# @api private
|
96
|
-
#
|
97
95
|
def all_tests_index
|
98
96
|
all_examples.each_with_index.each_with_object({}) do |(example, example_index), index|
|
99
97
|
index[parse_example(example, example_index)] = example
|
@@ -109,7 +107,6 @@ module Mutant
|
|
109
107
|
# @return [Test]
|
110
108
|
#
|
111
109
|
# @api private
|
112
|
-
#
|
113
110
|
def parse_example(example, index)
|
114
111
|
metadata = example.metadata
|
115
112
|
location = metadata.fetch(:location)
|
@@ -128,22 +125,20 @@ module Mutant
|
|
128
125
|
# @return [Expression]
|
129
126
|
#
|
130
127
|
# @api private
|
131
|
-
#
|
132
128
|
def parse_expression(metadata)
|
133
129
|
if metadata.key?(:mutant_expression)
|
134
|
-
|
130
|
+
expression_parser.(metadata.fetch(:mutant_expression))
|
135
131
|
else
|
136
132
|
match = EXPRESSION_CANDIDATE.match(metadata.fetch(:full_description))
|
137
|
-
|
133
|
+
expression_parser.try_parse(match.captures.first) || ALL_EXPRESSION
|
138
134
|
end
|
139
135
|
end
|
140
136
|
|
141
|
-
#
|
137
|
+
# Available rspec examples
|
142
138
|
#
|
143
139
|
# @return [Array<String, RSpec::Core::Example]
|
144
140
|
#
|
145
141
|
# @api private
|
146
|
-
#
|
147
142
|
def all_examples
|
148
143
|
@world.example_groups.flat_map(&:descendants).flat_map(&:examples).select do |example|
|
149
144
|
example.metadata.fetch(:mutant, true)
|
@@ -157,7 +152,6 @@ module Mutant
|
|
157
152
|
# @return [undefined]
|
158
153
|
#
|
159
154
|
# @api private
|
160
|
-
#
|
161
155
|
def filter_examples(&predicate)
|
162
156
|
@world.filtered_examples.each_value do |examples|
|
163
157
|
examples.keep_if(&predicate)
|
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.8.
|
4
|
+
version: 0.8.1
|
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-07-24 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.8.
|
19
|
+
version: 0.8.1
|
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.8.
|
26
|
+
version: 0.8.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|