Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

FixtureClassNotFound when using Namespaces in Unit Test

#307

If have namespaced model classes, Party::Base and Party::Address, with their corresponding Unit test in the test/party directory the unit for the first starts failing once the second is added with a "FixtureClassNotFound: No class attached to find" error even if set_fixture_class is explicitly denoted.

When I remove the second unit test from the directory, everything runs fine once again.

My model classes are as follows:

class Party::Base < ActiveRecord::Base

set_table_name :parties

has_many :addresses,

:foreign_key => 'party_id'

end

class Party::Address < ActiveRecord::Base

belongs_to :party,

:class_name => "Party::Base",

:foreign_key => 'party_id'

end

A simple unit test for Party::Base works fine if no other test is present.

require 'test_helper'

class Party::BaseTest < ActiveSupport::TestCase

fixtures :parties

set_fixture_class :parties => Party::Base

  1. Replace this with your real tests.

def test_james_in_fixture

assert(parties(:one).name == "James McLachlan")

end

end

once I add Party::AddressTest if gives me the error:

test_james_in_fixture(Party::PartyTest):

FixtureClassNotFound: No class attached to find.

Reported by James M. McLachlan · June 2nd, 2008 @ 11:29 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. James M. McLachlan
    James M. McLachlan

    Please ignore this... it is not a but but a user error ;-)

    June 3rd, 2008 @ 05:43 AM

  2. Tarmo Tänav
    Tarmo Tänav
    • State changed from new to invalid
    • Tag set to testcase

    August 23rd, 2008 @ 01:56 PM