On Tuesday 05 July 2005 10:08 am, Doug Alcorn wrote:> David Corbin <dcorbin-wmGZ+vDKSyrZJqsBc5GL+g@public.gmane.org>
writes:
> > How do I write two tests that need to have two different fixtures
> > ''files''. The test side is not hard, but
it''s not clear how to write
> > two different fixtures for one table.
>
> According to http://rails.rubyonrails.com/classes/Fixtures.html, you
> can define your fixture_path to be something other than test/fixtures
> and have a second set of fixtures.
>
> class FooTest < Test::Unit::TestCase
> self.fixture_path =
File.dirname(__FILE__)+''/../fixtures2''
>
> fixtures :foos
>
> ...
> end
>
> The trick though is you''d probably want to define a separate
TestCase
> class for each of the two types of tests that require the different
> fixtures.
The problem with this solution, is that the assignment of fixture_path is
being set at "require time", not at test run time. Now, depending on
how the
''fixtures'' method is implemented, it might be possible to do
that assignment
in setup, but I''m suspect it won''t work.
The seperate TestCase is not a problem.
David