我在Ruby on Rails上有點新,目前正在關注Michael Hartl的Rails教程。關於收益率耙測試的錯誤與提供
正如我所用 '衛士' 的測試,它說,
After running bundle exec rake test below are the results:
1) Failure:
StaticPagesControllerTest#test_should_get_home [c:/Usrs/Code Box/workspace/feed/test/static_pages_controller_test.rb:7]:
<Home | Ruby on Rails Sample App> expected but was <Feed>..
Expected 0 to be >= 1.
3 runs, 6 assertions, 1 failures, 0 errors, 0 sips.
我想每一頁上的標題更改動態所以這裏是我的應用程序視圖,
<!DOCTYPE html>
<html>
<head>
<title><%= yield(:title) %> | Ruby on Rails Sample App</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
,這裏是作爲錯誤消息指出主視圖,
<% provide(:title, "Home") %>
<h1>Lipsum</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maxime, distinctio! Quidem eaque labore eos ipsam a aliquam, eius. Distinctio quo reprehenderit nostrum commodi quod assumenda consequatur officia, placeat sit fugit.
</p>
最後,這裏的測試控制器,
class StaticPagesControllerTest < ActionController::TestCase
test "should get home" do
get :home
assert_response :success
assert_select "title", "Home | Ruby on Rails Sample App"
end
測試中的哪一行導致錯誤?最好包含完整的錯誤跟蹤。 – 2015-04-05 02:50:03
第7行 - 這是 - assert_select「標題」,「主頁| Ruby on Rails示例應用程序」 – 2015-04-05 16:30:35