I have fixture data in froglets.yml In my functional test I specify fixtures :froglets I can then access the individual fixture values by froglets(:froglet1) for example. I want to check the data in my index view so I want to iterate through the froglets checking that the data is correctly formatted using something of the form froglets.each do |froglet| ... but this does not work as the froglets object appears to be an empty array. I realise I can do this by iterating the database records instead but this does not seem the right way to do it. I have googled without success. Suggestions will be much appreciated. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 30, 11:06 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> I have fixture data in froglets.yml > > In my functional test I specify fixtures :froglets > > I can then access the individual fixture values by froglets(:froglet1) for > example. > > I want to check the data in my index view so I want to iterate through the > froglets checking that the data is correctly formatted using something of > the form > froglets.each do |froglet| ... > but this does not work as the froglets object appears to be an empty array. > > I realise I can do this by iterating the database records instead but this > does not seem the right way to do it. > > I have googled without success. > > Suggestions will be much appreciated.I understand your skeptism, but eventually looping through the database records *is* the right way: Froglet.find(:all).each do |froglet| # ... end Looping through the fixtures only is not possible. Even though it was, it would be a bad idea since some of the records might have changed, new records might have been added and so on. You should always be sure to use the latest state of the database. :) -- Best regards, David Knorr http://twitter.com/perplect
2009/4/30 David Knorr <perplect-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> > > > On Apr 30, 11:06 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > I have fixture data in froglets.yml > > > > In my functional test I specify fixtures :froglets > > > > I can then access the individual fixture values by froglets(:froglet1) > for > > example. > > > > I want to check the data in my index view so I want to iterate through > the > > froglets checking that the data is correctly formatted using something of > > the form > > froglets.each do |froglet| ... > > but this does not work as the froglets object appears to be an empty > array. > > > > I realise I can do this by iterating the database records instead but > this > > does not seem the right way to do it. > > > > I have googled without success. > > > > Suggestions will be much appreciated. > > I understand your skeptism, but eventually looping through the > database records *is* the right way: > > Froglet.find(:all).each do |froglet| > # ... > end > > Looping through the fixtures only is not possible. Even though it was, > it would be a bad idea since some of the records might have changed, > new records might have been added and so on. You should always be sure > to use the latest state of the database. :) >I am happy to accept that I must do this, but I am not sure of the logic. Since this is running in a test then if the database has changed when the test is not expecting it then the test should fail. Colin> > -- > Best regards, > David Knorr > http://twitter.com/perplect > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---