opal-rspec 1.1.0.alpha2 → 1.1.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/opal/rspec/configuration_parser.rb +10 -0
- data/lib/opal/rspec/runner.rb +5 -0
- data/lib/opal/rspec/version.rb +1 -1
- data/lib-opal/opal/rspec/fixes/rspec/core/configuration.rb +35 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ade995b0c6d3f286e1fab0a744a29747a9404af45a8379dacbd30a42a04521d
|
4
|
+
data.tar.gz: c2e8c3252227413b183f0c0aaad68de756cb933b182aa250d92d565ffe4d8a71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c785be231521c658867c6fbe412066199feaab7ebb1f5fd28966f96f828bc5f783950f9ea1e8b27f2a973b46897809def87904e1f71105485881f8c03c436f33
|
7
|
+
data.tar.gz: 9ef0711790bcd41452f75f5d7a721f7db2194f30f88e17abbcc25a931d9a1424a88d65d70d4803a274778cfd295824ac8bc44531029103bf906e9a5bc2b45398
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Opal-RSpec Changelog
|
2
2
|
|
3
|
+
## 1.1.0.alpha3 - 2023-09-26
|
4
|
+
|
5
|
+
- Refactor glob_to_re into a robust implementation
|
6
|
+
|
7
|
+
- Add `--opal-opt` CLI option
|
8
|
+
|
9
|
+
- Add `--rbrequire` CLI option
|
10
|
+
|
11
|
+
|
3
12
|
## 1.1.0.alpha2 - 2023-09-20
|
4
13
|
|
5
14
|
- Drop advertised support for Opal v1.6
|
@@ -22,6 +22,16 @@ class Opal::RSpec::Core::Parser
|
|
22
22
|
options[:runner] = name
|
23
23
|
end
|
24
24
|
|
25
|
+
parser.on('-q', '--rbrequire FILE', 'Require a file in MRI context before running Opal') do |name|
|
26
|
+
options[:opal_rbrequires] ||= []
|
27
|
+
options[:opal_rbrequires] << name
|
28
|
+
end
|
29
|
+
|
30
|
+
parser.on('-O', '--opal-opt FLAG', 'Run Opal with additional options (separate by `,` or specify multiple times)') do |name|
|
31
|
+
options[:opal_options] ||= []
|
32
|
+
options[:opal_options] += name.split(",")
|
33
|
+
end
|
34
|
+
|
25
35
|
parser.separator ''
|
26
36
|
parser.separator ' **** Help ****'
|
27
37
|
parser.separator ''
|
data/lib/opal/rspec/runner.rb
CHANGED
@@ -117,6 +117,10 @@ module Opal
|
|
117
117
|
options << '--missing-require=ignore'
|
118
118
|
options += @legacy_server_proxy.to_cli_options
|
119
119
|
|
120
|
+
spec_opts.delete(:opal_rbrequires) { [] }.each do |r|
|
121
|
+
require r
|
122
|
+
end
|
123
|
+
|
120
124
|
load_paths = [Opal.paths, locator.get_spec_load_paths, self.libs].compact.sum([]).uniq
|
121
125
|
|
122
126
|
load_paths.each { |p| options << "-I#{p}" }
|
@@ -125,6 +129,7 @@ module Opal
|
|
125
129
|
::Opal::Config.stubbed_files.each { |p| options << "-s#{p}" }
|
126
130
|
|
127
131
|
options += @cli_options if @cli_options
|
132
|
+
options += spec_opts.delete(:opal_options) { [] }
|
128
133
|
|
129
134
|
bootstrap_code = ::Opal::RSpec.spec_opts_code(spec_opts)
|
130
135
|
|
data/lib/opal/rspec/version.rb
CHANGED
@@ -23,27 +23,49 @@ module ::RSpec; module Core; class Configuration
|
|
23
23
|
str.gsub(/(?:\.js)?\.(?:rb|opal|\{rb,opal\})\z/, '')
|
24
24
|
end
|
25
25
|
|
26
|
+
def glob_to_re_expand_alternatives(glob)
|
27
|
+
# If there are no braces, just return the string as an array
|
28
|
+
return [glob] unless glob =~ /(.*)\{([^\{\}]*?)\}(.*)/
|
29
|
+
|
30
|
+
prefix, contents, suffix = $1, $2, $3
|
31
|
+
|
32
|
+
alternatives = contents.split(',')
|
33
|
+
|
34
|
+
expanded_patterns = alternatives.map do |alternative|
|
35
|
+
"#{prefix}#{alternative}#{suffix}"
|
36
|
+
end
|
37
|
+
|
38
|
+
# Recursively expand for the rest of the pattern
|
39
|
+
return expanded_patterns.flat_map { |pattern| glob_to_re_expand_alternatives(pattern) }
|
40
|
+
end
|
41
|
+
|
26
42
|
def glob_to_re(path, pattern)
|
27
43
|
pattern = remove_ruby_ext(pattern)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
re =
|
37
|
-
|
38
|
-
|
44
|
+
if pattern.start_with?(path)
|
45
|
+
path = ""
|
46
|
+
else
|
47
|
+
path += "/" unless path.end_with?("/")
|
48
|
+
end
|
49
|
+
pattern = path + pattern
|
50
|
+
patterns = glob_to_re_expand_alternatives(pattern)
|
51
|
+
re = patterns.map { |i| Regexp.escape(i) }.join("|").then { |i| "(?:#{i})" }
|
52
|
+
re = re.gsub('\/\*\*\/', '(?:/|/.*?/)')
|
53
|
+
.gsub('\*', '[^/]*?')
|
54
|
+
.gsub('\?', '[^/]')
|
55
|
+
re = '(?:^|/)' + re + "$"
|
56
|
+
# Strip multiple '/'s
|
57
|
+
re = re.gsub(%r{(\\/|/)+}, '/')
|
39
58
|
# Strip the `/./`
|
40
|
-
re = re.gsub(
|
41
|
-
re = re.gsub(
|
59
|
+
re = re.gsub('/\./', '/')
|
60
|
+
re = re.gsub('(?:^|/)\./', '(?:^|/)')
|
42
61
|
Regexp.new(re)
|
43
62
|
end
|
44
63
|
|
45
64
|
# Only load from loaded files
|
46
65
|
def get_matching_files(path, pattern)
|
66
|
+
if pattern.is_a?(Array)
|
67
|
+
return pattern.map { |pat| get_matching_files(path, pat) }.flatten.sort.uniq
|
68
|
+
end
|
47
69
|
`Object.keys(Opal.modules)`.grep(glob_to_re(path, pattern)).sort
|
48
70
|
end
|
49
71
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0.
|
4
|
+
version: 1.1.0.alpha3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Beynon
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-09-
|
13
|
+
date: 2023-09-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: opal
|