rspec-sorbet 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/lib/rspec/sorbet/doubles.rb +18 -8
- data/lib/rspec/sorbet/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0da50be79de773b41e6a280974930066264c7b6af915864b216fc3b36af4cf2c
|
4
|
+
data.tar.gz: e32d7be4d906e8657ee043d2eef8cd4c10d70311d32ad1dd4c546668322781a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3432fcd29e907420ba0fe2b508a4485d4452cbbda934d6379ade55944684afaea72233b33c4b897e15d14106ffb7709cd69f10075527a884d5abc48491d846c6
|
7
|
+
data.tar.gz: 82358706e873ce32c112db84c6acf88b63cec554899d63621891bcbf8537cde2124a040b6dfe465dc79a650b05e7375b26e279680075c32f025bec76313796a3
|
data/.github/workflows/ci.yml
CHANGED
@@ -18,7 +18,7 @@ jobs:
|
|
18
18
|
- name: Install Linux dependencies
|
19
19
|
run: sudo apt-get update -qq && sudo apt-get install -y libsqlite3-dev
|
20
20
|
- name: Set up Ruby
|
21
|
-
uses: actions/setup-ruby@v1
|
21
|
+
uses: actions/setup-ruby@v1
|
22
22
|
with:
|
23
23
|
ruby-version: 2.6.6
|
24
24
|
- name: Cache gems
|
data/CHANGELOG.md
CHANGED
data/lib/rspec/sorbet/doubles.rb
CHANGED
@@ -21,7 +21,7 @@ module RSpec
|
|
21
21
|
private
|
22
22
|
|
23
23
|
INLINE_DOUBLE_REGEX =
|
24
|
-
/T.(let|cast): Expected type (T.(any|nilable)\()?(?<
|
24
|
+
/T.(?:let|cast): Expected type (?:T.(?<t_method>any|nilable|class_of)\()?(?<expected_types>[a-zA-Z:: ,]*)(\))?, got (?:type .* with value )?#<(?<double_type>Instance|Class|Object)?Double([\(]|[ ])(?<doubled_type>[a-zA-Z:: ,]*)(\))?/.freeze
|
25
25
|
|
26
26
|
def inline_type_error_handler(error)
|
27
27
|
case error
|
@@ -29,18 +29,26 @@ module RSpec
|
|
29
29
|
message = error.message
|
30
30
|
return if unable_to_check_type_for_message?(message)
|
31
31
|
|
32
|
-
|
33
|
-
return unless doubled_module_string
|
32
|
+
raise error unless (match = message.match(INLINE_DOUBLE_REGEX))
|
34
33
|
|
35
|
-
|
34
|
+
t_method = match[:t_method]
|
35
|
+
expected_types = match[:expected_types].split(',').map do |expected_type|
|
36
|
+
Object.const_get(expected_type.strip)
|
37
|
+
end
|
38
|
+
double_type = match[:double_type]
|
39
|
+
doubled_type = Object.const_get(match[:doubled_type])
|
40
|
+
|
41
|
+
if double_type == 'Class'
|
42
|
+
raise error if t_method != 'class_of'
|
36
43
|
|
37
|
-
|
38
|
-
|
44
|
+
valid = expected_types.any? do |expected_type|
|
45
|
+
doubled_type <= expected_type
|
46
|
+
end
|
47
|
+
raise error unless valid
|
39
48
|
end
|
40
|
-
doubled_module = Object.const_get(doubled_module_string)
|
41
49
|
|
42
50
|
valid = expected_types.any? do |expected_type|
|
43
|
-
|
51
|
+
doubled_type.ancestors.include?(expected_type)
|
44
52
|
end
|
45
53
|
raise error unless valid
|
46
54
|
else
|
@@ -83,6 +91,8 @@ module RSpec
|
|
83
91
|
end
|
84
92
|
|
85
93
|
case typing
|
94
|
+
when T::Types::ClassOf
|
95
|
+
should_raise = !(target <= typing.type)
|
86
96
|
when T::Types::Simple
|
87
97
|
should_raise = !target.ancestors.include?(typing.raw_type)
|
88
98
|
when T::Types::Union
|
data/lib/rspec/sorbet/version.rb
CHANGED