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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5092ba833b101ffc072738e4f4b77b96295de38819b2b02b07bd44c0c54ccb4a
4
- data.tar.gz: 6fd5067e42d0c170d64a2b6662be3498d47376fea4a008f4f279a3852d4594be
3
+ metadata.gz: 0da50be79de773b41e6a280974930066264c7b6af915864b216fc3b36af4cf2c
4
+ data.tar.gz: e32d7be4d906e8657ee043d2eef8cd4c10d70311d32ad1dd4c546668322781a3
5
5
  SHA512:
6
- metadata.gz: f600a8e78fc5e24db9d09a582368c56b90329678795f1b95b1c0ebd933c9738c4ac2e9e01d32bc7945d2863a19e50d28cc5a3dc5d12ba3a9d3faf0551a39f8c5
7
- data.tar.gz: 2af95a77e7b086904bff0dfd4c8fa2840134df66e5a172092096de9e0ec44ad79c8ec79b078aa5fc51187f7aa513510b6243e4421bf03e6fc19d5edaa8e4f30b
6
+ metadata.gz: 3432fcd29e907420ba0fe2b508a4485d4452cbbda934d6379ade55944684afaea72233b33c4b897e15d14106ffb7709cd69f10075527a884d5abc48491d846c6
7
+ data.tar.gz: 82358706e873ce32c112db84c6acf88b63cec554899d63621891bcbf8537cde2124a040b6dfe465dc79a650b05e7375b26e279680075c32f025bec76313796a3
@@ -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.1.1
21
+ uses: actions/setup-ruby@v1
22
22
  with:
23
23
  ruby-version: 2.6.6
24
24
  - name: Cache gems
@@ -1,3 +1,7 @@
1
+ 1.7.0
2
+
3
+ * Added support `T.class_of`.
4
+
1
5
  1.6.0
2
6
 
3
7
  * Non-verifying double support improved.
@@ -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)\()?(?<expected_classes>[a-zA-Z:: ,]*)(\))?, got type (.*) with value #<(Instance|Class|Object)?Double([\(]|[ ])(?<doubled_module>[a-zA-Z:: ,]*)(\))?/.freeze
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
- _, expected_types_string, doubled_module_string = (message.match(INLINE_DOUBLE_REGEX) || [])[0..2]
33
- return unless doubled_module_string
32
+ raise error unless (match = message.match(INLINE_DOUBLE_REGEX))
34
33
 
35
- raise error unless expected_types_string && doubled_module_string
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
- expected_types = expected_types_string.split(',').map do |expected_type_string|
38
- Object.const_get(expected_type_string.strip)
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
- doubled_module.ancestors.include?(expected_type)
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
@@ -3,6 +3,6 @@
3
3
 
4
4
  module RSpec
5
5
  module Sorbet
6
- VERSION = '1.6.0'
6
+ VERSION = '1.7.0'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sorbet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Giles