Skip to content

Commit 4bcf933

Browse files
committed
Ensure Kernel.raise remains private after patch
Kernel.raise is originally private, but define_method(:raise) creates a method that is public. Use `private :raise` to make the redefined method private to be consistent with default Ruby behavior. Fixes #350.
1 parent 86f8428 commit 4bcf933

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Custom Spring commands that implement `#binstub_prelude` will have that
66
snippet of code inserted into generated binstubs just after Spring is
77
set up. #329 - @merhard
8+
* Change monkey-patched `Kernel.raise` from public to private (to match default Ruby behavior) #351 - @mattbrictson
89

910
## 1.1.3
1011

lib/spring/application.rb

+1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ def shush_backtraces
270270
end
271271
end
272272
end
273+
private :raise
273274
end
274275
end
275276

test/acceptance/app_test.rb

+5
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,9 @@ def binstub_prelude
350350
assert_success %(bin/rails runner 'p ENV["OMG"]'), stdout: "2"
351351
assert_success %(bin/rails runner 'p ENV.key?("FOO")'), stdout: "false"
352352
end
353+
354+
test "Kernel.raise remains private" do
355+
expr = "p Kernel.private_instance_methods.include?(:raise)"
356+
assert_success %(bin/rails runner '#{expr}'), stdout: "true"
357+
end
353358
end

0 commit comments

Comments
 (0)