2014-11-13 2 views
1

자습서를 통해 따라하고 사이트 링크가 작동하지만 전달되지 않는 site_layout 링크 테스트는/about 경로입니다. 나는 나의 루트 파일, 바닥 글 파일을 통해 확인하고 site_layout_test 난 그냥 자습서를 확인하고 발견michael hartl 제 3 판 5.26 테스트 실패 site_layout 테스트 경로에 대해 no 표시

 1) Failure: 
    SiteLayoutTest#test_layout_links  [/home/ubuntu/workspace/sample_app/test/integration/site_layout_test.rb:10]: 
Expected at least 1 element matching "a[href="/about"]", found 0.. 
Expected 0 to be >= 1. 

    Rails.application.routes.draw do 
     root 'static_pages#home' 

     get 'help' => 'static_pages#help' 

     get 'about' => 'static_pages#about' 

     get 'contact' => 'static_pages#contact' 

<footer class="footer"> 
    <small> 
    The <a href= "http://www.railstutorial.org/">Ruby on Rails Tutorial</a> 
    by <a href="http://www.michaelhartl.com/">Michael Hartl</a> 
    </small> 
    <nav> 
    <ul> 
     <li><%= link_to "About", about_path %></li> 
     <li><%= link_to "Contact", contact_path %></li> 
     <li><a href="http://news.railstutorial.org/">News</a></li> 
    </ul> 
    </nav> 
</footer> 

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 
end 

답변

1

이것은 일반적인 버그가있는 것으로 보입니다. 모든 뷰 파일을 두 번 검사하고 내 통합 테스트에서 root_path에 대한 링크가 2 개 밖에없는 경우 3 개의 링크를 찾습니다. 로컬 레일 콘솔 내부의 로컬 응용 프로그램에서 테스트를 실행하면 작동합니다. c9의 콘솔이 올바르지 않습니다.

+0

이 질문은 클라우드 9를 처리합니까? – ppovoski

+0

예/his/home/우분투/workspace/sample_app 디렉토리로 판단 할 때 그는 Michael Hartl이 자신의 튜토리얼 전체에서 사용하도록 권장하는 c9 IDE를 사용하는 것이 가장 가능성이 높습니다 – MisterCal

0

무슨 잘못 찾을 수 없습니다 당신이 제거하면 그 site_layout_test.rb 테스트에서 "count : 2"가 통과합니다. "/home/ubuntu/workspace/sample_app/test/integration/site_layout_test.rb"에 필요합니다. 'test_helper'가 필요합니다.

(210)
class SiteLayoutTest < ActionDispatch::IntegrationTest 

test "layout links" do 
get root_path 
assert_template 'static_pages/home' 
assert_select "a[href=?]", root_path 
assert_select "a[href=?]", help_path 
assert_select "a[href=?]", about_path 
assert_select "a[href=?]", contact_path 
end 
0

그냥 당신은 코드 (about.html.erb) 당신이보기 파일을 확인 말하지 않았다 ...해야합니다 : <% 제공 (: 제목을 "정보") %> 아마 여기 제목에 철자가 틀린가요? 대소 문자/소문자?

관련 문제