Is there a supplementary guide/answer key for ruby koans?

Posted by corroded on Stack Overflow See other posts from Stack Overflow or by corroded
Published on 2010-08-25T05:37:54Z Indexed on 2011/11/30 17:50 UTC
Read the original article Hit count: 287

Filed under:
|

I have recently tried sharpening my rails skills with this tool:

http://github.com/edgecase/ruby_koans

but I am having trouble passing some tests. Also I am not sure if I'm doing some things correctly since the objective is just to pass the test, there are a lot of ways in passing it and I may be doing something that isn't up to standards.

Is there a way to confirm if I'm doing things right?

a specific example:

in about_nil,

 def test_nil_is_an_object
   assert_equal __, nil.is_a?(Object), "Unlike NULL in other languages"
 end

so is it telling me to check if that second clause is equal to an object(so i can say nil is an object) or just put assert_equal true, nil.is_a?(Object) because the statement is true?

and the next test:

def test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil
  # What happens when you call a method that doesn't exist.  The
  # following begin/rescue/end code block captures the exception and
  # make some assertions about it.
  begin
    nil.some_method_nil_doesnt_know_about
  rescue Exception => ex
    # What exception has been caught?
    assert_equal __, ex.class

    # What message was attached to the exception?
    # (HINT: replace __ with part of the error message.)
    assert_match(/__/, ex.message)
  end
end

Im guessing I should put a "No method error" string in the assert_match, but what about the assert_equal?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ruby-koans