I have a very simple problem. I can''t seem to access a the fixture by name I have a sites.yml with: simple_site: id: 1 name: demo description: A demo site created_on: 2005-10-25 00:00:00 updated_on: 2005-10-25 00:00:00 And I have a test class as: require File.dirname(__FILE__) + ''/../test_helper'' class SiteTest < Test::Unit::TestCase fixtures :sites, :contenttypes, :contentitems def setup end def test_create puts @sites puts @sites["simple_site"] end end When I attempt to print out the fixture I just get nil. I thought you reference the fixture as an instance variable with the name of the fixture file. So I use "@sites" since the fixtures are located in sites.yml Am I doing something wrong? scott. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Scott F. Walterscottwalter.com --explorer what''s new
Never mind its the whole instantiated fixture flag with 1.0 --- Scott Walter <tx_scottwalter-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> I have a very simple problem. I can''t seem to > access > a the fixture by name > > I have a sites.yml with: > > simple_site: > id: 1 > name: demo > description: A demo site > created_on: 2005-10-25 00:00:00 > updated_on: 2005-10-25 00:00:00 > > And I have a test class as: > > require File.dirname(__FILE__) + ''/../test_helper'' > > class SiteTest < Test::Unit::TestCase > fixtures :sites, > :contenttypes, > :contentitems > > def setup > end > > def test_create > puts @sites > puts @sites["simple_site"] > end > end > > When I attempt to print out the fixture I just get > nil. I thought you reference the fixture as an > instance variable with the name of the fixture file. > > So I use "@sites" since the fixtures are located in > sites.yml > > Am I doing something wrong? > > scott. > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Scott F. > Walterscottwalter.com --explorer what''s new > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Scott F. Walterscottwalter.com --explorer what''s new
On 10/28/05, Scott Walter <tx_scottwalter-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> I have a very simple problem. I can''t seem to access > a the fixture by name > > I have a sites.yml with: > > simple_site: > id: 1 > name: demo > description: A demo site > created_on: 2005-10-25 00:00:00 > updated_on: 2005-10-25 00:00:00 > > And I have a test class as: > > require File.dirname(__FILE__) + ''/../test_helper'' > > class SiteTest < Test::Unit::TestCase > fixtures :sites, > :contenttypes, > :contentitems > > def setup > end > > def test_create > puts @sites > puts @sites["simple_site"] > end > end > > When I attempt to print out the fixture I just get > nil. I thought you reference the fixture as an > instance variable with the name of the fixture file. > So I use "@sites" since the fixtures are located in > sites.yml > > Am I doing something wrong? > > scott. > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Scott F. Walterscottwalter.com --explorer what''s new > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >DHH recently pointed someone to http://www.clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting for explanations. summary: a default has changed in rails 1.0 => instanciated fixtures are now turned OFF by default. Read the linked article for a discussion of how to reactivate them or even better optimise you tests speed. Cheers Jean