SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    May 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Chapter 7 page 231 running the full test suite

    I have a problem with the following line from page 228

    assert_select 'ul#vote_history li, count => 2

    This is where my final test of this chapter fails and I'm stumped as to why. The failure message is returns 0 when expecting 2.

    It works fine in the live version of the website and the fixtures file is set up correctly and as far as I can see formatting etc is ok.


    Anyone got any suggestions as to why the test thinks the voting history is empty?

    Running on Mac OS 10.5
    Last edited by PbPhil; May 5, 2008 at 06:47. Reason: spec of platform

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have a syntax error in your assert. There is one ', but you need two. You also need a : before count.

    Code ruby:
    assert_select 'ul#vote_history li', :count => 2

  3. #3
    SitePoint Member
    Join Date
    May 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    Hi Fenir, thanks for the reply, unfortunately when I posted I had typos. in my controller test file the line of code is exactly as you've quoted. Any other suggestions?

    The content of the file is as follows.

    def test_should_show_story_vote_elements
    get :show, ermalink => 'my-shiny-weblog'
    assert_select 'h2 span#vote_score'
    assert_select 'ul#vote_history li', :count => 2
    assert_select 'div#vote_link'
    end

    PbPhil

  4. #4
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What does the HTML source for that page look like? What is your view code? I can't tell what's wrong with just the test

  5. #5
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i know this is a late reply to this thread but i did not see any solution here. i had this problem and did a html check that found a typo in the <!DOCTYPE line that caused all calls to assert_select to fail. so i believe any bad html tag or unclosed tag could cause these so don't look only at the 'failing' tag but make sure all tags are correct.

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    Are you working with book 1? The code from book 2 is
    Code Ruby:
      def test_should_show_story_vote_elements
        get :show, :id => stories(:one)
        assert_select 'h2 span#vote_score'
        assert_select 'ul#vote_history li', :count => 2
        assert_select 'div#vote_form form'
      end
    Does your fixture's yml file have more than 2 entries?
    Code Ruby:
    one:
      name: My shiny weblog 
      link: http://poocs.net/
     
    two:
      name: SitePoint Forums 
      link: http://www.sitepoint.com/forums/


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
  •