Bundler pre bug #171

Merged
merged 2 commits into from Sep 23, 2011

4 participants

@chaffeqa

Fixes Bundler --pre issue that only arrises if cucumber-rails is included outside of group :test.

Its a real edge case, but the fix was pretty painless and actually makes the code base more robust.

Basically any require of lib/cucumber/rails.rb will be ignored unless the call is from env.rb.

I also added a warning message to admonish users to put cucumber-rails under group :test (if the edge case is triggered)

@chaffeqa

I did create a ticket for bundler btw: bundler/bundler#1448

@aslakhellesoy aslakhellesoy merged commit c23d391 into cucumber:master Sep 23, 2011
@pda

The instructions in the warning message were not enough to prevent the warning for me.

Apart from moving cucumber-rails to a test-only bundler group, I had to prevent it being loaded by Bundler:

gem "cucumber-rails", "~> 1.0", require: false

Here's the backtrace of the warning I was getting prior to adding require: false:

⸩ rspec
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:76:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:76:in `rescue in block in require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:62:in `block in require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:55:in `each'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:55:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler.rb:128:in `require'
/Users/paul/org/project/config/application.rb:7:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/org/project/config/environment.rb:2:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/org/project/spec/spec_helper.rb:8:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/org/project/spec/models/example_spec.rb:1:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `load'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `map'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `load_spec_files'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/command_line.rb:18:in `run'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:80:in `run_in_process'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:69:in `run'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:10:in `block in autorun'

WARNING: Cucumber-rails required outside of env.rb.  The rest of loading is being defered until env.rb is called.
  To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile
@JeanMertz

same here, I already had the gem in the test group, but that didn't stop this message from showing up. using require: false solved this for now.

@aslakhellesoy
Cucumber member

What kind of ruby syntax is require: false ? Is that a new way to make a Hash?

@JeanMertz

Yes, it's the Ruby 1.9 style of assigning values in a hash. See here for the best explanation on the entire web.

@chaffeqa

Sorry for taking so long to get back about this...

I'm guessing that since you use require: false the cucumber-rails lib isn't getting loaded by bundler.

Could you try it without the require: false and get back to me about whether it worked?

@aslakhellesoy
Cucumber member

Folks, please open a new ticket. This is a closed pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment