SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Threaded View

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

    Question Trouble with fixtures and unit tests

    Hello,

    While creating an app similar to the "shove it" in the book, I came across an error in chapter 7 unit test (page. 226).

    The console displays 5 errors..all with the same message "FixtureClassNotFound: The class "Tran" was not found". So I removed all code from error testing from one unit tests and left only votes_test.rb in place.

    test_votes.rb
    Code Ruby:
    class VoteTest < ActiveSupport::TestCase
     
     fixtures :votes, :trans
     
      def test_story_association
        assert_equal trans(:first), votes(:first).trans
      end
     
    end

    fixture data for votes.yml
    Code Ruby:
    first:
      id: 1
      trans_id: 1
      created_at: <% Time.now.to_s(:db) %>
    second:
      id: 2
      trans_id: 1
      created_at: <% Time.now.to_s(:db) %>

    fixture data for trans.yml
    Code Ruby:
    first:
      id: 1
      eng: Apply online
      fre: Faites votre demande en ligne
      permalink: apply-online
    another:
      id: 2
      eng: Available in French
      fre: Disponible en fran&#231;ais
      permalink: available-in_french

    The code achieve says:
    Code Ruby:
    assert_equal stories(:first), votes(:first).story

    I believe this is my problem line. is it because their "stories" fixture I name "trans" and the "story" item was also named trans?
    Last edited by jennifert; Jan 25, 2008 at 10:44. Reason: missed typos in explaination


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
  •