1
嗨,大家好我是黃瓜新手,我有一個mongoid應用程序。未初始化的常量Cucumber :: Rails :: Database(NameError)cucumber + mongoid
我有database_cleaner在我的Gemfile
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/[email protected]/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/[email protected]/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load'
/home/ubuntu/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
/home/ubuntu/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/home/ubuntu/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/home/ubuntu/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `each'
/home/ubuntu/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/home/ubuntu/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/home/ubuntu/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:40:in `run!'
/home/ubuntu/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:43:in `execute!'
/home/ubuntu/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:20:in `execute'
/home/ubuntu/.rvm/gems/[email protected]/gems/cucumber-1.1.9/bin/cucumber:14:in `<top (required)>'
/home/ubuntu/.rvm/gems/[email protected]/bin/cucumber:23:in `load'
/home/ubuntu/.rvm/gems/[email protected]/bin/cucumber:23:in `<main>'
rake aborted!
Command failed with status (1): [/home/ubuntu/.rvm/rubies/ruby-1.9.3-p125/b...]
我的env.rb配置非常簡單:需要'水豚/黃瓜';需要'rspec/expectations';要求'黃瓜/鐵軌'; Capybara.javascript_driver =:硒 在文件「first_test.feature」中,我把「@javascript」正上方的「方案:打開新產品頁面」......我得到了這個錯誤:未初始化的常量Cucumber :: Rails: :Database :: Strategy :: DatabaseCleaner(NameError) 我曾在使用.rbenv和.rvm的計算機上運行相同的項目。他們兩人產生相同的問題。 – datnt 2014-06-17 03:01:44