pat / combustion

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

Allow to require engine gem just after requiring rails modules #46

Closed pabloh closed 11 years ago

pabloh commented 11 years ago

This fixes issues like https://github.com/pat/combustion/issues/27. Without having to do to any work around.

pabloh commented 11 years ago

This would also allow only do require 'bundler/setup' at spec_helper.rb instead of doing

require 'bundler'

Bundler.require :default, :test

Maybe I could add a commit to update the README file if you want.

pabloh commented 11 years ago

@pat, @parndt: no comment about this so far?

I think could settle for at least some mean to execute code after the rails modules are loaded but before Combustion::Application.initialize! is run. Like having some Combustion attribute where you could pass a block to be run, or maybe passing a block to Combustion.initialize! directly.

pat commented 11 years ago

@pabloh I'd be open to the idea of passing a block to Combustion.initialize that gets called just prior to Combustion::Application.initialize!. That feels a bit cleaner than this approach of guessing the gem name and loading it.

pabloh commented 11 years ago

@pat I changed commits I originally sent. Do you think the current changes are acceptable?, I'm basically calling 'Bundler.require' after requiring the rails modules and just before calling Application.initialize!. I also updated the README since the source of the problem I was having was when calling 'Bundler.require :default, :test' at the spec_helper.rb file.

The other approach of yielding a block just before calling Application.initialize!, will also work but I think this one is simpler.

pabloh commented 11 years ago

@pat @parndt , any feedback on this?

parndt commented 11 years ago

One (potential?) snag is that this binds us to Bundler inside of Combustion's source code whereas we previously weren't.

pabloh commented 11 years ago

@parndt, since when using rails you're already heavily binded to bundler, I don't understand how that could be a problem.

pat commented 11 years ago

I've merged this in - I agree that we're pretty closely tied to Bundler anyway, as that's what Rails uses and this gem's all about testing Rails-related libraries.