pat / combustion

Simple, elegant testing for Rails Engines
MIT License
708 stars 51 forks source link

"No such file - ["config/database.yml"]" (not a rails engine) #85

Closed jrochkind closed 6 years ago

jrochkind commented 6 years ago

I have a gem which isn't actually a Rails::Engine (it has no Rails::Engine in it), which could be the root of the problem. My gem doesn't need any of the features that come with Rails::Engine, but it is meant for use with Rails (and does depend on ActiveRecord), and I want to have some integration tests in rspec to verify it works as expected in the context of Rails. So combustion seems very useful.

Not sure if not being a Rails::Engine is part of the problem or not. I have a bunch of specs that were already running fine, including many ActiveRecord. Now I want to add some integration tests.

My spec_helper.rb, trying to get the simplest thing that might work working, has:

require 'bundler'
Bundler.require :default, :development
Combustion.initialize! :active_record

From the Combustion.initialize! line, I get an exception raised:

RuntimeError: Cannot load `Rails.application.database_configuration`:
Could not load database configuration. No such file - ["config/database.yml"]

full stack trace

I have run bundle exec combust, and do have the files at spec/internal, including spec/internal/config/database.yml

Any ideas or hints of what might be going on, or where I should go next? Thanks!

jrochkind commented 6 years ago

Aha. I had standalone_migrations in my app, from before I considered using combustion.

They are incompatible in some way. Removing standalone-migrations, the error goes away, and my tests are running (although oddly having some failures they didn't have before, even before actually adding the integration test! Due to some differences in environment between combustion vs just require 'activerecord' I guess. But this I can explore!)

So nevermind, closing! Good to know it is incompatible with standalone_migrations (and indeed there's probably no good reason to use both).

pat commented 6 years ago

Great to know you've got things working :) Certainly if you hit other problems you're unsure about, feel free to open further issues here!

jrochkind commented 6 years ago

@pat thanks! I've got it working, but did have some confusions and things I'm still not certain about. Would it make sense for me to open an issue for each individually?

pat commented 6 years ago

Separate issues sounds like the best way to go - makes it easier for others to find solutions to similar problems :)