pat / combustion

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

run Bundler.require after setting up the app's configuration #76

Closed jfeltesse-mdsol closed 7 years ago

jfeltesse-mdsol commented 7 years ago

This allows code in a before_configuration block to work properly, with Rails.root set to the proper path (spec/internal in most cases). Before Rails.root would return the root of the gem using combustion.

Not thoroughly tested (my gem only uses action_controller), opening a PR as a "FYI".

pat commented 7 years ago

Hi Julien,

Thanks for sharing this PR. I'm hoping to understand the problem better - I don't suppose your gem is publicly available on GitHub or elsewhere so I can see the code? :)

jfeltesse-mdsol commented 7 years ago

correct, it is not available publicly but basically it goes like

module MyGem
  class Railtie < Rails::Railtie
    config.before_configuration do
      # read some configuration file using Rails.root.join("config", "myfile.cfg")
    end
  end
end

The use case here is that after reading our config file we setup a custom logger and this needs to be done as soon as possible.

pat commented 7 years ago

I've been spending some time trying to confirm the difference in behaviour locally using one of my own gems and some debugging statements, but Rails.root never includes spec/internal at the before_configuration point. This is the case with and without your change.

I don't suppose you're able to create a test gem that uses your fork and reproduces the success?

jfeltesse-mdsol commented 7 years ago

Sorry I'm pretty time constrained right now so unfortunately I can't allocate time digging further... 😢 I suppose more stuff is at play if you're unable to reproduce. Maybe our gem is doing more things behind the scenes than it shows.

Feel free to close that PR and re-open if you or anyone comes up with a definite reproducible case. Thanks!

pat commented 7 years ago

No worries :) Appreciate the fact that you've lodged the issue and PR in the first place!