pat / combustion

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

Rackup has error trying to load engine gem #73

Closed ericenns closed 8 years ago

ericenns commented 8 years ago

This is the stack trace that I get when trying to run rackup, not sure what the problem is.

/home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in     `rescue in block (2 levels) in require': There was an error while trying to load the gem 'ciqap_cd4'. (Bundler::GemRequireError)
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
    from /home/ericenns/ciqap_cd4/config.ru:4:in `block in <main>'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
    from /home/ericenns/ciqap_cd4/config.ru:in `new'
    from /home/ericenns/ciqap_cd4/config.ru:in `<main>'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/server.rb:147:in `start'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/bin/rackup:4:in `<top (required)>'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/bin/rackup:23:in `load'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/bin/rackup:23:in `<main>'
pat commented 8 years ago

Hmm, I'm not sure of the cause, the error message isn't particularly helpful… don't suppose the source code of this library is online?

ericenns commented 8 years ago

It isn't but I just put something up that I followed the same steps, the name has just changed to combustion_test.

Here it is:

https://github.com/ericenns/combustion_test

pat commented 8 years ago

Just found some time to fire up that test repo locally, and the issue is that while you've got a dependency listed for Rails, you're not actually requiring it (anything listed in the gemspec as a dependency still needs to be manually required).

The unhelpful error messages are either from Rails or Bundler, I'm not sure which, but either way, adding require 'rails' to lib/ciqap_cd4.rb before you require other things that may require it - especially your engine - should get rackup running smoothly.

ericenns commented 8 years ago

I ended up adding require 'rails' to config.ru and now the rackup command works.

ericenns commented 8 years ago

Also I updated my example combustion_test with the fixes, for future reference.