未初始化的常量Cucumber :: Rails :: Database(NameError)黄瓜+ mongoid

时间:2012-07-11 17:43:04

标签: ruby-on-rails ruby-on-rails-3 rspec cucumber

大家好我是黄瓜的新手,我有一个mongoid的应用程序。

我的 Gemfile

中有database_cleaner
gem "database_cleaner", ">= 0.7.2", :group => :test

在我的app/features/support/env.rb文件中,我有:

require 'cucumber/rails'
Capybara.default_selector = :css
ActionController::Base.allow_rescue = false
begin
  DatabaseCleaner.orm = 'mongoid'
  DatabaseCleaner.strategy = :truncation
rescue NameError
  raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
Cucumber::Rails::Database.javascript_strategy = :truncation

当我运行rake cucumber

我收到了下一个错误:

uninitialized constant Cucumber::Rails::Database (NameError)
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library'
/home/ubuntu/Desktop/mf9/features/support/env.rb:59:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:40:in `run!'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:43:in `execute!'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:20:in `execute'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/gems/cucumber-1.1.9/bin/cucumber:14:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/bin/cucumber:23:in `load'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p125@rails32/bin/cucumber:23:in `<main>'
rake aborted!
Command failed with status (1): [/home/ubuntu/.rvm/rubies/ruby-1.9.3-p125/b...]

1 个答案:

答案 0 :(得分:1)

我遇到了类似的问题,我相信它的RVM导致了这个问题。

基本上它是针对Ruby编译的依赖项;使用rvm笔记

sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev