【发布时间】:2013-11-27 03:19:50
【问题描述】:
注意:我正在关注 Ruby on Rails 的教程,因此我是一个完全的菜鸟
基本上,在我所关注的教程中,它向您展示了如何进行您在进行中遇到的失败测试,例如您的程序的清单。我的问题是,当我进行测试时,它某种输出了它应该输出的内容,但是在错误中,这不好(我认为)因为它与指令的输出不匹配。
输出:http://pastebin.com/0xyf3aBf(如下所示)
输出
Failures:
1) Static pages Home page should have the content 'Sample App'
←[31mFailure/Error:←[0m ←[31mexpect(page).to have_content('Sample App')←[0m
←[31mexpected #has_content?("Sample App") to return true, got false←[0m
←[36m # ./spec/requests/static_pages_spec.rb:9:in `block (3 levels) in <top
(required)>'←[0m
Finished in 0.07 seconds
←[31m1 example, 1 failure←[0m
Failed examples:
←[31mrspec ./spec/requests/static_pages_spec.rb:7←[0m ←[36m# Static pages Home p
age should have the content 'Sample App'←[0m
Randomized with seed 10853
我的 static_pages_specs.rb 文件:http://pastebin.com/L0LHACR4(如下所示)
static_pages_specs.rb
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
expect(page).to have_content('Sample App')
end
end
end
【问题讨论】:
-
这里可以不加代码吗?
-
我不明白这个问题,因为我看不到“指令的输出”。我们也不知道您正在使用的任何东西的版本、您正在遵循的教程等等。简而言之,目前无事可做。
标签: ruby-on-rails ruby rspec railstutorial.org