Skip to content

Instantly share code, notes, and snippets.

@citrus
Created June 23, 2011 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save citrus/1043849 to your computer and use it in GitHub Desktop.
Save citrus/1043849 to your computer and use it in GitHub Desktop.
spork + cucumber-rails = "undefined method `World' for main:Object (NoMethodError)"

Here's the steps I took to create this error:

rvm use ruby-1.9.2-p180@sporkfail --create
gem install bundler
gem install rails --pre
rails new sporkfail
cd sporkfail

# edit Gemfile

bundle install
rails generate cucumber:install --spork
rails generate cucumber:feature post title:string body:text published:boolean
rails generate scaffold post title:string body:text published:boolean
rake db:migrate

bundle exec rake cucumber
# works

bundle exec spork
# error
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require 'rubygems'
require 'spork'
Spork.prefork do
require 'cucumber/rails'
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax.
Capybara.default_selector = :css
end
Spork.each_run do
# By default, any exception happening in your Rails application will bubble up
# to Cucumber so that your scenario will fail. This is a different from how
# your application behaves in the production environment, where an error page will
# be rendered instead.
#
# Sometimes we want to override this default behaviour and allow Rails to rescue
# exceptions and display an error page (just like when the app is running in production).
# Typical scenarios where you want to do this is when you test your error pages.
# There are two ways to allow Rails to rescue exceptions:
#
# 1) Tag your scenario (or feature) with @allow-rescue
#
# 2) Set the value below to true. Beware that doing this globally is not
# recommended as it will mask a lot of errors for you!
#
ActionController::Base.allow_rescue = false
# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
# See the DatabaseCleaner documentation for details. Example:
#
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
# DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
# end
#
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
# DatabaseCleaner.strategy = :transaction
# end
#
end
# Error
Using Cucumber
Preloading Rails environment
Loading Spork.prefork block...
undefined method `World' for main:Object (NoMethodError)
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/cucumber-rails-1.0.0/lib/cucumber/rails/world.rb:24:in `<top (required)>'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `require'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `block in require'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `require'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/cucumber-rails-1.0.0/lib/cucumber/rails.rb:4:in `<top (required)>'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `require'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `block in require'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:639:in `new_constants_in'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in `load_dependency'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `require'
/Users/Spencer/RoR/rails31/sporkfail/features/support/env.rb:11:in `block in <top (required)>'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/lib/spork.rb:24:in `prefork'
/Users/Spencer/RoR/rails31/sporkfail/features/support/env.rb:10:in `<top (required)>'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:233:in `load'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:233:in `block in load'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:639:in `new_constants_in'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in `load_dependency'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:233:in `load'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/lib/spork/test_framework.rb:138:in `block (2 levels) in preload'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/lib/spork/app_framework/rails.rb:8:in `preload'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/lib/spork/test_framework.rb:134:in `block in preload'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/lib/spork.rb:62:in `exec_prefork'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/lib/spork/test_framework.rb:120:in `preload'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/lib/spork/test_framework/cucumber.rb:17:in `preload'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/lib/spork/run_strategy/forking.rb:25:in `preload'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/lib/spork/runner.rb:74:in `run'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/lib/spork/runner.rb:10:in `run'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/gems/spork-0.9.0.rc8/bin/spork:10:in `<top (required)>'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/bin/spork:19:in `load'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180@sporkfail/bin/spork:19:in `<main>'
# Gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.0.rc4'
gem 'sqlite3'
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-script'
gem 'uglifier'
gem 'jquery-rails'
group :test do
gem 'cucumber-rails', '>= 1.0.0'
gem 'database_cleaner', '>= 0.6.7'
gem 'spork', '>= 0.9.0.rc8'
end
@larryh
Copy link

larryh commented Jun 24, 2011

Same thing happened to me when I upgraded to 1.0.

@citrus
Copy link
Author

citrus commented Jun 24, 2011

@larryh - I opened issue #122 on spork.. hopefully this will get sorted out soon!

-Spencer

@larryh
Copy link

larryh commented Jun 24, 2011 via email

@citrus
Copy link
Author

citrus commented Jun 24, 2011

@larryh - you're welcome! add a +1 comment to the issue ;)

@larryh
Copy link

larryh commented Jun 25, 2011 via email

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