ruby-on-rails – 失败:在轨道上的ruby上预期0> = 1

我正在做Hartle教程并且每次运行rake测试时看到这个失败我看到这个失败:

1) Failure:
StaticPagesControllerTest#test_should_get_help [.../sample_app/test/controllers/static_pages_controller_test.rb:14]:
<Help | Ruby on Rails Tutorial Sample App> expected but was
<Ruby on Rails Tutorial Sample App>..
Expected 0 to be >= 1.

这是什么意思?我该如何解决
这是我的static_pages_controller_test.rb文件.

require 'test_helper'

class StaticPagesControllerTest < ActionController::TestCase

  test "should get home" do
    get :home
    assert_response :success
    assert_select "title","Ruby on Rails Tutorial Sample App"   end

  test "should get help" do
    get :help
    assert_response :success
    assert_select "title","Help | Ruby on Rails Tutorial Sample App"   end

  test "should get about" do
    get :about
    assert_response :success
    assert_select "title","About | Ruby on Rails Tutorial Sample App"   end

  test "should get contact" do
    get :contact
    assert_response :success
    assert_select "title","Contact | Ruby on Rails Tutorial Sample App"   end end

这是第14行.

assert_select "title","Help | Ruby on Rails Tutorial Sample App"

解决方法

问题是没有匹配“帮助| Ruby on Rails Tutorial Sample App”的html.

如果你看一下assert_select的定义,它接受:count as(可选)参数.如果未指定计数,则将html的最小出现次数设置为1.这就是为什么您得到的错误是预期0为> = 1 ..在您的情况下有0个匹配,其中测试至少是预期的1场比赛.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...