My Rails应用程序运行正常,但当我尝试应用某些模型测试时,RSpec会抛出错误:
Enter a non-negative number (0-exit): 1
Number 1 is composite
Enter a non-negative number (0-exit): 2
Number 2 is prime
Enter a non-negative number (0-exit): 3
Number 3 is prime
Enter a non-negative number (0-exit): 4
Number 4 is composite
Enter a non-negative number (0-exit): 5
Number 5 is prime
Enter a non-negative number (0-exit): 6
Number 6 is composite
Enter a non-negative number (0-exit): 7
Number 7 is prime
Enter a non-negative number (0-exit): 8
Number 8 is composite
Enter a non-negative number (0-exit): 9
Number 9 is composite
Enter a non-negative number (0-exit): 0
这是我的database.yml文件:
/home/luka/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `initialize': FATAL: password authentication failed for user "luka" (PG::ConnectionBad)
FATAL: password authentication failed for user "luka"
这是我跑的测试:
default: &default
adapter: postgresql
encoding: unicode
host: localhost
username: luka
password: 4129235
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
test:
<<: *default
database: postdb_test
的Gemfile:
require 'spec_helper'
require 'rails_helper'
describe Student do
it "creates valid entry"
end
我安装了一个pg,用正确的密码创建了用户并创建了&#39; postdb&#39;拥有正确的所有者在配置中我已经从同伴变为md5。没啥事儿。
UPD:问题出现在&#34; postgres&#34;用户。命令&#34; createdb&#34;并且CREATE DATABASE没有做任何事情,CREATE USER和ALTER USER
也是如此答案 0 :(得分:0)
不知道它是什么,但通过重新安装postgre来治愈。