Permalink
Browse files

Working through methods

  • Loading branch information...
1 parent a3ab744 commit 2ef0b00b629bc7bc9c6b2098534ad71f57b0411a @danishkhan committed Sep 20, 2011
Showing with 13 additions and 13 deletions.
  1. +12 −12 koans/about_methods.rb
  2. +1 −1 koans/about_regular_expressions.rb
View
@@ -7,18 +7,18 @@ def my_global_method(a,b)
class AboutMethods < EdgeCase::Koan
def test_calling_global_methods
- assert_equal __, my_global_method(2,3)
+ assert_equal 5, my_global_method(2,3)
end
def test_calling_global_methods_without_parentheses
result = my_global_method 2, 3
- assert_equal __, result
+ assert_equal 5, result
end
# (NOTE: We are Using eval below because the example code is
# considered to be syntactically invalid).
def test_sometimes_missing_parentheses_are_ambiguous
- eval "assert_equal 5, my_global_method 2, 3" # ENABLE CHECK
+ eval "assert_equal(5, my_global_method (2, 3))" # ENABLE CHECK
#
# Ruby doesn't know if you mean:
#
@@ -33,15 +33,15 @@ def test_sometimes_missing_parentheses_are_ambiguous
# NOTE: wrong number of argument is not a SYNTAX error, but a
# runtime error.
def test_calling_global_methods_with_wrong_number_of_arguments
- exception = assert_raise(___) do
+ exception = assert_raise(ArgumentError) do
my_global_method
end
- assert_match(/__/, exception.message)
+ assert_match("wrong number of arguments (0 for 2)", exception.message)
- exception = assert_raise(___) do
+ exception = assert_raise(ArgumentError) do
my_global_method(1,2,3)
end
- assert_match(/__/, exception.message)
+ assert_match("wrong number of arguments (3 for 2)", exception.message)
end
# ------------------------------------------------------------------
@@ -51,8 +51,8 @@ def method_with_defaults(a, b=:default_value)
end
def test_calling_with_default_values
- assert_equal [1, __], method_with_defaults(1)
- assert_equal [1, __], method_with_defaults(1, 2)
+ assert_equal [1, :default_value], method_with_defaults(1)
+ assert_equal [1, 2], method_with_defaults(1, 2)
end
# ------------------------------------------------------------------
@@ -62,9 +62,9 @@ def method_with_var_args(*args)
end
def test_calling_with_variable_arguments
- assert_equal __, method_with_var_args
- assert_equal __, method_with_var_args(:one)
- assert_equal __, method_with_var_args(:one, :two)
+ assert_equal [], method_with_var_args
+ assert_equal [:one], method_with_var_args(:one)
+ assert_equal [:one, :two], method_with_var_args(:one, :two)
end
# ------------------------------------------------------------------
@@ -154,6 +154,6 @@ def test_sub_is_like_find_and_replace
end
def test_gsub_is_like_find_and_replace_all
- assert_equal __, "one two-three".gsub(/(t\w*)/) { $1[0, 1] }
+ assert_equal "one t-t", "one two-three".gsub(/(t\w*)/) { $1[0, 1] }
end
end

0 comments on commit 2ef0b00

Please sign in to comment.