This a complete example: https://github.com/arturoherrero/rolling-back-transactions
Can anyone help me? Pull request are welcome :) On Friday, 4 April 2014 16:04:48 UTC+1, Jeremy Evans wrote: > > On Friday, April 4, 2014 6:22:30 AM UTC-7, Arturo Herrero wrote: >> >> I'm trying to configure RSpec to work with >> database_cleaner<https://github.com/bmabey/database_cleaner> using >> the transaction strategy and Sequel >> transactions<http://sequel.jeremyevans.net/rdoc/files/doc/transactions_rdoc.html> >> . >> >> Example of code that pass my specs: >> >> def call >> DB.transaction(:savepoint => true) do >> create_user >> create_account >> endend >> >> ------------------------------ >> >> def call >> DB.transaction(:savepoint => true) do >> DB.transaction do >> create_user >> create_account >> end >> endend >> >> I don't want to modify each transaction in my code and add :savepoint => >> true. So, I keep my original code: >> >> def call >> DB.transaction do >> create_user >> create_account >> endend >> >> and I add in spec_helper file: >> >> config.around(:each) do |spec| >> DB.transaction(:savepoint => true) do >> spec.run >> endend >> >> ------------------------------ >> >> Failures: >> Failure/Error: expect(users_count).to eq o >> >> expected: 0 >> got: 1 >> >> This approach is not working and apparently the behaviour need to be the >> same as the second working example that I wrote above. What's the problem? >> >> I found a similar >> approach<https://groups.google.com/d/msg/sequel-talk/VjfJcTD6s3w/D6nusXO_bbsJ> >> in >> the Sequel mailing list. I tried it too and it doesn't work for me. How I >> can configure RSpec to pass my specs? >> >> This was originally posted in StackOverflow: >> http://stackoverflow.com/q/22838625/462015. >> >> Thank you! >> > > You didn't post a self-contained example or the full error, so it's hard > to say for sure what is going on, but my guess is the key problem is you > aren't rolling back the transactions (no :rollback=>:always). See > http://sequel.jeremyevans.net/rdoc/files/doc/testing_rdoc.html > > If you still have problems and need help, please provide a self-contained > example file. > > Thanks, > Jeremy > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
