私は最近、Michael HartlのチュートリアルでRuby on Railsを学び始めたので、私はStackOverflowで新しくなりました。私はリスト8.25のテストに合格していないようです(「この時点でテストスイートはまだ緑色でなければなりません:$ bundle exec rake test):Michael Hartl's Railsチュートリアルの第8章、リスト8.25テストスイートRED
私のテストは赤で、エラーは次の通りです:
~/workspace/sample_app (log-in-log-out) $ bundle exec rake test
Started
ERROR["test_layout_links", SiteLayoutTest, 2016-04-14 23:15:47 +0000]
test_layout_links#SiteLayoutTest (1460675747.92s)
NoMethodError: NoMethodError: undefined method `full_title' for # <SiteLayoutTest:0x0000000a30bad8>
test/integration/site_layout_test.rb:13:in `block in <class:SiteLayoutTest>'
test/integration/site_layout_test.rb:13:in `block in <class:SiteLayoutTest>'
22/22: [======================================================] 100% Time: 00:00:01, Time: 00:00:01
Finished in 1.30261s
tests, 49 assertions, 0 failures, 1 errors, 0 skips
私は、第7章と第8章の最近の変更をもう一度読み直しました。 8.20と8.21と8.24のテストはちょうど合格です。
エラーで述べたファイルsite_layout_testは次のようになります。
require 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
test "layout links" do
get root_path
assert_template 'static_pages/home'
assert_select "a[href=?]", root_path, count: 2
assert_select "a[href=?]", help_path
assert_select "a[href=?]", about_path
assert_select "a[href=?]", contact_path
get signup_path
assert_select "title", full_title("Sign up")
end
end
ADDITIONS:
1)これは私がやっているチュートリアルです:https://www.railstutorial.org/book/log_in_log_out
2)これはファイルですエラーが参照するもの:
最後にassert_select、私はもうエラーを取得しません。
そして、これはapplication_helperです:
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title = '')
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
page_title + " | " + base_title
end
end
end
あなたのヘルプははるかに高く評価されます。前もって感謝します!
あなたが質問にチュートリアルへのリンクを投稿してくださいもらえますか?あなたが8章で言及している仕様を見つけることができませんでした。 – born4new
'test_helper'で' full_title'メソッドが定義されていますか? –
あなたのコメントをありがとう、私はいくつかの情報を追加しました – nannev