sus 0.26.0 → 0.27.0
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
- checksums.yaml.gz.sig +0 -0
- data/lib/sus/mock.rb +17 -0
- data/lib/sus/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15dd552861dc2a448ac4717e95092d21b76e9f09e50492269a898c8d7db464e3
|
4
|
+
data.tar.gz: 47e84419dadb77bfa29e82b8383f7ae90b18d8a170cdd4136e2ef75f3f5afb38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa482cd7ea24f6b6f5b32f59582403171ecf8695f490edc0a1149366566d05424e8199d813f4ff0cbd5ef6b2abd327013f35b112a84c905bba62ded1bee9e478
|
7
|
+
data.tar.gz: 3bf33b5fdcf42584ba46e360b9a83367b2f09ebc15a6b23497f2485fcd105ea5c354e10e4a15b084624aff8af2a506305771e9edd4754cc7b7e700a99fd50683
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/sus/mock.rb
CHANGED
@@ -62,6 +62,23 @@ module Sus
|
|
62
62
|
|
63
63
|
return self
|
64
64
|
end
|
65
|
+
|
66
|
+
# Wrap a method, yielding the original method as the first argument, so you can call it from within the hook.
|
67
|
+
def wrap(method, &hook)
|
68
|
+
execution_context = Thread.current
|
69
|
+
|
70
|
+
@interceptor.define_method(method) do |*arguments, **options, &block|
|
71
|
+
if execution_context == Thread.current
|
72
|
+
original = proc do |*arguments, **options|
|
73
|
+
super(*arguments, **options)
|
74
|
+
end
|
75
|
+
|
76
|
+
hook.call(original, *arguments, **options, &block)
|
77
|
+
else
|
78
|
+
super(*arguments, **options, &block)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
65
82
|
end
|
66
83
|
|
67
84
|
module Mocks
|
data/lib/sus/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|