我为那该死的错误挣扎了一天。希望你能帮助我。当我尝试启动bundle exec cucumber -r features
堆栈跟踪:
Could not load 'active_record/connection_adapters/mysql2_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `<top (required)>'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/mysql2_adapter.rb:4:in `<top (required)>'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:188:in `spec'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.1/lib/active_record/connection_handling.rb:50:in `establish_connection'
/Users/volodymyr/projects/conductor/conductor/cucumber/features/support/databases.rb:27:in `<class:ReportingDb>'
/Users/volodymyr/projects/conductor/conductor/cucumber/features/support/databases.rb:11:in `<top (required)>'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/cucumber-1.3.15/lib/cucumber/rb_support/rb_language.rb:95:in `load'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/cucumber-1.3.15/lib/cucumber/rb_support/rb_language.rb:95:in `load_code_file'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/cucumber-1.3.15/lib/cucumber/runtime/support_code.rb:180:in `load_file'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/cucumber-1.3.15/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/cucumber-1.3.15/lib/cucumber/runtime/support_code.rb:82:in `each'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/cucumber-1.3.15/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/cucumber-1.3.15/lib/cucumber/runtime.rb:184:in `load_step_definitions'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/cucumber-1.3.15/lib/cucumber/runtime.rb:42:in `run!'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/cucumber-1.3.15/lib/cucumber/cli/main.rb:47:in `execute!'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/gems/cucumber-1.3.15/bin/cucumber:13:in `<top (required)>'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/bin/cucumber:23:in `load'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/bin/cucumber:23:in `<main>'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
/Users/volodymyr/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
Gemfile公司:
source 'http://rubygems.org'
gem 'cucumber'
gem 'rspec'
gem 'watir-webdriver'
gem 'parallel_tests'
gem 'activesupport'
gem 'httparty'
gem 'i18n'
gem 'json'
gem 'logger'
gem 'nokogiri'
gem 'activerecord'
gem 'mysql2', '> 0.3'
gem 'factory_girl'
gem 'database_cleaner'
gem 'aws-sdk'
gem 'rubyzip' # Required for rubyXL
gem 'rubyXL'
gem 'syntax'
gem 'rake'
gem 'mail'
group :development do
gem 'guard-cucumber' # Guard for Cucumber
gem 'terminal-notifier-guard' # OSX notifications! :)
end
最佳答案
必须定义数据库连接并在database.yml
文件夹中的config
文件中提供凭据。如果没有此文件,请创建它并将我们的设置添加到其中:
# in config/database.yml
development:
adapter: mysql2
encoding: utf8
database: DATABASE_NAME_FOR_DEVELOPMENT
username: DATABASE_USER
password: DATABASE_PASSWORD
host: localhost
port: 3306
test:
adapter: mysql2
encoding: utf8
database: DATABASE_NAME_FOR_TESTS
username: DATABASE_USER
password: DATABASE_PASSWORD
host: localhost
port: 3306
关于ruby - 无法加载“active_record/connection_adapters/mysql2_adapter”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25763270/