-require 'edgecase'
+require File.expand_path(File.dirname(__FILE__) + '/edgecase')
def my_global_method(a,b)
a + b
end
-
+
class AboutMethods < EdgeCase::Koan
def test_calling_global_methods
assert_equal __, my_global_method(2,3)
end
- def test_calling_global_methods_without_parenthesis
+ def test_calling_global_methods_without_parentheses
result = my_global_method 2, 3
assert_equal __, result
end
# (NOTE: We are Using eval below because the example code is
# considered to be syntactically invalid).
- def test_sometimes_missing_parenthesis_are_ambiguous
+ def test_sometimes_missing_parentheses_are_ambiguous
eval "assert_equal 5, my_global_method 2, 3" # ENABLE CHECK
#
# Ruby doesn't know if you mean:
# Rewrite the eval string to continue.
#
end
-
+
# NOTE: wrong number of argument is not a SYNTAX error, but a
# runtime error.
def test_calling_global_methods_with_wrong_number_of_arguments
# ------------------------------------------------------------------
- def my_same_class_method(a, b)
+ def my_method_in_the_same_class(a, b)
a * b
end
def test_calling_methods_in_same_class
- assert_equal __, my_same_class_method(3,4)
+ assert_equal __, my_method_in_the_same_class(3,4)
end
def test_calling_methods_in_same_class_with_explicit_receiver
- assert_equal __, self.my_same_class_method(3,4)
+ assert_equal __, self.my_method_in_the_same_class(3,4)
end
# ------------------------------------------------------------------
"tail"
end
end
-
+
def test_calling_methods_in_other_objects_require_explicit_receiver
rover = Dog.new
assert_equal __, rover.name