As mentioned in another post recently, I have been trying to get Rails 3 and MongoDB working, firstly by following this handy document: http://www.mongodb.org/display/DOCS/Rails+3+-+Getting+Started Having done this, I found that the scaffold functional test code contained the following: require ''test_helper'' class JobsControllerTest < ActionController::TestCase setup do @job = jobs(:one) end # …. various basic tests here end I have defined a "one" job in jobs.yml. However, attempting to run tests gives me such errors as: NoMethodError: undefined method `jobs'' for #<JobsControllerTest:0x007f91c0f37da8> If I understand correctly, this would suggest that the jobs.yml fixture has not been loaded. Adding "fixtures :all" to test/test_helper.rb simply produces NoMethodErrors for "fixtures". I''m not getting any test.log entries to assist in debugging this, but I think that the database connection is working as the app, running in a development environment, successfully interacts with the development database. Have I missed something vital out when doing the initial app setup, perhaps? -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Have you tried adding the fixtures :all inside the JobsControllerTest class? I''ve not used fixtures or TestCase in a while but I''m sure thats how it''s done. David -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David White wrote in post #974225:> Have you tried adding the fixtures :all inside the JobsControllerTest > class?I did - sorry, should have mentioned it. That produces the same effect as putting it in test_helper.rb, ie. undefined method `fixtures'' for JobsControllerTest:Class (NoMethodError) Checking back to my Rails 2 code I used to have fixtures :all in the test_helper, so perhaps something is missing as a result of using MongoDB. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
My only suggestion now would be that fixtures is part of ActiveRecord. If you''re following that tutorial then you removed the require ''rails/all'' in favour of: require "action_controller/railtie" require "action_mailer/railtie" require "active_resource/railtie" require "rails/test_unit/railtie" Which means you project doesn''t include active record any more. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David White wrote in post #974236:> My only suggestion now would be that fixtures is part of ActiveRecord.It looks like you''re right - thanks. Simply including fixtures.rb doesn''t appear to work as it requires ActiveRecord::Base, which it seems I can''t also use if sticking to those instructions. I suspect that I''ll have to find another means to run the tests, avoiding fixtures. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It might be worth giving https://github.com/thoughtbot/factory_girl a try. It''s an excellent alternative to fixtures and if I''m right should hopefully use your model which is mongo based. A good tutorial here: http://railscasts.com/episodes/158-factories-not-fixtures David -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks - that looks very interesting indeed. I''ll give it a go. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 12 January 2011 13:49, David White <david-+ZbKFBrfdxLby3iVrkZq2A@public.gmane.org> wrote:> It might be worth giving https://github.com/thoughtbot/factory_girl a try. > It''s an excellent alternative to fixtures and if I''m right should hopefully > use your model which is mongo based. A good tutorial > here: http://railscasts.com/episodes/158-factories-not-fixturesI prefer Machinist, but it is a matter of taste. I don''t know about using it with mongo though. 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
No I wasn''t 100% on using factory_girl with mongo but worth a try. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It seems that factory_girl does indeed work. I didn''t have to do much other than create a test/factory.rb, include this in test/test_helper.rb, and add to the latter some code to clear out the test database after testing. Thanks again for the suggestions. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.