我已尝试设置rspec和minitest测试,但在这两种情况下我都收到以下错误:ActiveRecord::ConnectionNotEstablished: No connection pool with id primary found.
我可以毫无问题地运行rails db:setup RAILS_ENV=test
,但运行rails db:migrate RAILS_ENV=test
并不起作用。它会抛出运行rspec .
也可能有所帮助,当我运行rails db:create RAILS_ENV=test
时,我得到Database 'mail_test' already exists
。所以数据库肯定存在,mail_test
是我的.env
我已尝试过所有内容,我的搜索内容充满了紫色链接,所以非常欢迎任何帮助或建议!
编辑:这是我的database.yml的test
部分
development:
adapter: postgresql
encoding: unicode
database: mail_dev
pool: 5
username: cbris
password:
test:
adapter: postgresql
encoding: unicode
database: mail_test
pool: 5
username: cbris
password:
source 'https://rubygems.org'
ruby '2.3.4'
gem 'rails', '5.0'
gem 'puma'
gem 'pg'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'slim-rails'
gem 'bootstrap-sass'
gem 'packery-rails'
gem 'font-awesome-sass'
gem 'jquery-rails'
gem 'turbolinks'
gem 'paperclip'
gem 'aws-sdk'
gem 'aws-sdk-rails'
gem 'devise'
gem 'redis'
gem 'sidekiq'
gem 'sidekiq-cron'
gem 'validate_url'
gem 'kaminari'
gem 'httparty'
gem 'smarter_csv'
gem 'chartkick'
gem 'meta_request'
gem 'tinymce-rails'
# Documentation
gem 'rdoc'
gem 'sdoc'
gem 'spring'
gem 'scout_apm'
gem 'annotate'
gem 'faker'
group :development, :test do
# Testing framework
gem 'rspec-rails'
gem 'dotenv-rails'
end
group :development do
gem 'byebug'
gem 'better_errors'
gem 'binding_of_caller'
end
group :test do
# Clean db after testing
gem 'database_cleaner'
gem 'capybara'
end
group :production do
gem 'rails_12factor'
end