This project is archived and is in readonly mode.
FixtureClassNotFound when using Namespaces in Unit Test
Reported by James M. McLachlan | June 2nd, 2008 @ 11:29 PM
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
- 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.
Comments and changes to this ticket
-
James M. McLachlan June 3rd, 2008 @ 05:43 AM
Please ignore this... it is not a but but a user error ;-)
-
Tarmo Tänav August 23rd, 2008 @ 01:56 PM
- State changed from new to invalid
- Tag set to testcase
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Tags
Referenced by
- 4263 Unit test fail when using non-standard table names This error has been reported in tickets #389 and #307. Th...
- 4263 Unit test fail when using non-standard table names https://rails.lighthouseapp.com/projects/8994/tickets/30...