rspec-sorbet 1.8.3 → 1.9.1
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 +4 -2
- data/CHANGELOG.md +38 -28
- data/README.md +13 -0
- data/lib/rspec/sorbet/doubles.rb +12 -3
- data/lib/rspec/sorbet/version.rb +1 -1
- data/nix/sources.json +4 -4
- data/nix/sources.nix +21 -1
- 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: c919fffe36f51d10375e595ccb204bc198e25cf8315e266b58ac003e5a3044e3
|
4
|
+
data.tar.gz: e9f7fd2ebc16cbfb02a35386e6e18167e4c2d7135d892818cfef0828bbac3d29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 036dc3f8f4fe03014d3fd841c3db206cb3f4d044238f995f204ea66379763e1dd4f66882fd87571eaf1fa5a473af3b4dd28cdd943d7ff1dfb902b03ef1849b86
|
7
|
+
data.tar.gz: bfaa969a76685774eedbceb4842b977a3bdb39dc48055035a93c85b53cf9a7029b9f6592722307a96d0b03ac2ff51ed0d5b406012469334eaf92c11f3bfd855c
|
data/.github/workflows/ci.yml
CHANGED
@@ -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.
|
43
|
+
SLACK_BOT_TOKEN: "${{ secrets.BELLROY_SLACK_TOKEN }}"
|
42
44
|
with:
|
43
|
-
args: '{\"channel\":\"
|
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
|
+
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
## 1.9.1
|
4
4
|
|
5
|
-
|
5
|
+
- Support `T.nilable(T.class_of(...))` among others (thanks [@deecewan](https://github.com/deecewan))
|
6
6
|
|
7
|
-
|
7
|
+
## 1.9.0
|
8
8
|
|
9
|
-
|
9
|
+
- Allow specification of a custom validation handler (thanks [@bmalinconico](https://github.com/bmalinconico))
|
10
10
|
|
11
|
-
|
11
|
+
## 1.8.3
|
12
12
|
|
13
|
-
|
13
|
+
- Make sorbet a development dependency
|
14
14
|
|
15
|
-
|
15
|
+
## 1.8.2
|
16
16
|
|
17
|
-
|
17
|
+
- Reduce gem size by excluding RBIs from gem build
|
18
18
|
|
19
|
-
|
19
|
+
## 1.8.1
|
20
20
|
|
21
|
-
|
21
|
+
- [BUGFIX] Fix processing T.let type mismatch messages when there are digits in module name
|
22
22
|
|
23
|
-
|
23
|
+
## 1.8.0
|
24
24
|
|
25
|
-
|
25
|
+
- Fixed issues around union types referencing typed enumerables.
|
26
26
|
|
27
|
-
|
27
|
+
## 1.7.0
|
28
28
|
|
29
|
-
|
29
|
+
- Added support `T.class_of`.
|
30
30
|
|
31
|
-
|
31
|
+
## 1.6.0
|
32
32
|
|
33
|
-
|
33
|
+
- Non-verifying double support improved.
|
34
34
|
|
35
|
-
|
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
|
-
|
37
|
+
- Added support for `T.cast`.
|
39
38
|
|
40
|
-
|
39
|
+
## 1.4.0
|
41
40
|
|
42
|
-
|
41
|
+
- Added support for `T.let` referencing `T.nilable` types.
|
43
42
|
|
44
|
-
|
43
|
+
## 1.3.0
|
45
44
|
|
46
|
-
|
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
|
-
|
48
|
+
## 1.2.1
|
49
49
|
|
50
|
-
|
50
|
+
- Fix call check when opts contains :message instead of :pretty_message.
|
51
51
|
|
52
|
-
|
53
|
-
|
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
|
+
```
|
data/lib/rspec/sorbet/doubles.rb
CHANGED
@@ -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)\()
|
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(
|
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
|
-
|
120
|
+
handle_call_validation_error(signature, opts) if should_raise
|
112
121
|
end
|
113
122
|
end
|
114
123
|
end
|
data/lib/rspec/sorbet/version.rb
CHANGED
data/nix/sources.json
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"nixpkgs": {
|
3
|
-
"branch": "nixos-
|
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": "
|
9
|
-
"sha256": "
|
8
|
+
"rev": "1935dd8fdab8e022a9d958419663162fd840014c",
|
9
|
+
"sha256": "1z0nkqpwahlaz362lcdx5qcdvwdzr5a3bdfirjgbf9jg37rsbwl2",
|
10
10
|
"type": "tarball",
|
11
|
-
"url": "https://github.com/NixOS/nixpkgs/archive/
|
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
|
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.
|
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.
|
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.
|