मैं हाल ही में इस उपकरण के साथ मेरी रेल कौशल sharpening की कोशिश की है:क्या रूबी कोन्स के लिए एक पूरक गाइड/उत्तर कुंजी है?
http://github.com/edgecase/ruby_koans
लेकिन मैं मुसीबत कुछ परीक्षण गुजर कर रहा हूँ। इसके अलावा मुझे यकीन नहीं है कि क्या मैं कुछ चीजें सही तरीके से कर रहा हूं क्योंकि उद्देश्य केवल परीक्षा उत्तीर्ण करने के लिए है, इसे पास करने में कई तरीके हैं और मैं कुछ ऐसा कर रहा हूं जो मानकों तक नहीं है।
क्या यह पुष्टि करने का कोई तरीका है कि मैं सही काम कर रहा हूं या नहीं?
एक विशिष्ट उदाहरण:
about_nil में,
def test_nil_is_an_object
assert_equal __, nil.is_a?(Object), "Unlike NULL in other languages"
end
तो
यह है कि दूसरे खंड एक वस्तु (तो मैं कह सकता हूँ शून्य एक वस्तु है) या बस के बराबर है की जाँच करने के कह रहा है assert_equal true, nil.is_a?(Object)
डालें क्योंकि कथन सत्य है?
और अगले टेस्ट:
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 अनुमान मैं assert_match में एक "कोई विधि त्रुटि" स्ट्रिंग, लेकिन क्या assert_equal के बारे में रखना चाहिए?
दिलचस्प, koans के बारे में पता नहीं था, उन्हें कोशिश होगा। शायद मदद मांगना, या उन चीजों पर सलाह की तलाश करना जो आपको नहीं लगता है, लेकिन अधिक विशिष्ट होने के कारण, आपको बेहतर जवाब मिलेंगे – Chubas