1

大家好,我是黄瓜的新手,我有一个带有 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...]
4

1 回答 1

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
于 2012-07-11T18:00:23.350 回答