Forum: Ruby on Rails Putting fixtures into subdirectories

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A05b2bc384b56021f4ac9b71a03b887b?d=identicon&s=25 Todd Huss (thuss)
on 2006-05-23 02:37
I want to organize my fixtures just like the namespace of my models. So
for example if I have a model Company::Employee I'd like the fixture to
be in fixtures/company/employees.yml.

However, I can't figure out how to specify the path of the fixture file.
If I do:

fixtures :employees

in my unit test it can't find the fixture file. Any suggestions?

Thanks,
Todd
http://gabrito.com
0a28989c4bf20e226cc36267702bd796?d=identicon&s=25 Tim Glenn (Guest)
on 2007-04-20 20:57
Try this:

require File.dirname(__FILE__) + '/../../test_helper'

class Messaging::BulletinTest < Test::Unit::TestCase

  Test::Unit::TestCase.fixture_path= File.dirname(__FILE__)
+"/../../fixtures/messaging"

  fixtures :messaging_bulletins

  set_fixture_class :messaging_bulletins => Messaging::Bulletin

   def test_database
    assert_equal messaging_bulletins(:one).id, 1
    end
end
This topic is locked and can not be replied to.