Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RoR教程-直接测试完整标题助手_Ruby On Rails_Ruby_Railstutorial.org - Fatal编程技术网

Ruby on rails RoR教程-直接测试完整标题助手

Ruby on rails RoR教程-直接测试完整标题助手,ruby-on-rails,ruby,railstutorial.org,Ruby On Rails,Ruby,Railstutorial.org,我正在做RoR教程第5章的练习,我似乎不知道用什么文本来代替“FILL_in”,我试图通过将实际与预期匹配来阅读错误消息。我做错了什么?另外,有人能解释一下和 需要“测试助手” 类ApplicationHelperTest

我正在做RoR教程第5章的练习,我似乎不知道用什么文本来代替“FILL_in”,我试图通过将实际与预期匹配来阅读错误消息。我做错了什么?另外,有人能解释一下

需要“测试助手”
类ApplicationHelperTest
有人能解释一下
是如何工作的吗

通常尖括号之间的术语,如
表示需要替换的值。在这种情况下,它提到:

assert_equal <expected>, <actual>
在这里,我们将
替换为
2
,将
替换为
result
,以测试1+1=2,正如我们预期的那样

我似乎不知道用什么文本来代替“填写”

因此,代码中的相关行是:

assert_equal full_title, FILL_IN
assert_equal full_title('help'), FILL_IN
在这两行中,您都应该用前面参数的结果替换
FILL\u In
——在本例中是
full\u title
,以及
full\u title('help')

因此,如果
full_title
给出了“Kim's Cool Rails站点”,那么第一行应该是:

assert_equal full_title, "Kim's Cool Rails Site"
assert_equal full_title('Help'), "Kim's Cool Rails Site | Help"
如果
full_title('Help')
给出了“Kim's Cool Rails Site | Help”,那么第二行应该是:

assert_equal full_title, "Kim's Cool Rails Site"
assert_equal full_title('Help'), "Kim's Cool Rails Site | Help"
**更新**

因此,您得到的错误基本上是:我们希望看到“RubyonRails教程示例应用程序”,而不是“Kim'sCoolRails站点”

在我给出的示例中,我只是以“Kim's Cool Rails站点”为例,因为我不知道您站点的实际标题。您需要将“Kim's Cool Rails站点”替换为站点的实际标题(即,
full\u path
returns)。因此,从错误消息判断,第一行所需的确切代码为:

assert_equal full_title, "Ruby on Rails Tutorial Sample App"

您需要自己找出第二行所需的确切文本,但基本上您只需将“Kim's Cool Rails Site | Help”替换为您希望返回的
完整标题(“Help”)

有人能解释一下
是如何工作的吗

通常尖括号之间的术语,如
表示需要替换的值。在这种情况下,它提到:

assert_equal <expected>, <actual>
在这里,我们将
替换为
2
,将
替换为
result
,以测试1+1=2,正如我们预期的那样

我似乎不知道用什么文本来代替“填写”

因此,代码中的相关行是:

assert_equal full_title, FILL_IN
assert_equal full_title('help'), FILL_IN
在这两行中,您都应该用前面参数的结果替换
FILL\u In
——在本例中是
full\u title
,以及
full\u title('help')

因此,如果
full_title
给出了“Kim's Cool Rails站点”,那么第一行应该是:

assert_equal full_title, "Kim's Cool Rails Site"
assert_equal full_title('Help'), "Kim's Cool Rails Site | Help"
如果
full_title('Help')
给出了“Kim's Cool Rails Site | Help”,那么第二行应该是:

assert_equal full_title, "Kim's Cool Rails Site"
assert_equal full_title('Help'), "Kim's Cool Rails Site | Help"
**更新**

因此,您得到的错误基本上是:我们希望看到“RubyonRails教程示例应用程序”,而不是“Kim'sCoolRails站点”

在我给出的示例中,我只是以“Kim's Cool Rails站点”为例,因为我不知道您站点的实际标题。您需要将“Kim's Cool Rails站点”替换为站点的实际标题(即,
full\u path
returns)。因此,从错误消息判断,第一行所需的确切代码为:

assert_equal full_title, "Ruby on Rails Tutorial Sample App"

您需要自己找出第二行所需的确切文本,但基本上您只需将“Kim's Cool Rails Site | Help”替换为您希望返回的
完整标题(“Help”)

我相信这就是您想要的

require 'test_helper'

class ApplicationHelperTest < ActionView::TestCase
  test "full title helper" do
    assert_equal full_title,          "Ruby on Rails Tutorial Sample App"
    assert_equal full_title("Help"),  "Help | Ruby on Rails Tutorial Sample App"
  end
end
需要“测试助手”
类ApplicationHelperTest
我相信这就是你想要的

require 'test_helper'

class ApplicationHelperTest < ActionView::TestCase
  test "full title helper" do
    assert_equal full_title,          "Ruby on Rails Tutorial Sample App"
    assert_equal full_title("Help"),  "Help | Ruby on Rails Tutorial Sample App"
  end
end
需要“测试助手”
类ApplicationHelperTest
欢迎来到堆栈溢出。请不要将屏幕截图或图像用于代码和错误。我们不能重复使用内容来帮助您,让我们手动键入任何需要的内容。如果你的GUI出现问题,它们是可以的。请重新编辑你的问题并格式化代码,使其可读。这是大量的图像;请使用文本。。。在我看来,代码是可读的。我还能做什么?使用文本,而不是图像。欢迎使用堆栈溢出。请不要将屏幕截图或图像用于代码和错误。我们不能重复使用内容来帮助您,让我们手动键入任何需要的内容。如果你的GUI出现问题,它们是可以的。请重新编辑你的问题并格式化代码,使其可读。这是大量的图像;请使用文本。。。在我看来,代码是可读的。我还能做什么?使用文本,而不是图像。你很接近了,我强烈建议你阅读错误消息,看看它可能会告诉你关于你的代码的信息,然后自己解决这个问题。提示:“Kim's Cool Rails站点”只是我从头猜到的一个随机字符串,因为我不知道你的完整标题方法会返回什么。不过,如果你自己还不明白,我已经用更多的信息更新了我的答案。非常感谢。在提交之前,我一直在跟踪错误消息