Giter Site home page Giter Site logo

Comments (17)

bmabey avatar bmabey commented on August 26, 2024

Did you see this similar issue?

#37

One suggestion would be to try to establish the connection yourself before DatabaseCleaner tries to. The thought behind it being that for some reason the regular Rails environment can establish a connection to the DB but for whatever reason DBCleaner is going about it a different way and is causing problems...

from database_cleaner.

thebaggage avatar thebaggage commented on August 26, 2024

Hi bmabey,

Thanks for the quick response.

I did see that issue and attempted the solution. The database error was replaced by:

NOTICE:  there is no transaction in progress
      You have a nil object when you didn't expect it!
      You might have expected an instance of Array.
      The error occurred while evaluating nil.- (NoMethodError)
      /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract_adapter.rb:190:in `decrement_open_transactions'
      /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/active_record/transaction.rb:20:in `clean'
      /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/base.rb:77:in `clean'
      /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-rails-1.0.2/lib/cucumber/rails/hooks/database_cleaner.rb:9:in `After'

Considering the 'nil' on the connection, I'm guessing this is a related issue? Still very stumped, if you have any suggestions I'd be very appreciative. Might also be worth mentioning:

(a) I'm using factory girl in cucumber
(b) I've tried switching db adapters to mysql - same issue
(c) I've tried creating a bare project with just cucumber/rspec/database_cleaner/factory_girl & running a very basic scenario - same issue
(d) Rails 3.1.0rc4, database_cleaner 0.6.7, cucumber 1.0.2, pg 0.11.0

from database_cleaner.

bmabey avatar bmabey commented on August 26, 2024

If you have a bare project that is reproducing the issue please push it to github and I'll see if I can figure it out.

from database_cleaner.

thebaggage avatar thebaggage commented on August 26, 2024

Many thanks - really appreciate it.

Basic repo here: https://github.com/thebaggage/Database-Cleaner-Problem-Example

The scenario should pass all steps, but come back with 'failed' for the scenario, and the following error:

OTICE:  there is no transaction in progress
      You have a nil object when you didn't expect it!
      You might have expected an instance of Array.
      The error occurred while evaluating nil.- (NoMethodError)
      /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0.rc6/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `decrement_open_transactions'
      /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/active_record/transaction.rb:20:in `clean'
      /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/base.rb:77:in `clean'
      /Users/john/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-rails-1.0.2/lib/cucumber/rails/hooks/database_cleaner.rb:9:in `After'

from database_cleaner.

thebaggage avatar thebaggage commented on August 26, 2024

Hi again - thanks for the responses. In the end I just cleared out all my gems, installed them all again, and it worked. In short, a gem was broken...everything works fine now.

from database_cleaner.

thebaggage avatar thebaggage commented on August 26, 2024

Nope - the problem is back...haven't changed a thing. Removing database_cleaner from my Gemfile fixes it, but then I can't use database_cleaner. I'm completely at a loss.

from database_cleaner.

windock avatar windock commented on August 26, 2024

Try replacing "default: &defaults" part in your database.yml file with another name. As I remember, DatabaseCleaner or some other gem tries to establish connection to "default" database, sees that line and thinks it is a database configuration, but since it doesn't see "database" definition, it throws "No database specified. Missing argument: database."

from database_cleaner.

windock avatar windock commented on August 26, 2024

Oh yes, here is that line in DatabaseCleaner::Base.db:
def db
@db || :default
end

from database_cleaner.

thebaggage avatar thebaggage commented on August 26, 2024

rapturous applause
standing ovation
tickertape parade

Many thanks windock - I've spent almost two days on this...and yep, that was the issue. Much appreciated.

from database_cleaner.

windock avatar windock commented on August 26, 2024

I do think it causes too much frustration for everyone, I've spent 2 days previously on this also - lots of people use "default" block in database.yml I'd suggest to change DatabaseCleaner in a way not to connect to default database.

from database_cleaner.

thebaggage avatar thebaggage commented on August 26, 2024

nods Very much second windock on this one. 'Defaults' is really common, and the conflict was a real s.o.b. to track down.

from database_cleaner.

bmabey avatar bmabey commented on August 26, 2024

Hi, I was going to look into this this morning but I am glad to see that it was figured out. I'll look into why the :default is in place and see if relacing it with a raise would be a better approach (it seems like it would based on this thread).

from database_cleaner.

ramontayag avatar ramontayag commented on August 26, 2024

+1 for the raise. Just ran into this

from database_cleaner.

david-harkness avatar david-harkness commented on August 26, 2024

+1 for the raise as well

from database_cleaner.

fosrias avatar fosrias commented on August 26, 2024

+1 for raise. Still an issue.

from database_cleaner.

bmabey avatar bmabey commented on August 26, 2024

@fosrias Would you mind pointing bundler to use ab066b1 of DatabaseCleaner to see if that resolves the issue for you?

from database_cleaner.

fosrias avatar fosrias commented on August 26, 2024

Worked like a charm. Thanks.

from database_cleaner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.