Forum: Ruby on Rails can one test manual transactions in Rspec/UnitTest noting the testing framework wraps its DB work in

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2009-01-14 08:28
(Received via mailing list)
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/
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-01-15 19:23
(Received via mailing list)
On Wed, Jan 14, 2009 at 1:27 AM, Greg Hauptmann
<greg.hauptmann.ruby@gmail.com> 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
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2009-01-15 21:55
(Received via mailing list)
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@gmail.com>wrote:

> transaction is the default behavior, but is easily turned off with
> HTH,
> > >
> >
>
> >
>


--
Greg
http://blog.gregnet.org/
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-01-16 01:44
(Received via mailing list)
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
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2009-01-16 01:48
(Received via mailing list)
actually I'm only using specs (rspec)

On Fri, Jan 16, 2009 at 10:43 AM, Frederick Cheung <
frederick.cheung@gmail.com> wrote:

> unit at least) rails will reload fixtures for you between tests.
> > > Hi,
> >
> >
> >
> > >
>
>
> >
>


--
Greg
http://blog.gregnet.org/
This topic is locked and can not be replied to.