rspec-sorbet 1.8.3 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d40a0e2d4b22ec8c7a7809fea36e467492bd7c649ac7de5ac3e09130ac7e180
4
- data.tar.gz: a39fe8993182ca260861e2d583e68ce9fb332e9557d376210583f33be7042208
3
+ metadata.gz: c919fffe36f51d10375e595ccb204bc198e25cf8315e266b58ac003e5a3044e3
4
+ data.tar.gz: e9f7fd2ebc16cbfb02a35386e6e18167e4c2d7135d892818cfef0828bbac3d29
5
5
  SHA512:
6
- metadata.gz: daa20d80ec931a565cdec2dbcd25a72c781a319b0760d5896e0470ad35cd789eb90a8d543aebb01e282fa11f512882c1ccff03832ec7865d18d1627974857a45
7
- data.tar.gz: bb6bc7ea8e5f088f73eea5c72498ba4839c3aecc6dc83fb727135d15abdf24cb9ce3454de689fd7f31662e8fc65d0868ad2157c671ff55f23c7aeb5b434583b6
6
+ metadata.gz: 036dc3f8f4fe03014d3fd841c3db206cb3f4d044238f995f204ea66379763e1dd4f66882fd87571eaf1fa5a473af3b4dd28cdd943d7ff1dfb902b03ef1849b86
7
+ data.tar.gz: bfaa969a76685774eedbceb4842b977a3bdb39dc48055035a93c85b53cf9a7029b9f6592722307a96d0b03ac2ff51ed0d5b406012469334eaf92c11f3bfd855c
@@ -1,5 +1,7 @@
1
1
  ---
2
2
  name: Continuous Integration
3
+ env:
4
+ SLACK_CHANNEL_ID: C0317P7C9C2
3
5
  on:
4
6
  push:
5
7
  branches-ignore:
@@ -38,9 +40,9 @@ jobs:
38
40
  || github.ref == 'refs/heads/stable')
39
41
  uses: pullreminders/slack-action@a5a262c896a1cc80dcbae59ba95513e2dfb21439
40
42
  env:
41
- SLACK_BOT_TOKEN: "${{ secrets.SLACK_BOT_TOKEN }}"
43
+ SLACK_BOT_TOKEN: "${{ secrets.BELLROY_SLACK_TOKEN }}"
42
44
  with:
43
- args: '{\"channel\":\"C33574SJJ\",\"text\":\"* ${{ github.repository }} BUILD
45
+ args: '{\"channel\":\"${{ env.SLACK_CHANNEL_ID }}\",\"text\":\"* ${{ github.repository }} BUILD
44
46
  FAILURE*\", \"attachments\": [{ \"fallback\": \"Failure summary\", \"color\":
45
47
  \"#ff0000\", \"fields\": [{\"title\": \"Branch\", \"value\":\"${{ steps.extract_branch.outputs.branch
46
48
  }}\"}, {\"title\": \"Who broke it\", \"value\":\"${{ github.actor }}\"},
data/CHANGELOG.md CHANGED
@@ -1,53 +1,63 @@
1
- 1.8.3
1
+ # Changelog
2
2
 
3
- * Make sorbet a development dependency
3
+ ## 1.9.1
4
4
 
5
- 1.8.2
5
+ - Support `T.nilable(T.class_of(...))` among others (thanks [@deecewan](https://github.com/deecewan))
6
6
 
7
- * Reduce gem size by excluding RBIs from gem build
7
+ ## 1.9.0
8
8
 
9
- 1.8.1
9
+ - Allow specification of a custom validation handler (thanks [@bmalinconico](https://github.com/bmalinconico))
10
10
 
11
- * [BUGFIX] Fix processing T.let type mismatch messages when there are digits in module name
11
+ ## 1.8.3
12
12
 
13
- 1.8.0
13
+ - Make sorbet a development dependency
14
14
 
15
- * Fixed issues around union types referencing typed enumerables.
15
+ ## 1.8.2
16
16
 
17
- 1.7.0
17
+ - Reduce gem size by excluding RBIs from gem build
18
18
 
19
- * Added support `T.class_of`.
19
+ ## 1.8.1
20
20
 
21
- 1.6.0
21
+ - [BUGFIX] Fix processing T.let type mismatch messages when there are digits in module name
22
22
 
23
- * Non-verifying double support improved.
23
+ ## 1.8.0
24
24
 
25
- 1.5.0
25
+ - Fixed issues around union types referencing typed enumerables.
26
26
 
27
- * Added support for `T.cast`.
27
+ ## 1.7.0
28
28
 
29
- 1.4.0
29
+ - Added support `T.class_of`.
30
30
 
31
- * Added support for `T.let` referencing `T.nilable` types.
31
+ ## 1.6.0
32
32
 
33
- 1.3.0
33
+ - Non-verifying double support improved.
34
34
 
35
- * Added ability to allow any kind of double (Class, Instance, Object).
36
- * `RSpec::Sorbet.allow_instance_doubles!` has been renamed to `RSpec::Sorbet.allow_doubles!`, an alias remains for backwards compatibility for the time being.
35
+ ## 1.5.0
37
36
 
38
- 1.2.1
37
+ - Added support for `T.cast`.
39
38
 
40
- * Fix call check when opts contains :message instead of :pretty_message.
39
+ ## 1.4.0
41
40
 
42
- 1.2.0
41
+ - Added support for `T.let` referencing `T.nilable` types.
43
42
 
44
- * Added support for verifying `T::Enumerable` types.
43
+ ## 1.3.0
45
44
 
46
- 1.1.0
45
+ - Added ability to allow any kind of double (Class, Instance, Object).
46
+ - `RSpec::Sorbet.allow_instance_doubles!` has been renamed to `RSpec::Sorbet.allow_doubles!`, an alias remains for backwards compatibility for the time being.
47
47
 
48
- * Add basic `instance_double` verification to help check the type of an instance double.
48
+ ## 1.2.1
49
49
 
50
- 1.0.0
50
+ - Fix call check when opts contains :message instead of :pretty_message.
51
51
 
52
- * Initial release
53
- * Supports just allowing instance doubles for now
52
+ ## 1.2.0
53
+
54
+ - Added support for verifying `T::Enumerable` types.
55
+
56
+ ## 1.1.0
57
+
58
+ - Add basic `instance_double` verification to help check the type of an instance double.
59
+
60
+ ## 1.0.0
61
+
62
+ - Initial release
63
+ - Supports just allowing instance doubles for now
data/README.md CHANGED
@@ -34,3 +34,16 @@ RSpec::Sorbet.allow_doubles!
34
34
  ### `eq` matcher usage with `T::Struct`'s
35
35
 
36
36
  Using the [`eq` matcher](https://www.rubydoc.info/github/rspec/rspec-expectations/RSpec%2FMatchers:eq) to compare [`T::Struct`'s](https://sorbet.org/docs/tstruct) might not behave as you'd expect whereby two separate instances of the same struct class with identical attributes are not `==` out of the box. The standalone [sorbet-struct-comparable](https://github.com/tricycle/sorbet-struct-comparable) gem may be of interest if you are looking for a simple attribute based comparison that will help make the `eq` matcher behave as you expect.
37
+
38
+ ### Specifying a custom validation handler
39
+
40
+ You can customise the handler of Sorbet validation errors if you so desire.
41
+
42
+
43
+ ```ruby
44
+ def handler(signature, opts)
45
+ raise MyCustomException, "The options were #{opts}"
46
+ end
47
+
48
+ T::Configuration.call_validation_error_handler = handler
49
+ ```
@@ -11,6 +11,8 @@ module RSpec
11
11
  inline_type_error_handler(error)
12
12
  end
13
13
 
14
+ @existing_handler = T::Configuration.instance_variable_get(:@call_validation_error_handler)
15
+
14
16
  T::Configuration.call_validation_error_handler = proc do |signature, opts|
15
17
  call_validation_error_handler(signature, opts)
16
18
  end
@@ -21,7 +23,14 @@ module RSpec
21
23
  private
22
24
 
23
25
  INLINE_DOUBLE_REGEX =
24
- /T.(?:let|cast): Expected type (?:T.(?<t_method>any|nilable|class_of)\()?(?<expected_types>[a-zA-Z0-9:: ,]*)(\))?, got (?:type .* with value )?#<(?<double_type>Instance|Class|Object)?Double([\(]|[ ])(?<doubled_type>[a-zA-Z0-9:: ,]*)(\))?/.freeze
26
+ /T.(?:let|cast): Expected type (?:T.(?<t_method>any|nilable|class_of)\()*(?<expected_types>[a-zA-Z0-9:: ,]*)(\))*, got (?:type .* with value )?#<(?<double_type>Instance|Class|Object)?Double([\(]|[ ])(?<doubled_type>[a-zA-Z0-9:: ,]*)(\))?/.freeze
27
+
28
+
29
+ def handle_call_validation_error(signature, opts)
30
+ raise TypeError, opts[:pretty_message] unless @existing_handler
31
+
32
+ @existing_handler.call(signature, opts)
33
+ end
25
34
 
26
35
  def inline_type_error_handler(error)
27
36
  case error
@@ -75,7 +84,7 @@ module RSpec
75
84
  message.match?(TYPED_ARRAY_MESSAGE)
76
85
  end
77
86
 
78
- def call_validation_error_handler(_signature, opts)
87
+ def call_validation_error_handler(signature, opts)
79
88
  should_raise = true
80
89
 
81
90
  message = opts.fetch(:pretty_message, opts.fetch(:message, ''))
@@ -108,7 +117,7 @@ module RSpec
108
117
  end
109
118
  end
110
119
 
111
- raise TypeError, opts[:pretty_message] if should_raise
120
+ handle_call_validation_error(signature, opts) if should_raise
112
121
  end
113
122
  end
114
123
  end
@@ -3,6 +3,6 @@
3
3
 
4
4
  module RSpec
5
5
  module Sorbet
6
- VERSION = '1.8.3'
6
+ VERSION = '1.9.1'
7
7
  end
8
8
  end
data/nix/sources.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "nixpkgs": {
3
- "branch": "nixos-21.05",
3
+ "branch": "nixos-22.05",
4
4
  "description": "Nix packages collection",
5
5
  "homepage": "https://github.com/NixOS/nixpkgs",
6
6
  "owner": "NixOS",
7
7
  "repo": "nixpkgs",
8
- "rev": "e85f0175e3effe9ba191d66c09e8f1b7d6362d5e",
9
- "sha256": "1qr2hmymbzwj8jrz6smcgc04scgwp2v5070x22k4fvh261g1n4zw",
8
+ "rev": "1935dd8fdab8e022a9d958419663162fd840014c",
9
+ "sha256": "1z0nkqpwahlaz362lcdx5qcdvwdzr5a3bdfirjgbf9jg37rsbwl2",
10
10
  "type": "tarball",
11
- "url": "https://github.com/NixOS/nixpkgs/archive/e85f0175e3effe9ba191d66c09e8f1b7d6362d5e.tar.gz",
11
+ "url": "https://github.com/NixOS/nixpkgs/archive/1935dd8fdab8e022a9d958419663162fd840014c.tar.gz",
12
12
  "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13
13
  }
14
14
  }
data/nix/sources.nix CHANGED
@@ -31,8 +31,28 @@ let
31
31
  if spec ? branch then "refs/heads/${spec.branch}" else
32
32
  if spec ? tag then "refs/tags/${spec.tag}" else
33
33
  abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
34
+ submodules = if spec ? submodules then spec.submodules else false;
35
+ submoduleArg =
36
+ let
37
+ nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0;
38
+ emptyArgWithWarning =
39
+ if submodules == true
40
+ then
41
+ builtins.trace
42
+ (
43
+ "The niv input \"${name}\" uses submodules "
44
+ + "but your nix's (${builtins.nixVersion}) builtins.fetchGit "
45
+ + "does not support them"
46
+ )
47
+ {}
48
+ else {};
49
+ in
50
+ if nixSupportsSubmodules
51
+ then { inherit submodules; }
52
+ else emptyArgWithWarning;
34
53
  in
35
- builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
54
+ builtins.fetchGit
55
+ ({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg);
36
56
 
37
57
  fetch_local = spec: spec.path;
38
58
 
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.8.3
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Giles
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.2.16
146
+ rubygems_version: 3.2.26
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: A small gem consisting of helpers for using Sorbet & RSpec together.