rspec / rspec-rails

RSpec for Rails 6+
https://rspec.info
MIT License
5.15k stars 1.03k forks source link

Autotest fails with "undefined method 'configure' for RSpec:Module" #56

Closed dbackeus closed 14 years ago

dbackeus commented 14 years ago

Though working about a week ago autotest currently fails with the following message:

/Users/druiden/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rspec-rails-ecc85494c7a36ef96e6fae06cbac27505f02dc64-273e1249d69c348b8e4c5a273447a247fe8ac328/lib/rspec/rails/transactional_database_support.rb:37: undefined method `configure' for RSpec:Module (NoMethodError)
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-c53683595749dcfa223802669237480ac9ebc17f/activesupport/lib/active_support/dependencies.rb:209:in `require'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-c53683595749dcfa223802669237480ac9ebc17f/activesupport/lib/active_support/dependencies.rb:209:in `require'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-c53683595749dcfa223802669237480ac9ebc17f/activesupport/lib/active_support/dependencies.rb:197:in `load_dependency'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-c53683595749dcfa223802669237480ac9ebc17f/activesupport/lib/active_support/dependencies.rb:209:in `require'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rspec-rails-ecc85494c7a36ef96e6fae06cbac27505f02dc64-273e1249d69c348b8e4c5a273447a247fe8ac328/lib/rspec/rails.rb:6
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-c53683595749dcfa223802669237480ac9ebc17f/activesupport/lib/active_support/dependencies.rb:209:in `require'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-c53683595749dcfa223802669237480ac9ebc17f/activesupport/lib/active_support/dependencies.rb:209:in `require'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-c53683595749dcfa223802669237480ac9ebc17f/activesupport/lib/active_support/dependencies.rb:197:in `load_dependency'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-c53683595749dcfa223802669237480ac9ebc17f/activesupport/lib/active_support/dependencies.rb:209:in `require'
from /Users/druiden/development/rails/streamio/spec/spec_helper.rb:5
from /Users/druiden/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Users/druiden/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/druiden/development/rails/streamio/spec/original_movie_stategies/cloud_front_spec.rb:1
from /Users/druiden/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Users/druiden/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/configuration.rb:233:in `require_files_to_run'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/configuration.rb:233:in `map'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/configuration.rb:233:in `require_files_to_run'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:37:in `configure'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:24:in `run'
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:12
from /Users/druiden/.rvm/gems/ruby-1.8.7-p249/gems/rspec-core-2.0.0.beta.8/bin/rspec:2

Running "rake specs" still works without problems.

I'm using todays rails edge with all the rspec gems also on edge.

dchelimsky commented 14 years ago

Autotest likes Rspec, not RSpec

Closed by b4052347d53fdd86e87f9c0a8408e742d3afdc24.

dbackeus commented 14 years ago

Thanks!

dbackeus commented 14 years ago

Actually after testing I still get the same error.

It seems RSpec::Core is not available even after the require 'rspec/core' in rails.rb (puts RSpec::Core on the line just after the require crashes cause it cannot find the constant). I can't figure out why. It's there when raking but not when autotesting.

dchelimsky commented 14 years ago

That was incidental - I just moved that in the process of solving the problem. The real problem was related to the conversion from Rspec to RSpec. After I fixed it, I had to uninstall all of the beta gems and rebuild them from git HEAD and re-install them before it worked. Please try that and see if it helps.

dbackeus commented 14 years ago

The problem was due to me using Bundler for RSpec and not system gems. I finally found the easiest way to patch rspec was to add the following lines in rspec-core/bin/rspec:

require 'bundler' Bundler.setup

kristianmandrup commented 14 years ago

$ AUTOFEATURE=true autotest loading autotest/cucumber_rails_rspec2 Error loading Autotest style autotest/cucumber_rails_rspec2 (no such file to load -- autotest/rails_rspec2). Aborting.

What should go in this 'cucumber_rails_rspec2' file or is there another solution?

I tried resolving it by installing autotest-rails, but didn't work:

http://groups.google.com/group/cukes/browse_thread/thread/7764eafe40c866fb

I have the rspec 2.0.0.beta11 gems and the latest cucumber and cucumber-rails all installed both as system gems and in my app using Bundler. Could this be the problem?

Thanks.

Kristian

dchelimsky commented 14 years ago

Just to document, the underlying problem is that autotest decides what class to load by searching for any autotest/discover.rb files anywhere on the load path, each of which is responsible to provide a name to autotest.

In this case it's picking up the autotest/discover.rb file in the project, which adds "rspec2" to the list of names. It also picks up the cucumber-rails' autotest/discover.rb, which adds "cucumber" to the list of names if AUTOFEATURE=true. Then autotest itself sees the config directory and adds "rails" to its own list. The result is the names cucumber, rails, and rspec2 are concat'ed to "cucumber_rails_rspec2" but nobody is supplying that file because rspec provides rails_rspec2 and cucumber provides cucumber_rails (I think).

Not sure what the right solution here is.

kristianmandrup commented 14 years ago

Looking at the cucumber 0.8.0 source, I see there is a 'cucumber_rails_rspec2' file. I find the 'rails-rspec2' file in rspec-rails 2.0.0.beta11.

It turns out that I need to install both as system gems, then it works. I had the rspec-rails 2.b11 gem only as a bundled gem. I think it would be nice with some kind of notice on this issue, maybe as a notice.txt file in the generated autotest folder or sth.?

dchelimsky commented 14 years ago

D'oh! I don't think a notice is necessary - it's really just a matter of how Rails-3 works. DHH talked about this in his keynote - that we're all going to have a little pain while we get used to the fact that every gem we're using needs to be listed in the Gemfile.