mirror of
https://github.com/edgecase/ruby_koans.git
synced 2026-04-15 07:23:19 -04:00
Resolve #12 - behavior change in ruby 2.7
This commit is contained in:
@@ -126,12 +126,14 @@ class AboutMethods < Neo::Koan
|
|||||||
assert_equal __("a secret"), my_private_method
|
assert_equal __("a secret"), my_private_method
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if before_ruby_version("2.7") # https://github.com/edgecase/ruby_koans/issues/12
|
||||||
def test_calling_private_methods_with_an_explicit_receiver
|
def test_calling_private_methods_with_an_explicit_receiver
|
||||||
exception = assert_raise(___(NoMethodError)) do
|
exception = assert_raise(___(NoMethodError)) do
|
||||||
self.my_private_method
|
self.my_private_method
|
||||||
end
|
end
|
||||||
assert_match /#{__("method `my_private_method'")}/, exception.message
|
assert_match /#{__("method `my_private_method'")}/, exception.message
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ def in_ruby_version(*versions)
|
|||||||
yield if versions.any? { |v| ruby_version?(v) }
|
yield if versions.any? { |v| ruby_version?(v) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def before_ruby_version(version)
|
||||||
|
Gem::Version.new(RUBY_VERSION) < Gem::Version.new(version)
|
||||||
|
end
|
||||||
|
|
||||||
in_ruby_version("1.8") do
|
in_ruby_version("1.8") do
|
||||||
class KeyError < StandardError
|
class KeyError < StandardError
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user