Forum: Ruby on Rails Fixtures 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.
6b6f6f03a79ad699bd8c9a64931b4d4e?d=identicon&s=25 torreborre (Guest)
on 2006-01-24 09:38
(Received via mailing list)
Hi,



[This is a repost, I canÂ?t find where went my previous post,Â?]



I wanted to create subdirectories in the fixtures directory in order to
be
able to manage many different initial states for my system (or to sort
fixtures / corresponding model subpackages).



I came up with the idea of writing:



Test::Unit::TestCase.fixture_path = RAILS_ROOT +
"/test/fixtures/selling"

fixtures :customers, :partners



Test::Unit::TestCase.fixture_path = RAILS_ROOT +
"/test/fixtures/catalog"

fixtures :products, :parts



However, it looks like the test_help.rb file (in <rails>/lib) which is
written as:



Test::Unit::TestCase.fixture_path = RAILS_ROOT + "/test/fixtures/ "



def create_fixtures(*table_names)

  Fixtures.create_fixtures(RAILS_ROOT + "/test/fixtures", table_names)

end



could be rewritten as :



Test::Unit::TestCase.fixture_path = RAILS_ROOT + "/test/fixtures/ "



def create_fixtures(*table_names)

  Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path,
table_names)

end



in order to do the trick (and to respect the DRY principle,Â?).



What do you think?



Eric TORREBORRE

LTG Product Manager



LEIRIOS

TEMIS

18, rue Alain Savary

25000 Besançon

Phone: +33 (0)3 81 25 53 62

Fax: +33 (0)3 81 50 64 70

 <http://www.leirios.com/> www.leirios.com

----------------------------------------------------------------------

CONFIDENTIALITY NOTICE

This e-mail message and any attachments are only for the use of the
intended
recipient and may contain information that is privileged, confidential
or
exempt from disclosure under applicable law. If you are not the intended
recipient, any disclosure, distribution or other use of this e-mail
message
or attachments is prohibited. If you have received this e-mail message
in
error, please delete and notify the sender immediately. Thank you.
This topic is locked and can not be replied to.