sorbet-runtime 0.6.13274 → 0.6.13275
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 +4 -4
- data/lib/types/compatibility_patches.rb +42 -0
- 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: 717e7a8e84d644a5afb7d14417ccaed42da2a6ef811c9dd3035feeee101c11fd
|
|
4
|
+
data.tar.gz: 16f5fb77e086aa31acbf1d1b77f968ddd05511fdec586df1d24e26dfc61c1c2c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d16177658b783935acd782292692cc60f574fa472646eb0d88d78d90e4367352a48232969f7ce907d2e5b08fbbbe1077196c36dba6aa46da0854fd914f556fdd
|
|
7
|
+
data.tar.gz: f3fb7b569a24bc63aaebb77b0ec9c9b920a6b246fd3bdaf8c1b98a24895529e51305cc6a383acce813696d4b0032a0bec9e4e7762af9aa9d91ad755d8d369a42
|
|
@@ -51,6 +51,48 @@ if defined? ::RSpec::Mocks
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
# Allow using `sig {...}` on top of a `let`-defined method in an RSpec example group
|
|
55
|
+
if defined? ::RSpec::Core::MemoizedHelpers::ClassMethods
|
|
56
|
+
module T
|
|
57
|
+
module CompatibilityPatches
|
|
58
|
+
module RSpecCompatibility
|
|
59
|
+
module MemoizedHelpers
|
|
60
|
+
# `let!`, `subject`, and `subject!` are implemented by dispatching to
|
|
61
|
+
# `let`, so this should cover those methods too.
|
|
62
|
+
def let(name, &block)
|
|
63
|
+
# TODO(jez) This will need to use consume!
|
|
64
|
+
|
|
65
|
+
current_declaration = T::Private::DeclState.current.active_declaration
|
|
66
|
+
return super unless current_declaration
|
|
67
|
+
T::Private::DeclState.current.reset!
|
|
68
|
+
|
|
69
|
+
# Allow the `let`-defined methods to be defined
|
|
70
|
+
super
|
|
71
|
+
|
|
72
|
+
# Stash the sig and re-define the method RSpec just defined. This
|
|
73
|
+
# ensures that the `sig` attaches to the outer method, not any
|
|
74
|
+
# method inside the LetDefinitions module.
|
|
75
|
+
#
|
|
76
|
+
# Unfortunately, this means that the runtime checks are not
|
|
77
|
+
# memoized (but they never were).
|
|
78
|
+
#
|
|
79
|
+
# (An alternative approach of pretending that the `sig` was actually
|
|
80
|
+
# written inside the `LetDefinitions` module didn't work, because
|
|
81
|
+
# things like `sig {override}` broke: the `LetDefinitions` module
|
|
82
|
+
# has no ancestors and thus does not override anything)
|
|
83
|
+
|
|
84
|
+
method = instance_method(name)
|
|
85
|
+
remove_method(name)
|
|
86
|
+
T::Private::DeclState.current.active_declaration = current_declaration
|
|
87
|
+
define_method(name, method)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
::RSpec::Core::MemoizedHelpers::ClassMethods.prepend(MemoizedHelpers)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
54
96
|
# Work around for sorbet-runtime wrapped methods.
|
|
55
97
|
#
|
|
56
98
|
# When a sig is defined, sorbet-runtime will replace the sigged method
|