Greg Hauptmann
2009-Jan-14 07:27 UTC
can one test manual transactions in Rspec/UnitTest noting the testing framework wraps its DB work in a transaction & mysql doesn''t allow nested transactions?
Hi, Just wondering, can one test manual transactions in Rspec/UnitTest noting the testing framework wraps its DB work in a transaction & mysql doesn''t allow nested transactions? -- Greg http://blog.gregnet.org/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David Chelimsky
2009-Jan-15 18:23 UTC
Re: can one test manual transactions in Rspec/UnitTest noting the testing framework wraps its DB work in a transaction & mysql doesn''t allow nested transactions?
On Wed, Jan 14, 2009 at 1:27 AM, Greg Hauptmann <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > Just wondering, can one test manual transactions in Rspec/UnitTest noting > the testing framework wraps its DB work in a transaction & mysql doesn''t > allow nested transactions?Wrapping code examples (in rspec) or test methods (in t/u) in a transaction is the default behavior, but is easily turned off with config.transactional_fixtures = false. The name transactional_fixtures is a bit misleading because its really about wrapping each method in a transaction whether you''re using fixtures or not. If you do turn this off, however, you''ll want some code to truncate the DB after each example (after(:each) in rspec, teardown in test/unit) to avoid leaking state across examples. HTH, David> > -- > Greg > http://blog.gregnet.org/ > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Greg Hauptmann
2009-Jan-15 20:54 UTC
Re: can one test manual transactions in Rspec/UnitTest noting the testing framework wraps its DB work in a transaction & mysql doesn''t allow nested transactions?
actually what I really want would be to turn it off on just some tests, i.e. the ones that are going to be doing tests relating to transactions and rollbacks. Don''t suppose you know if this is possible? thanks On Fri, Jan 16, 2009 at 4:23 AM, David Chelimsky <dchelimsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > On Wed, Jan 14, 2009 at 1:27 AM, Greg Hauptmann > <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > > > Just wondering, can one test manual transactions in Rspec/UnitTest noting > > the testing framework wraps its DB work in a transaction & mysql doesn''t > > allow nested transactions? > > Wrapping code examples (in rspec) or test methods (in t/u) in a > transaction is the default behavior, but is easily turned off with > config.transactional_fixtures = false. > > The name transactional_fixtures is a bit misleading because its really > about wrapping each method in a transaction whether you''re using > fixtures or not. > > If you do turn this off, however, you''ll want some code to truncate > the DB after each example (after(:each) in rspec, teardown in > test/unit) to avoid leaking state across examples. > > HTH, > David > > > > > > -- > > Greg > > http://blog.gregnet.org/ > > > > > > > > > > > > > > >-- Greg http://blog.gregnet.org/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Jan-16 00:43 UTC
Re: can one test manual transactions in Rspec/UnitTest noting the testing framework wraps its DB work in a transaction & mysql doesn''t allow nested transactions?
On 15 Jan 2009, at 20:54, Greg Hauptmann wrote:> actually what I really want would be to turn it off on just some > tests, i.e. the ones that are going to be doing tests relating to > transactions and rollbacks. Don''t suppose you know if this is > possible?It''s a per subclass of Test::Unit::TestCase setting. IIRC (for test/ unit at least) rails will reload fixtures for you between tests. Fred> > thanks > > On Fri, Jan 16, 2009 at 4:23 AM, David Chelimsky > <dchelimsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On Wed, Jan 14, 2009 at 1:27 AM, Greg Hauptmann > <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > > > Just wondering, can one test manual transactions in Rspec/UnitTest > noting > > the testing framework wraps its DB work in a transaction & mysql > doesn''t > > allow nested transactions? > > Wrapping code examples (in rspec) or test methods (in t/u) in a > transaction is the default behavior, but is easily turned off with > config.transactional_fixtures = false. > > The name transactional_fixtures is a bit misleading because its really > about wrapping each method in a transaction whether you''re using > fixtures or not. > > If you do turn this off, however, you''ll want some code to truncate > the DB after each example (after(:each) in rspec, teardown in > test/unit) to avoid leaking state across examples. > > HTH, > David > > > > > > -- > > Greg > > http://blog.gregnet.org/ > > > > > > > > > > > > > > > > > -- > Greg > http://blog.gregnet.org/ > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Greg Hauptmann
2009-Jan-16 00:48 UTC
Re: can one test manual transactions in Rspec/UnitTest noting the testing framework wraps its DB work in a transaction & mysql doesn''t allow nested transactions?
actually I''m only using specs (rspec) On Fri, Jan 16, 2009 at 10:43 AM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 15 Jan 2009, at 20:54, Greg Hauptmann wrote: > > > actually what I really want would be to turn it off on just some > > tests, i.e. the ones that are going to be doing tests relating to > > transactions and rollbacks. Don''t suppose you know if this is > > possible? > > It''s a per subclass of Test::Unit::TestCase setting. IIRC (for test/ > unit at least) rails will reload fixtures for you between tests. > > Fred > > > > thanks > > > > On Fri, Jan 16, 2009 at 4:23 AM, David Chelimsky > > <dchelimsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Wed, Jan 14, 2009 at 1:27 AM, Greg Hauptmann > > <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > > > > Just wondering, can one test manual transactions in Rspec/UnitTest > > noting > > > the testing framework wraps its DB work in a transaction & mysql > > doesn''t > > > allow nested transactions? > > > > Wrapping code examples (in rspec) or test methods (in t/u) in a > > transaction is the default behavior, but is easily turned off with > > config.transactional_fixtures = false. > > > > The name transactional_fixtures is a bit misleading because its really > > about wrapping each method in a transaction whether you''re using > > fixtures or not. > > > > If you do turn this off, however, you''ll want some code to truncate > > the DB after each example (after(:each) in rspec, teardown in > > test/unit) to avoid leaking state across examples. > > > > HTH, > > David > > > > > > > > > > -- > > > Greg > > > http://blog.gregnet.org/ > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > Greg > > http://blog.gregnet.org/ > > > > > > > > > > > > > >-- Greg http://blog.gregnet.org/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---