Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Foundations Testing MiniTest

I'm getting an uninitialized constant/name error while running ruby 1-test.rb

here is my code ....it worked fine when it was testing addition but now that I am testing the array it is giving me errors. Can anyone tell me what I have done wrong?


require 'minitest/autorun'

class MyTest < MiniTest::Unit::Testcase def test_that_addition_works assert_equal 4, 2+2 end

def test_that_my_array_has_a_value my_array = %w(dog cat frog) assert my_array.include?('frog') end end

Error message:

MadelynsMiniMac-2:~ madelynpapineau$ ruby 1-test.rb 1-test.rb:3:in `<main>': uninitialized constant MiniTest::Unit::Testcase (NameError) MadelynsMiniMac-2:~ madelynpapineau$

Ralph Johnson
Ralph Johnson
10,408 Points

Glad I could actually help. This stuff can be really frustrating, and finding answers even more so. Nice to feel useful for once. :)

1 Answer

Ralph Johnson
Ralph Johnson
10,408 Points

If you didn't retype the class definition between the first and second tests, I'm not sure why the first one passed. But I think the MiniTest parent module is returning an uninitialized constant error (assuming that what's printed above is cut-and-pasted) because the C in the two-word CamelCase "::TestCase" isn't capitalized. As far as Ruby's concerned, TestCase and Testcase are as different as IceCream and HeffalumpNostrils. Kinda finicky, I know...:)

Thank You that worked!