Hi, My app uses a read-only database --- what I need to test is the parsing code. I''d like to be able to copy the development database to test, and run a series of unit tests based on it. But I can''t see how to stop the test system from clearing the data out for each test. Any way to do this? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Craig Demyanovich
2009-Mar-15 12:26 UTC
Re: How to disable database setup / teardown in unit tests?
There''s a :purge task in databases.rake in vendor/rails/railties/lib/tasks. You''ll wan to find a way to avoid calling that when running tests. I''m interested to see what ideas others might share. Regards, Craig -- Craig Demyanovich Mutually Human Software http://mutuallyhuman.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-/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 -~----------~----~----~----~------~----~------~--~---
Craig Demyanovich wrote:> There''s a :purge task in databases.rake in > vendor/rails/railties/lib/tasks. You''ll wan to find a way to avoid > calling that when running tests. > > I''m interested to see what ideas others might share.Leave your test database read-write, and load it up with the test/fixtures system. Then, in setup(), use Mocha to mock your .save methods (and .update, and whatever internal methods they all call), and raise a fault if anyone calls them. Always think of mocks as a way to "change reality" - to make random dice crooked, or to change the clock time. Alternately... Switch the DB to "read-only" in setup() and turn that off in "tear-down". Either way, experiment by trying to .save from a scratch test, to ensure the system correctly blows up in your face. The point is to make sure at production time it does not! -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---