Forum: Ruby on Rails Beginner needs help

Posted by Peter Hermansson (chewbacca)
on 2009-07-02 14:56
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 by Gavin Morrice (dr_gavin)
on 2009-07-02 19:39
(Received via mailing list)
What version of Rails are you using?



On Jul 2, 1:56 pm, Peter Hermansson <rails-mailing-l...@andreas-s.net>
Posted by Alpha Blue (elricstorm)
on 2009-07-02 20:52
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 by Sijo k g (sijo)
on 2009-07-03 08:54
> 
> class AuthorTest < Test::Unit::Testcase

change the above to

class AuthorTest < ActiveSupport::TestCase
Posted by Sijo k g (sijo)
on 2009-07-03 08:54
> 
> class AuthorTest < Test::Unit::Testcase

change the above to

class AuthorTest < ActiveSupport::TestCase

Sijo
Posted by Peter Hermansson (chewbacca)
on 2009-07-04 20:12
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 by Peter Hermansson (chewbacca)
on 2009-07-04 20:19
Tried the suggestions from Sijo. Worked like a charm. Coool..!

Thanks again everyone!

//Peter
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.