Rspec 测试失败,但应该通过。 Railstutorial.org 第 3 章

发布于 2024-12-14 17:24:15 字数 754 浏览 2 评论 0原文

我从编程中休息了很长时间,因为其他事情引起了我的兴趣。当我重新拿起它时,我决定返回railstutorial.org是个好主意,因为我第一次发现它很有用,但记不清了,正如我希望的那样。

在简单地运行命令“railsgeneratecontrollerPageshomecontact”后,我有一个“spec/controllers/pages_controllers_rspec.rb”文件,如下所示:

require 'spec_helper'

describe PagesController do

  describe "GET 'home'" do
    it "should be successful" do
      get 'home'
      response.should be_success
    end
  end

  describe "GET 'contact'" do
    it "should be successful" do
      get 'contact'
      response.should be_success
    end
  end
end

即使所有路由和控制器都已就位,如第 3 章所述,Rspec 指示失败。我做错了什么?

两个测试都失败并显示消息:

Failure/Error: Unable to find matching line from backtrace
PGError: fe_sendauth: no password supplied

I took a long break from programming, because other things caught my interest. When I picked it back up, I decided it would be a good idea to go back through railstutorial.org, since I found it useful the first time through, but couldn't remember much as I had hoped.

After simply running the command 'rails generate controller Pages home contact' I have a 'spec/controllers/pages_controllers_rspec.rb' file that looks like this:

require 'spec_helper'

describe PagesController do

  describe "GET 'home'" do
    it "should be successful" do
      get 'home'
      response.should be_success
    end
  end

  describe "GET 'contact'" do
    it "should be successful" do
      get 'contact'
      response.should be_success
    end
  end
end

Even though all the routes and controllers are in place as described in chapter 3, Rspec indicates failure. What am I doing wrong?

Both tests fail with messages:

Failure/Error: Unable to find matching line from backtrace
PGError: fe_sendauth: no password supplied

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪痕残 2024-12-21 17:24:21

尚未创建测试数据库。别问我为什么。一旦我返回并手动创建测试数据库,测试就开始通过。

The test database hadn't been created. Don't ask me why. Once I'd gone back in and manually created the test database, tests started passing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文