[LRUG] Handling opening and closing of transactions manually in ActiveRecord
Tim Cowlishaw
tim at timcowlishaw.co.uk
Fri Oct 8 04:32:54 PDT 2010
On Fri, Oct 8, 2010 at 11:40 AM, Matthew Willson <matthew at playlouder.com> wrote:
> Can't speak for datamapper, or for RSpec infact, but here's a little test mixin we use with Sequel and test/spec in case a similar approach works.
>
> module TransactionalTestCase
> def run(*args, &block)
> database.transaction do
> super
> raise Sequel::Error::Rollback
> end
> end
> end
>
Aah interesting! sadly it's not a technique that's transferrable over
to rspec / AR, but very elegant nonetheless. I recently switched back
to using test/unit and stories from rspec and cucumber for a personal
project recently, and this nicely illustrates one of the reasons why -
the syntax, while being a bit more verbose than rspec's, actually
allows you to do things like this in a simple ruby-ish way, rather
than messing around with the implementation of their DSL.
More information about the Chat
mailing list