我正在使用 Ruby 1.9.2、Rails 3.1、Rspec、Postgres 和 Spork,但我无法让它们很好地协同工作。
第一次运行规范(Spork 在后台运行)工作正常。但是,当我第二次运行规范时,它失败了:
Failure/Error: Unable to find matching line from backtrace
PGError:
no connection to the server
# /Users/tom/.rvm/gems/ruby-1.9.2-p180@grapi/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in `exec'
etc....
任何提示表示赞赏!
最佳答案
您可能还启用了设计。
您的问题描述如下:https://github.com/sporkrb/spork/wiki/Spork.trap_method-Jujutsu
更具体地说,这里是 Rails 3.1:https://gist.github.com/1054078spec_helper.rb
和 env.rb
中 prefork 块的开头应如下所示:
Spork.prefork do
Spork.trap_method(Rails::Application, :reload_routes!)
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
...
祝你好运!
关于ruby-on-rails - "PGError: no connection to the server"使用 Spork 运行规范,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6721491/