У меня есть кодовая база fre sh Rails 6 с базой данных pg, и я получаю сообщение об ошибке при попытке запустить простой тест rspe c. В чем может быть проблема здесь?
1) SomeModel Object Itself sets the name correctly
Failure/Error: m = SomeModel.new(name: 'some name', description: 'a description')
ActiveRecord::ConnectionNotEstablished:
No connection pool with 'primary' found.
И тестовая база данных, и база данных разработки выглядят нормально, когда я проверяю с PSQL
postgres-# \c test_doubles_test
You are now connected to database "test_doubles_test" as user "someusername".
test_doubles_test-# \dt
Did not find any relations.
test_doubles_test-# \c test_doubles_development
You are now connected to database "test_doubles_development" as user "someusername".
test_doubles_development-# \ct
invalid command \ct
Try \? for help.
test_doubles_development-# \dt
List of relations
Schema | Name | Type | Owner
--------+----------------------+-------+-------------
public | ar_internal_metadata | table | testdoubles
public | schema_migrations | table | testdoubles
public | some_models | table | testdoubles
(3 rows)
Active Record работает должным образом на консоли
± |master S:2 U:3 ?:2 ✗| → rails c
Loading development environment (Rails 6.0.2.2)
irb(main):001:0> SomeModel.count
(2.7ms) SELECT COUNT(*) FROM "some_models"
=> 0
irb(main)
config / database.yml
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: testdoubles
password: <%= ENV['APPNAME_DATABASE_PASSWORD'] %>
development:
<<: *default
database: test_doubles_development
test:
<<: *default
database: test_doubles_test
production:
<<: *default
database: test_doubles_production
username: test_doubles
password: <%= ENV['TEST_DOUBLES_DATABASE_PASSWORD'] %>
Наконец, мой Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.2', '>= 6.0.2.2'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
gem 'rubocop-rails', require: false
gem 'sorbet-runtime'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: %i[mri mingw x64_mingw]
gem 'rspec-rails', '~> 4.0.0'
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'web-console', '>= 3.3.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'sorbet'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
enter code here