Comments (17)
Did you see this similar issue?
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.
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.
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.
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.
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.
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.
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.
Oh yes, here is that line in DatabaseCleaner::Base.db:
def db
@db || :default
end
from database_cleaner.
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.
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.
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.
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.
+1 for the raise
. Just ran into this
from database_cleaner.
+1 for the raise as well
from database_cleaner.
+1 for raise. Still an issue.
from database_cleaner.
@fosrias Would you mind pointing bundler to use ab066b1
of DatabaseCleaner to see if that resolves the issue for you?
from database_cleaner.
Worked like a charm. Thanks.
from database_cleaner.
Related Issues (20)
- DatabaseCleaner triggering `before` hook while threads are still running HOT 2
- url_allowlist only works against DATABASE_URL HOT 1
- Data
- uninitialized constant ActiveRecord::DatabaseConfigurations::ConnectionUrlResolver::URI HOT 2
- Remote database is wiped out HOT 2
- API documentation is empty HOT 1
- YAML aliases with Ruby 3.1 HOT 8
- Hand soap HOT 1
- NoMethodError: undefined method 'state' for nil:NilClass HOT 7
- Change strategy for specific test
- 0.0.0.0 doesn't count as a local host HOT 2
- Rspec tests freeze as soon as DatabaseCleaner begins to work HOT 1
- Feature spec should complete after showing the result
- Prevent cleaning of development database HOT 1
- Highly variable duration of truncations (not a database_cleaner issue)
- Deprecation warning on: DatabaseCleaner.clean_with(:truncation) HOT 1
- Reading Database config from database.yml HOT 1
- Is this gem compatible with ruby 3.2.2 HOT 1
- Issue with Rails 7.2
- NoMethodError error schema_migration with Rails 7.2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from database_cleaner.