Im still working on getting this to work
I think what you use is a more succinct version of what I had. I
tried it out but with no luck still. I think the problem may be
trying to find the DB handle. When rspec runs, DB is not available:
uninitialized constant Spec::Example::ExampleGroup::DB
However, I thought the connection was available as
Merb::Orms::Sequel.connect
Perhaps this is not correct? Is there a better way to get access to
the connection handle? I read thru the merb_sequel code, and it looks
like Merb::Orms::Sequel.connect should be returning the connection
refrence, but maybe im missing something? My transactions are not
rolling back.
Thanks,
Michael
On Oct 27, 8:18 am, Jeremy Evans <[EMAIL PROTECTED]> wrote:
> On Oct 26, 10:58 pm, fairchild <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello,
> > I am trying to use sequel with my spec tests and was trying to make
> > each example run within a transaction. I came up with the following
> > code:
>
> > # monkey patch Sequel transactions into rspec
> > module Spec
> > module Example
> > module ExampleGroupMethods
>
> > def execute_examples(success, instance_variables, examples)
> > return [success, instance_variables] unless success
> > after_all_instance_variables = instance_variables
> > examples.each do |example_group_instance|
> > Merb::Orms::Sequel.connect.transaction do
> > success &=
> > example_group_instance.execute(Spec::Runner.options,
> > instance_variables)
> > after_all_instance_variables =
> > example_group_instance.instance_variable_hash
> > raise Sequel::Error::Rollback #'Rolling Back after rspec
> > example'
> > end
> > end
> > return [success, after_all_instance_variables]
> > end
>
> > end
> > end
> > end
>
> > To confirm that this was working i wrote 2 examples, one to create an
> > object and one he next one to try and find it. IF transactions are
> > working the second find should fail, but it doesn't. Is there
> > something else I must do to ensure the rollback occurs?
> > Thanks,
> > Michael Fairchild
>
> Here's the code I use to run rspec examples inside a transaction, with
> changes rolled back at the end:
>
> class Spec::Example::ExampleGroup
> def execute(*args, &block)
> DB.transaction{super(*args, &block); raise
> Sequel::Error::Rollback}
> end
> end
>
> Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---