Hello I''m experiencing some problems using rails fixtures with unit tests. With my version of Ruby I have to define test with the following syntax: test ''some test'' do assert.. end instead of def test_some_test assert.. end If I try to include/load the fixtures by using: fixtures :stories, :votes after the class definition, I get the following errors: StandardError: No fixture with name.. What am I doing wrong? Is this the latest Ruby test code or am I using some outdated version? Is there any place that I could check that (I tried with some googling without relevant results)? Thanks in advance! -- Posted via http://www.ruby-forum.com/.
Aljaz Fajmut wrote:> With my version of Ruby I have to define test with the following syntax: > > test ''some test'' do > assert.. > endWhat do you mean by this? I don''t think the Ruby version should have anything to do with this. What testing framework are you using (Test::Unit, Soulda, etc)? This might affect how you use fixtures, I''m not sure. I use rSpec myself. I also tend to avoid fixtures altogether in favor of factories (factory_girl, machinist, etc.). -- Posted via http://www.ruby-forum.com/.
Robert Walker wrote:> Aljaz Fajmut wrote: >> With my version of Ruby I have to define test with the following syntax: >> >> test ''some test'' do >> assert.. >> end > > What do you mean by this? I don''t think the Ruby version should have > anything to do with this. What testing framework are you using > (Test::Unit, Soulda, etc)? > > This might affect how you use fixtures, I''m not sure. I use rSpec > myself. I also tend to avoid fixtures altogether in favor of factories > (factory_girl, machinist, etc.).I''m using the default one and I''m not yet familiar with all the concepts. -- Posted via http://www.ruby-forum.com/.
On Aug 13, 4:14 pm, Aljaz Fajmut <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello > > I''m experiencing some problems using rails fixtures with unit tests. > > With my version of Ruby I have to define test with the following syntax: > > test ''some test'' do > assert.. > end > > instead of > > def test_some_test > assert.. > end >Either syntax works.> If I try to include/load the fixtures by using: > fixtures :stories, :votesyou don''t need that any more - The default test_helper.rb is set to load all fixtures. Fred> > after the class definition, I get the following errors: > > StandardError: No fixture with name.. > > What am I doing wrong? > Is this the latest Ruby test code or am I using some outdated version? > Is there any place that I could check that (I tried with some googling > without relevant results)? > > Thanks in advance! > -- > Posted viahttp://www.ruby-forum.com/.
Frederick Cheung wrote:> On Aug 13, 4:14�pm, Aljaz Fajmut <rails-mailing-l...-ARtvInVfO7m5VldFQK4jKA@public.gmane.orgt> > wrote: >> instead of >> >> def test_some_test >> � assert.. >> end >> > Either syntax works. > >> If I try to include/load the fixtures by using: >> � fixtures :stories, :votes > > you don''t need that any more - The default test_helper.rb is set to > load all fixtures. > > FredIf I remove the line for including specific fixtures, I still get the errors (although the fixtures exist): 1) Error: test_should_return_3_latest_votes(StoryTest): StandardError: No fixture with name ''first'' found for table ''stories'' Any idea what could be wrong? -- Posted via http://www.ruby-forum.com/.
2009/8/14 Aljaz Fajmut <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Frederick Cheung wrote: >> On Aug 13, 4:14�pm, Aljaz Fajmut <rails-mailing-l...@andreas-s.net> >> wrote: >>> instead of >>> >>> def test_some_test >>> � assert.. >>> end >>> >> Either syntax works. >> >>> If I try to include/load the fixtures by using: >>> � fixtures :stories, :votes >> >> you don''t need that any more - The default test_helper.rb is set to >> load all fixtures. >> >> Fred > > If I remove the line for including specific fixtures, I still get the > errors (although the fixtures exist): > > 1) Error: > test_should_return_3_latest_votes(StoryTest): > StandardError: No fixture with name ''first'' found for table ''stories'' >Have you got a record ''first:'' in stories.yml? If so check the syntax carefully. Colin
You should write fixtures :stories, :votes, :first 2009/8/14 Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>> > 2009/8/14 Aljaz Fajmut <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: > > > > Frederick Cheung wrote: > >> On Aug 13, 4:14�pm, Aljaz Fajmut <rails-mailing-l...@andreas-s.net> > >> wrote: > >>> instead of > >>> > >>> def test_some_test > >>> � assert.. > >>> end > >>> > >> Either syntax works. > >> > >>> If I try to include/load the fixtures by using: > >>> � fixtures :stories, :votes > >> > >> you don''t need that any more - The default test_helper.rb is set to > >> load all fixtures. > >> > >> Fred > > > > If I remove the line for including specific fixtures, I still get the > > errors (although the fixtures exist): > > > > 1) Error: > > test_should_return_3_latest_votes(StoryTest): > > StandardError: No fixture with name ''first'' found for table ''stories'' > > > > Have you got a record ''first:'' in stories.yml? If so check the syntax > carefully. > > Colin > > > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---