From 4bcf93304e6010cf08f8ba94ee3d1d4a93e12294 Mon Sep 17 00:00:00 2001 From: Matt Brictson Date: Tue, 9 Sep 2014 18:03:33 -0700 Subject: [PATCH] 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. --- CHANGELOG.md | 1 + lib/spring/application.rb | 1 + test/acceptance/app_test.rb | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b89384e1..31d1455d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Custom Spring commands that implement `#binstub_prelude` will have that snippet of code inserted into generated binstubs just after Spring is set up. #329 - @merhard +* Change monkey-patched `Kernel.raise` from public to private (to match default Ruby behavior) #351 - @mattbrictson ## 1.1.3 diff --git a/lib/spring/application.rb b/lib/spring/application.rb index 6397d1c9..90d39dfc 100644 --- a/lib/spring/application.rb +++ b/lib/spring/application.rb @@ -270,6 +270,7 @@ def shush_backtraces end end end + private :raise end end diff --git a/test/acceptance/app_test.rb b/test/acceptance/app_test.rb index 37ad5960..90896b06 100644 --- a/test/acceptance/app_test.rb +++ b/test/acceptance/app_test.rb @@ -350,4 +350,9 @@ def binstub_prelude assert_success %(bin/rails runner 'p ENV["OMG"]'), stdout: "2" assert_success %(bin/rails runner 'p ENV.key?("FOO")'), stdout: "false" end + + test "Kernel.raise remains private" do + expr = "p Kernel.private_instance_methods.include?(:raise)" + assert_success %(bin/rails runner '#{expr}'), stdout: "true" + end end