database_cleaner-sequel
database_cleaner-sequel copied to clipboard
Transaction strategy fails with Sequel
Backtrace:
NoMethodError: undefined method `pop' for nil:NilClass
/home/braulio/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/database_cleaner-1.5.3/lib/database_cleaner/sequel/transaction.rb:31:in `clean'
/home/braulio/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/database_cleaner-1.5.3/lib/database_cleaner/base.rb:46:in `clean_with'
/home/braulio/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:91:in `block in clean_with'
/home/braulio/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:91:in `each'
/home/braulio/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:91:in `clean_with'
/home/braulio/Projects/olery/scheduler/spec/support/database_cleaner.rb:7:in `block (2 levels) in <top (required)>'
Multiple threads being used
I just ran into the same problem. In my case it's because Sequel::DATABASES
was empty when calling DatabaseCleaner.start
.
Thus I simply had to initialise the connection to my database before calling DatabaseCleaner.start
Ran into this as well. Updated implementation and it is working as expected:
class Minitest::Spec
before :each do
DatabaseCleaner[:sequel].start
end
after :each do
DatabaseCleaner[:sequel].clean
end
end
@jeffvincent It sounds like maybe this situation could be addressed in the README? What do you think?
Totally agree! tbh, I wasn't confident enough in my solution. Was expecting to hear about all kinds of terrible externalities I caused by doing things this way :)
An update to the README would certainly help future-me. I'm happy to create PR, if you think that's a good idea.
@jeffvincent Yes, please do!