本文介绍了未初始化的常数Cucumber :: Rails :: Database(NameError)cucumber + mongoid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Gemfile
中有database_cleaner gemdatabase_cleaner,> = 0.7.2,:group => :test
在我的 app / features / support / env.rb
file我有:
require'cucumber / rails'
Capybara.default_selector =:css
ActionController :: Base.allow_rescue = false
begin
DatabaseCleaner.orm ='mongoid'
DatabaseCleaner.strategy =:truncation
rescue NameError
raiseYou需要添加database_cleaner到您的Gemfile(在:测试组)如果你想使用它。
end
Cucumber :: Rails :: Database.javascript_strategy =:truncation
当我运行 rake cucumber
我得到下一个错误:
未初始化的常数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(必填)"'
/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 :在`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在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`每个'
/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:在`execute'
/ home / ubuntu / .rvm / gems / ruby-1.9.3-p125 @ rails32 / gems / cucumber-1.1.9 / bin / cucumber:14:in`< top(必需)>'
/ 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!
命令失败,状态(1):[/home/ubuntu/.rvm/rubies/ruby-1.9.3-p125/b ...]
解决方案
我有一个类似的问题,我相信它的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
Hi guys I am newbie with cucumber and I have a app with mongoid.
I have database_cleaner in my Gemfile
gem "database_cleaner", ">= 0.7.2", :group => :test
In my app/features/support/env.rb
file I have:
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
When I run rake cucumber
I get the next error:
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...]
解决方案
I had a similar issue to this and I believe its RVM that is causing the problem.
Basically its the dependencies Ruby is compiled against; using rvm notes
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
这篇关于未初始化的常数Cucumber :: Rails :: Database(NameError)cucumber + mongoid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!