我有一个新的rails环境我正在设置,并且我在运行RSPEC测试时遇到了与postgres连接到数据库的一些问题。
我的环境是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
并打开数据库控制台并向我显示模式,以便测试数据库和开发数据库在那里并且似乎正在运行 - 但Postgres在我运行时似乎仍然无法找到它rake spec
出于某种原因。
答案 0 :(得分:0)
查看Postgres on Rails FATAL: database does not exist
尝试rake db:create:all
,然后尝试rake db:migrate