selective-ruby-rspec 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 357a3e88c5faad8cc7d188615b158094058f55b9342977bc999c14cfcdc82980
|
4
|
+
data.tar.gz: 6afe356356bd83ae83cce8267a3d98446489621dee5960eda86772bd29861273
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47046465fbc086af40e51f7bf74e8ffd65c4d2b5c92ba914eff1e6a567e8cc005abad6b4f8e5e08492f0e35d076afd2c1f1cb3faa50f05ced435c72e5a910518
|
7
|
+
data.tar.gz: d7013aba148b15d7a9f7576cf8e99f7497cf1860610d32ad6d5a6d802903862152921fa3fe8b8104767320e7012606afb6d0f758ab887fd8ac59c26293c57f13
|
@@ -139,10 +139,10 @@ module Selective
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
-
module Hooks
|
143
|
-
hooks = %i(before prepend_before after append_after)
|
144
142
|
|
145
|
-
|
143
|
+
HOOKS = %i(before prepend_before after append_after)
|
144
|
+
module Hooks
|
145
|
+
HOOKS.each do |hook|
|
146
146
|
define_method(hook) do |*args, &block|
|
147
147
|
args = args.map { |a| a == :all ? :each : a }
|
148
148
|
super(*args, &block)
|
@@ -150,7 +150,21 @@ module Selective
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
|
153
|
+
module RequireEachHooks
|
154
|
+
HOOKS.each do |hook|
|
155
|
+
define_method(hook) do |*args, &block|
|
156
|
+
if args.none? { |a| a == :all}
|
157
|
+
super(*args, &block)
|
158
|
+
else
|
159
|
+
super(*args) do
|
160
|
+
raise "Before :all hooks are not supported when using --require-each-hooks. Please use before(:each) instead."
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def self.apply(config)
|
154
168
|
::RSpec::Support.require_rspec_core("formatters/base_text_formatter")
|
155
169
|
|
156
170
|
MAP.each do |module_name, _methods|
|
@@ -163,7 +177,11 @@ module Selective
|
|
163
177
|
# a bug in < Ruby 3.0 that prevents us from doing so. Instead,
|
164
178
|
# we extend the ExampleGroup class which is where the Hooks module
|
165
179
|
# is included.
|
166
|
-
|
180
|
+
if config[:require_each_hooks]
|
181
|
+
::RSpec::Core::ExampleGroup.extend(RequireEachHooks)
|
182
|
+
else
|
183
|
+
::RSpec::Core::ExampleGroup.extend(Hooks)
|
184
|
+
end
|
167
185
|
|
168
186
|
::RSpec.singleton_class.prepend(RSpec)
|
169
187
|
::RSpec::Core::Reporter.prepend(Reporter)
|
@@ -7,20 +7,17 @@ module Selective
|
|
7
7
|
class RunnerWrapper
|
8
8
|
class TestManifestError < StandardError; end
|
9
9
|
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :rspec_runner, :config
|
11
11
|
|
12
|
+
FRAMEWORK = "rspec"
|
12
13
|
DEFAULT_SPEC_PATH = "./spec"
|
13
14
|
|
14
15
|
def initialize(args)
|
15
|
-
|
16
|
-
|
17
|
-
Selective::Ruby::RSpec::Monkeypatches.apply
|
16
|
+
rspec_args, wrapper_config_hash = parse_args(args)
|
17
|
+
Selective::Ruby::RSpec::Monkeypatches.apply(wrapper_config_hash)
|
18
18
|
apply_rspec_configuration
|
19
19
|
|
20
|
-
|
21
|
-
@args = args
|
22
|
-
|
23
|
-
@config = ::RSpec::Core::ConfigurationOptions.new(args)
|
20
|
+
@config = ::RSpec::Core::ConfigurationOptions.new(rspec_args)
|
24
21
|
if config.options[:files_or_directories_to_run].empty?
|
25
22
|
config.options[:files_or_directories_to_run] = [DEFAULT_SPEC_PATH]
|
26
23
|
end
|
@@ -29,6 +26,23 @@ module Selective
|
|
29
26
|
@rspec_runner.setup($stderr, $stdout)
|
30
27
|
end
|
31
28
|
|
29
|
+
def parse_args(args)
|
30
|
+
supported_wrapper_args = %w[--require-each-hooks]
|
31
|
+
wrapper_args, rspec_args = args.partition do |arg|
|
32
|
+
supported_wrapper_args.any? do |p|
|
33
|
+
arg.start_with?(p)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
wrapper_config_hash = wrapper_args.each_with_object({}) do |arg, hash|
|
38
|
+
key = arg.sub('--', '').tr('-', '_').to_sym
|
39
|
+
hash[key] = true
|
40
|
+
end
|
41
|
+
|
42
|
+
rspec_args << "--format=progress" unless args.any? { |e| e.start_with?("--format") }
|
43
|
+
[rspec_args, wrapper_config_hash]
|
44
|
+
end
|
45
|
+
|
32
46
|
def manifest
|
33
47
|
output = nil
|
34
48
|
Tempfile.create("selective-rspec-dry-run") do |f|
|
@@ -80,6 +94,18 @@ module Selective
|
|
80
94
|
::RSpec.world.reporter.finish
|
81
95
|
end
|
82
96
|
|
97
|
+
def framework
|
98
|
+
RunnerWrapper::FRAMEWORK
|
99
|
+
end
|
100
|
+
|
101
|
+
def framework_version
|
102
|
+
::RSpec::Core::Version::STRING
|
103
|
+
end
|
104
|
+
|
105
|
+
def wrapper_version
|
106
|
+
RSpec::VERSION
|
107
|
+
end
|
108
|
+
|
83
109
|
private
|
84
110
|
|
85
111
|
def run_test_case(test_case_id, callback)
|
data/lib/selective-ruby-rspec.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "zeitwerk"
|
4
|
+
require "rspec/core"
|
5
|
+
require "#{__dir__}/selective/ruby/rspec/version"
|
4
6
|
|
5
7
|
loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
|
6
8
|
loader.inflector.inflect("rspec" => "RSpec")
|
7
9
|
loader.ignore("#{__dir__}/selective-ruby-rspec.rb")
|
10
|
+
loader.ignore("#{__dir__}/selective/ruby/rspec/version.rb")
|
8
11
|
loader.setup
|
9
12
|
|
10
13
|
require "selective-ruby-core"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selective-ruby-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Wood
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: zeitwerk
|