From 3efe58ac1e38cf3f92c82b756bb7232fe4f85463 Mon Sep 17 00:00:00 2001 From: Mike Doel Date: Mon, 24 Feb 2020 10:03:00 -0500 Subject: [PATCH] Resolve #12 - behavior change in ruby 2.7 --- src/about_methods.rb | 10 ++++++---- src/neo.rb | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/about_methods.rb b/src/about_methods.rb index bd6d8b3..7886526 100644 --- a/src/about_methods.rb +++ b/src/about_methods.rb @@ -126,11 +126,13 @@ class AboutMethods < Neo::Koan assert_equal __("a secret"), my_private_method end - def test_calling_private_methods_with_an_explicit_receiver - exception = assert_raise(___(NoMethodError)) do - self.my_private_method + if before_ruby_version("2.7") # https://github.com/edgecase/ruby_koans/issues/12 + def test_calling_private_methods_with_an_explicit_receiver + exception = assert_raise(___(NoMethodError)) do + self.my_private_method + end + assert_match /#{__("method `my_private_method'")}/, exception.message end - assert_match /#{__("method `my_private_method'")}/, exception.message end # ------------------------------------------------------------------ diff --git a/src/neo.rb b/src/neo.rb index 00f95fe..eaccc2e 100644 --- a/src/neo.rb +++ b/src/neo.rb @@ -25,6 +25,10 @@ def in_ruby_version(*versions) yield if versions.any? { |v| ruby_version?(v) } end +def before_ruby_version(version) + Gem::Version.new(RUBY_VERSION) < Gem::Version.new(version) +end + in_ruby_version("1.8") do class KeyError < StandardError end