gpt4 book ai didi

ruby-on-rails - Cucumber Rails 3.1 未初始化的常量 ActionController::Dispatcher (NameError)

转载 作者:行者123 更新时间:2023-12-03 20:45:25 26 4
gpt4 key购买 nike

我正在使用 Rails 3.1 应用程序,我正在将 cucumber 集成到我的应用程序中,但是当我尝试运行它时,出现了这个奇怪的错误,有人可以帮我吗?

Using the default profile...
uninitialized constant ActionController::Dispatcher (NameError)
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-rails-0.3.2/lib/cucumber/rails/action_controller.rb:51:in `rescue in <top (required)>'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-rails-0.3.2/lib/cucumber/rails/action_controller.rb:42:in `<top (required)>'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-rails-0.3.2/lib/cucumber/rails/world.rb:27:in `<top (required)>'
/Users/chinog9/INNKU/tacos/features/support/env.rb:11:in `<top (required)>'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/lib/cucumber/rb_support/rb_language.rb:143:in `load'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/lib/cucumber/rb_support/rb_language.rb:143:in `load_code_file'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/lib/cucumber/runtime/support_code.rb:176:in `load_file'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/lib/cucumber/runtime/support_code.rb:78:in `block in load_files!'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/lib/cucumber/runtime/support_code.rb:77:in `each'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/lib/cucumber/runtime/support_code.rb:77:in `load_files!'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/lib/cucumber/runtime.rb:137:in `load_step_definitions'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/lib/cucumber/runtime.rb:39:in `run!'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/lib/cucumber/cli/main.rb:43:in `execute!'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/lib/cucumber/cli/main.rb:20:in `execute'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-0.10.2/bin/cucumber:14:in `<top (required)>'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/bin/cucumber:19:in `load'
/Users/chinog9/.rvm/gems/ruby-1.9.2-p180/bin/cucumber:19:in `<main>'

这是我的 env.rb:
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')

require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/world'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'

require 'capybara/rails'
require 'capybara/cucumber'
require 'capybara/session'
require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript

Capybara.default_selector = :css

ActionController::Base.allow_rescue = false


Cucumber::Rails::World.use_transactional_fixtures = true

if defined?(ActiveRecord::Base)
begin
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
rescue LoadError => ignore_if_database_cleaner_not_present
end
end

这是我的 Gemfile:
source 'http://rubygems.org'

gem 'rails', '3.1.0.rc4'

gem 'sqlite3'
gem 'nifty-generators'

gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-script'
gem 'uglifier'

gem 'jquery-rails'

gem 'ruby-debug19', :require => 'ruby-debug'

group :development, :test do
gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails'
gem 'cucumber'
gem 'rspec-rails', '>=2.6'
gem 'rspec-rails-mocha'
gem 'spork', '~> 0.9.0.rc'
gem 'factory_girl_rails'
gem 'launchy'
gem "ruby-debug19"
gem 'turn', :require => false
gem "selenium-client"
end

gem "mocha", :group => :test

谢谢! :)

最佳答案

我遇到了同样的问题并解决了将 cucumber rails 升级到 1.0.5 的问题。在 Gemfile 中试试这个。

gem "cucumber-rails", "1.0.5"

并重新运行安装程序
script/rails g cucumber:install your-language --your-options

关于ruby-on-rails - Cucumber Rails 3.1 未初始化的常量 ActionController::Dispatcher (NameError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6576991/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com