2013-03-10 5 views
1
내가 제 5 장 테스트 파일을 실행했을 때 다음과 같은 오류를 받고 있어요 에있는 Hartl 튜토리얼에있어

:HARTL 5 장 full_title가 발견되지

실패 : 간결함을 위해

1) User pages Signup page 
Failure/Error: it { should have_selector('title', text: full_title('Sign up')) } 
NoMethodError: 
    undefined method `full_title' for #<RSpec::Core::ExampleGroup::Nested_2::Nested_1:0xaeb792c> 
# ./spec/requests/user_pages_spec.rb:12:in `block (3 levels) in <top (required)>' 

을, 문제 해결 중에 다른 "full_title을 찾을 수 없음"오류를 주석 처리했습니다.

메소드가 app/helpers/application_helper.rb 파일에 있음을 확인했습니다. 발견되지 않은 아이디어가 있습니까? 헬퍼 파일에있는 것이 가장 확실합니다.

내 사용자 페이지 사양 파일 :

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 
     "#{base_title} | #{page_title}" 
    end 
    end 
end 

답변

0

Tutorial 다른 장소 당신에 그것을 추가 할 것

require 'spec_helper' 

describe "User pages" do 

    subject { page } 

    describe "Signup page" do 
    before { visit signup_path } 

    it { should have_selector('h1', text: 'Sign Up') } 
    it { should have_selector('title', text: full_title('Sign up')) } 
    end 
end 

내 application_helper.rb 파일. spec에 사용 된 full_titlespec/support/utilities.rb에 정의되었습니다. application_helper.rb에 정의 된 것을 app/views/layouts/application.html.erb에 사용했습니다.

+0

정말 고마워요. 내가 어떻게 그걸 놓쳤는 지 잘 모르겠다. 나는 문자 그대로 이것을 몇 시간 동안보고 있었다. 그게 내 문제를 해결 했어. –

관련 문제