SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Chapter 8 - test_helper causing monster crash

    Page 295 adding test/test_helper.rb causes nothing to work

    Exception is:
    NameError (uninitialized constant Test):
    app/helpers/test_helper.rb:4:in `<top (required)>'
    app/controllers/application_controller.rb:2:in `<class:ApplicationController>'
    app/controllers/application_controller.rb:1:in `<top (required)>'
    app/controllers/stories_controller.rb:1:in `<top (required)>'

    My test_helper looks like:
    Code Ruby:
    ENV["RAILS_ENV"] = "test"
    require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
    require 'test_help'
     
    class Test::Unit::TestCase
      self.use_transactional_fixtures = true
      self.use_instantiated_fixtures  = false
      fixtures :all
     
      def get_with_user(action, parameters = nil, session = nil, flash = nil)
        get action, parameters, :user_id => users(:patrick).id
      end
      def post_with_user(action, parameters = nil, session = nil, flash = nil)
        post action, parameters, :user_id => users(:patrick).id
      end
    end

    I have modified the line so it finds environment but that just causes another error.

    Thanks for any help anyone might have. I hate feeling so helpless!

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    Hi bovine_duck, welcome to the forums

    From the best I can tell, that code looks exactly like what I have that works.

    The book was written for Ruby 1.8.6 and Rails 2.0.2
    (Although I have Ruby 1.8.6 and Rails 2.1.0 and as I said, that code works for me)


    There have been a lot of changes since the book was written, are you running 1.8.6 and 2.0.2 ??

  3. #3
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I am using Ruby 1.9.x and Rails 2.2.3 I will attempt to downgrade ruby and try again. Thanks for your help


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •