Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RubyKoans: broken koan?

Tags:

ruby

Probably a sign of an amateur that I'm wondering if the problem's the koan (rather than me), however, consider this koan

def test_calling_global_methods_without_parentheses
    result = my_global_method 2, 3
    assert_equal __, result
  end

Note, my_global method is

def my_global_method(a,b)
  a + b
end

This is the hint it gives me in the terminal

The answers you seek...
  <"FILL ME IN"> expected but was  <5>.

So I did

  def test_calling_global_methods_without_parentheses
    result = my_global_method 2, 3
    assert_equal 5, result
  end

and I got this error

Users/mm/Sites/koans/about_methods.rb:21:in `eval': (eval):1: syntax error, unexpected tINTEGER, expecting keyword_do or '{' or '(' (SyntaxError)
assert_equal 5, my_global_method 2, 3
                                  ^
    from /Users/mm/Sites/koans/about_methods.rb:21:in `test_sometimes_missing_parentheses_are_ambiguous'
    from /Users/mm/Sites/koans/edgecase.rb:377:in `meditate'
    from /Users/mm/Sites/koans/edgecase.rb:449:in `block in walk'
    from /Users/mm/Sites/koans/edgecase.rb:460:in `block (3 levels) in each_step'
    from /Users/mm/Sites/koans/edgecase.rb:458:in `each'
    from /Users/mm/Sites/koans/edgecase.rb:458:in `block (2 levels) in each_step'
    from /Users/mm/Sites/koans/edgecase.rb:457:in `each'
    from /Users/mm/Sites/koans/edgecase.rb:457:in `each_with_index'
    from /Users/mm/Sites/koans/edgecase.rb:457:in `block in each_step'
    from /Users/mm/Sites/koans/edgecase.rb:455:in `catch'
    from /Users/mm/Sites/koans/edgecase.rb:455:in `each_step'
    from /Users/mm/Sites/koans/edgecase.rb:448:in `walk'
    from /Users/mm/Sites/koans/edgecase.rb:470:in `block in <top (required)>'

Does anyone know the problem or can you tell me how to skip a koan?

like image 841
Leahcim Avatar asked Aug 24 '12 02:08

Leahcim


1 Answers

Oh, I tested this koan. The error is on line 21 if you noticed that, not the "test_calling_global_methods_without_parentheses" method. It's the "test_sometimes_missing_parentheses_are_ambiguous" method goes wrong as it should be. You are expected to correct that method.

def test_calling_global_methods_without_parentheses
  result = my_global_method 2, 3
  assert_equal 5, result           # You're fine with this koan.
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
  # **LOOK HERE~~~ HERE IS THE ERROR YOU SEE** Just correct it.

And if there is any koan you don't know how to deal with, just comment it.

like image 104
halfelf Avatar answered Sep 28 '22 06:09

halfelf