Postgres на Rails FATAL: база данных "my_app_test" не существует
У меня есть новая среда rails, которую я настраиваю, и у меня возникают некоторые проблемы с подключением postgres к базе данных при выполнении тестов RSPEC.
Моя среда - Ruby 2.2.4p230, Rails 3.2.22, Postgresql 9.4.5
Мой файл database.yml выглядит так:
test:
adapter: postgresql
encoding: unicode
database: myapp_com_test
min_messages: WARNING
pool: 5
username:
password:
я могу бежать rake db:migrate
и не получать никаких ошибок.
Я тоже могу бегать rails c test
и консоль, кажется, запускается и показывает мне:
Digest::Digest is deprecated; use Digest
Loading test environment (Rails 3.2.22)
[1] pry(main)>
Но когда я запускаю что-то вроде rake db:test:prepare
похоже, что он работает нормально в этом окне терминала, но я получаю FATAL: database "myapp_com_test" does not exist
в окне сервера.
В том же духе, когда я бегу rake spec
Я получаю то же самое FATAL: database "myapp_com_test" does not exist
в окне сервера вместе с этой ошибкой
Connecting to database specified by database.yml
(0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
(0.6ms) SELECT version FROM schema_migrations ORDER BY version
(126.3ms) DROP DATABASE IF EXISTS "myapp_com_test"
(236.5ms) CREATE DATABASE "myapp_com_test" ENCODING = 'unicode'
/Users/ryanfitch/.rvm/rubies/ruby-2.2.4/bin/ruby -S rspec ./spec/controllers/account_controller_spec.rb ./spec/controllers/artists_controller_spec.rb ./spec/controllers/contact_controller_spec.rb ./spec/controllers/exclusivities_controller_spec.rb ./spec/controllers/help_controller_spec.rb ./spec/controllers/home_controller_spec.rb ./spec/controllers/legal_controller_spec.rb ./spec/controllers/line_items_controller_spec.rb ./spec/controllers/mixtapes_controller_spec.rb ./spec/controllers/newsletter_controller_spec.rb ./spec/controllers/order_controller_spec.rb ./spec/controllers/originals_controller_spec.rb ./spec/controllers/registrations_controller_spec.rb ./spec/controllers/stations_controller_spec.rb ./spec/controllers/story_controller_spec.rb ./spec/controllers/tracks_controller_spec.rb ./spec/controllers/users_controller_spec.rb ./spec/decorators/exclusivities_decorator_spec.rb ./spec/decorators/station_decorator_spec.rb ./spec/features/user_creates_account_spec.rb ./spec/features/user_places_click_order_spec.rb ./spec/helpers/exclusivities_helper_spec.rb ./spec/helpers/stations_helper_spec.rb ./spec/models/address_spec.rb ./spec/models/artist_spec.rb ./spec/models/billing_information_spec.rb ./spec/models/exclusivity_spec.rb ./spec/models/license_spec.rb ./spec/models/line_item_spec.rb ./spec/models/mixtape_download_spec.rb ./spec/models/mixtape_spec.rb ./spec/models/order_spec.rb ./spec/models/outbox_spec.rb ./spec/models/promo_code_spec.rb ./spec/models/side_spec.rb ./spec/models/station_spec.rb ./spec/models/track_rank_spec.rb ./spec/models/track_spec.rb ./spec/models/user_spec.rb ./spec/models/vendor_spec.rb ./spec/routing/artists_routing_spec.rb ./spec/routing/contact_routing_spec.rb ./spec/routing/help_routing_spec.rb ./spec/routing/home_routing_spec.rb ./spec/routing/legal_routing_spec.rb ./spec/routing/mixtapes_routing_spec.rb ./spec/routing/originals_routing_spec.rb ./spec/routing/story_routing_spec.rb ./spec/routing/tracks_routing_spec.rb ./spec/views/stations/play.html.erb_spec.rb
invalid option: --no-fail-fast
Please use --help for a listing of valid options
/Users/ryanfitch/.rvm/rubies/ruby-2.2.4/bin/ruby -S rspec ./spec/controllers/account_controller_spec.rb ./spec/controllers/artists_controller_spec.rb ./spec/controllers/contact_controller_spec.rb ./spec/controllers/exclusivities_controller_spec.rb ./spec/controllers/help_controller_spec.rb ./spec/controllers/home_controller_spec.rb ./spec/controllers/legal_controller_spec.rb ./spec/controllers/line_items_controller_spec.rb ./spec/controllers/mixtapes_controller_spec.rb ./spec/controllers/newsletter_controller_spec.rb ./spec/controllers/order_controller_spec.rb ./spec/controllers/originals_controller_spec.rb ./spec/controllers/registrations_controller_spec.rb ./spec/controllers/stations_controller_spec.rb ./spec/controllers/story_controller_spec.rb ./spec/controllers/tracks_controller_spec.rb ./spec/controllers/users_controller_spec.rb ./spec/decorators/exclusivities_decorator_spec.rb ./spec/decorators/station_decorator_spec.rb ./spec/features/user_creates_account_spec.rb ./spec/features/user_places_click_order_spec.rb ./spec/helpers/exclusivities_helper_spec.rb ./spec/helpers/stations_helper_spec.rb ./spec/models/address_spec.rb ./spec/models/artist_spec.rb ./spec/models/billing_information_spec.rb ./spec/models/exclusivity_spec.rb ./spec/models/license_spec.rb ./spec/models/line_item_spec.rb ./spec/models/mixtape_download_spec.rb ./spec/models/mixtape_spec.rb ./spec/models/order_spec.rb ./spec/models/outbox_spec.rb ./spec/models/promo_code_spec.rb ./spec/models/side_spec.rb ./spec/models/station_spec.rb ./spec/models/track_rank_spec.rb ./spec/models/track_spec.rb ./spec/models/user_spec.rb ./spec/models/vendor_spec.rb ./spec/routing/artists_routing_spec.rb ./spec/routing/contact_routing_spec.rb ./spec/routing/help_routing_spec.rb ./spec/routing/home_routing_spec.rb ./spec/routing/legal_routing_spec.rb ./spec/routing/mixtapes_routing_spec.rb ./spec/routing/originals_routing_spec.rb ./spec/routing/story_routing_spec.rb ./spec/routing/tracks_routing_spec.rb ./spec/views/stations/play.html.erb_spec.rb failed
Есть идеи, что здесь происходит?
РЕДАКТИРОВАТЬ: я могу бежать rails db test
и он открывает консоль базы данных и показывает мне схему, так что тестовая база данных и база данных dev там есть и, кажется, работают - но Postgres все еще не находит ее, когда я запускаю rake spec
по какой-то причине.
1 ответ
Посмотрите Postgres on Rails FATAL: база данных не существует
Попробуйте rake db:create:all
а затем rake db:migrate