Hi, I am trying to follow the book ''Beginning Ruby on Rails e-commerce'' examples. When I come to unit testing I get an error message: C:/Ruby/bin/ruby.exe -I"lib;test" "C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/author_test.rb" "test/unit/helpers/about_helper_test.rb" C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in `load_missing_constant'': uninitialized constant Test::Unit::Testcase (NameError) My test/unit/author_test.rb looks like this: require File.dirname(__FILE__) + '' /../test_helper'' class AuthorTest < Test::Unit::Testcase fixtures :authors def test_name author=Author.create(:first_name => ''Joel'', :last_name => ''Spolsky'') assert_equal ''Joel Spolsky'', author.name end end Why do I get the error message ? -- Posted via http://www.ruby-forum.com/.
What version of Rails are you using? On Jul 2, 1:56 pm, Peter Hermansson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, I am trying to follow the book ''Beginning Ruby on Rails e-commerce'' > examples. > > When I come to unit testing I get an error message: > C:/Ruby/bin/ruby.exe -I"lib;test" > "C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" > "test/unit/author_test.rb" "test/unit/helpers/about_helper_test.rb" > C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in > `load_missing_constant'': uninitialized constant Test::Unit::Testcase > (NameError) > > My test/unit/author_test.rb looks like this: > > require File.dirname(__FILE__) + '' /../test_helper'' > > class AuthorTest < Test::Unit::Testcase > fixtures :authors > def test_name > author=Author.create(:first_name => ''Joel'', > :last_name => ''Spolsky'') > > assert_equal ''Joel Spolsky'', author.name > end > end > > Why do I get the error message ? > -- > Posted viahttp://www.ruby-forum.com/.
He''s using 2.3.2 from the errors.. So, did you create everything from scratch? Or, did you read a section in the book that said go to x website and download the incomplete or complete samples and you are working from those? If you are working from samples, the samples are probably not using the same RoR version you are. That''s the very first question I''d answer. Most books and source files that go with those books are out of date already. -- Posted via http://www.ruby-forum.com/.
> > class AuthorTest < Test::Unit::Testcasechange the above to class AuthorTest < ActiveSupport::TestCase -- Posted via http://www.ruby-forum.com/.
> > class AuthorTest < Test::Unit::Testcasechange the above to class AuthorTest < ActiveSupport::TestCase Sijo -- Posted via http://www.ruby-forum.com/.
Thanks guys, I have been out of town a few days, thats why this late reply. I am using Rails 2.3.2 The book was published in 2006 so I guess the examples can be out of date. I ran into that when the book mentioned start-form-tag and end-form-tag... Took me a while to figure that out. Anyways, I am buildng all the examples from scratch, and so far I have not downloaded anything, so it could be a typo, even though I have checked the code several times... Tha last two suggestions I haven''t tried yet, but I will. cheers, -- Posted via http://www.ruby-forum.com/.