sus 0.26.0 → 0.27.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: 731c63c1341c591c641c0c9a8d05d387ca0258adef3aeb002b4509e5d6672e69
4
- data.tar.gz: 4f0b0fd74e104f5fb82f48df8e7c8011dea872b07f5ccd7b314908b401f68597
3
+ metadata.gz: 15dd552861dc2a448ac4717e95092d21b76e9f09e50492269a898c8d7db464e3
4
+ data.tar.gz: 47e84419dadb77bfa29e82b8383f7ae90b18d8a170cdd4136e2ef75f3f5afb38
5
5
  SHA512:
6
- metadata.gz: 0fae67b800bfc9f5c05581c2e3a4e3c45d5fe13f9403acc12c771441a2f333d775e8305c20449d14669bce69cdc0b234325e9adacb33ea9847c117ba750fe22c
7
- data.tar.gz: edb022b7eef312a19c03452fee531ace489038d9320b6e68a13146a482136fb70f00273f3f43206d8b5f78e752c52ec46645eeab407ed815169290189a28230b
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
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.26.0"
7
+ VERSION = "0.27.0"
8
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file