연습 문제는 5 장 끝에 있습니다. 링크가 올바른 페이지로 이동하는지 테스트해야합니다. 여기에 내 테스트 코드가있다.내 rspec 테스트가 통과하지 못합니다. Michael Hartl 's rails tutorial
require 'spec_helper'
describe "LayoutLinks" do
it "should have the right links on the layout" do
visit root_path
click_link "About"
response.should have_selector('title', :content => "About")
click_link "Home"
response.should have_selector('title', :content => "Home")
click_link "Help"
response.should have_selector('title', :content => "Help")
click_link "Contact"
response.should have_selector('title', :content => "Contact")
click_link "Sign up now!"
response.should have_selector('title', :content => "Sign up")
end
end
마지막 테스트를 제외한 모든 항목이 통과합니다. 그것은 "지금 가입하십시오!"텍스트와 링크를 찾을 수 없다고 말합니다. . 페이지에 "지금 가입하십시오!"라는 메시지가 표시됩니다. 링크. 소스 코드에서 다르게 렌더링했을 수도 있지만 원본 코드를 보면 정상적으로 보입니다 <a href="/signup" class="signup_button round">Sign up now!</a>
. 내 이해에서 링크를 클릭 한 다음 제목이 : content 기호와 일치하는지 테스트해야합니다. 내가 뭔가를 오해하고 있니? 여기
Failures:
1) LayoutLinks should have the right links on the layout
Failure/Error: click_link "Sign up now!"
Webrat::NotFoundError:
Could not find link with text or title or id "Sign up now!"
콘텐츠 설정 => "지금 가입하십시오!" 실험하기 만하면되지만, 문제는 응답이 아닌 root_path에서 링크를 찾는 것 같습니다. –
장탄구가 있지만 느낌표를 제거하면 작동합니다. 'click_link 지금 가입하기 '' – lebreeze
방금 시도했습니다. 그것은 나에게 같은 오류를 준다. 나도 데려가려고! 링크에서 –