Created
October 24, 2013 03:09
-
-
Save JonathonMA/7130682 to your computer and use it in GitHub Desktop.
Why wait for ruby 2.1?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'minitest', '>= 5' | |
require 'minitest/autorun' | |
module Kernel | |
def private_def method_name, &block | |
define_method method_name, &block | |
private method_name | |
end | |
end | |
class PrivateDefTest < MiniTest::Test | |
class Foo | |
private_def :foo do | |
:foo | |
end | |
end | |
def test_Foo_foo_exists | |
assert_equal :foo, Foo.new.send(:foo) | |
end | |
def test_Foo_foo_is_private | |
assert_raises NoMethodError do | |
Foo.new.foo | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment