SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member jennifert's Avatar
    Join Date
    Oct 2007
    Location
    Canada
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy [SOLVED] Rails Book p231: 1 failure 2 errors in story-controller-test.rb

    Hello,

    I just started this book a day ago and its really great. At the end of chapter 7, when I tried to run the final "rake test" , I received 1 failure and 2 errors. Rake test:unites runs smoothly - no errors.

    I double checked my code in the book to make sure it matched the book and I still have errors. I looked in the code achieve and tried pasting that code in where the error suggested and still no luck.

    Is anyone having the same trouble?

    The controller code is below (story_controller_test.rb).

    Code Ruby:
    def test_should_show_story
        get :show, :permalink => 'my-shiny-weblog'
        assert_response :success
        assert_template 'show'
        assert_equal stories(:another), assigns(:story)
      end
     
      def test_should_show_story_vote_elements
        get :show, :permalink => 'my-shiny-weblog'
        assert_select 'h2 span#vote_score'
        assert_select 'ul#vote_history li', :count => 2
        assert_select 'div#vote_link'
      end
     
      def test_should_accept_vote
        assert stories(:another).votes.empty?
        post :vote, :id => 2
        assert ! assigns(:story).reload.votes.empty?
      end
     
      def test_should_render_rjs_after_vote_with_ajax
        xml_http_request :post, :vote, :id => 2
        assert_response :success
        assert_template 'vote'
      end
     
      def test_should_redirect_after_vote_with_get
        get :vote, :id => 2
        assert_redirected_to :action => 'show',
          :permalink => 'sitepoint-forums'
      end

    When I compared my _vote.rhtml file to the code achieve it was the same. The application works as expected when running webBrick. Any suggestions? Did I miss something? Should I attach other files? I tried searching the form but it seemed like no one had the same errors as me.
    Attached Files Attached Files
    Last edited by jennifert; Nov 1, 2007 at 05:58. Reason: Solved problem.

  2. #2
    SitePoint Member jennifert's Avatar
    Join Date
    Oct 2007
    Location
    Canada
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow! I solved it. First I downloaded the newest ruby version (1.60 rc 2) and reinstalled rails. I noticed that I did not fix the migration file with the extra end. I ran the test again and it seemed to be fine. I noticed it might have been a migration when the created_at field in db was empty. It works well now.

  3. #3
    SitePoint Member
    Join Date
    Nov 2007
    Location
    Joliet, IL
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Which migration file?

    I appear to have the same error.

    You mentioned a migration that has an extra end? Which one. I didn't notice a problem on a quick scan.
    Jim Maher

  4. #4
    SitePoint Member jennifert's Avatar
    Join Date
    Oct 2007
    Location
    Canada
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jdmaher View Post
    You mentioned a migration that has an extra end? Which one. I didn't notice a problem on a quick scan.

    On page 123 when you are creating the migration 002_create_votes.rb it has:

    Code Ruby:
    class CreateStories < ActiveRecord::Migration
      def self.up
        create_table :stories do |t|
          # t.column :name, :string
        end
      end
      def self.down
        drop_table :stories
    [B]    end[/B]
      end
    end

    it should read:

    Code Ruby:
    class CreateStories < ActiveRecord::Migration
      def self.up
        create_table :stories do |t|
          # t.column :name, :string
        end
      end
      def self.down
        drop_table :stories
      end
    end

    I found that at the following page: http://www.sitepoint.com/books/rails1/errata.php it lists all the typos and what not. It is probably the migration if you have an empty table column when others are filled.
    Last edited by jennifert; Nov 16, 2007 at 06:43. Reason: indicated wrong page

  5. #5
    SitePoint Member
    Join Date
    Nov 2007
    Location
    Joliet, IL
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    That's not the problem

    Jennifer,

    Thanks for the migration file reference.

    However, I must have downloaded the code archive AFTER that correction was made. My migration file 002_create_votes.rb does NOT have the extraneous 'end' statement.

    In my case, I'm running under Windows with what I believe to be the latest Ruby version 1.8.6 (i386-mswin32). Yet I still have the problem.

    Any other thoughts?


    Thanks,
    Jim Maher

  6. #6
    SitePoint Member jennifert's Avatar
    Join Date
    Oct 2007
    Location
    Canada
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: migration

    Hello,

    Did you try coping the source from the code achieve? for the files?

    I have done that myself and finally got it working. What is your error message?


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
  •