2012-12-21 8 views
1

Michael Hartl의 RoR 안내서 5.3 절에 연락처 페이지를 추가하고 있습니다. 나는 $ bundle exec rspec spec/requests/static_pages_spec.rb을 만났다. 나는 그 오류를 알아낼 수 없다. spec/requests/static_pages_spec.rb를 변경하고 연락처 페이지에 대한 적절한 경로와 작업을 추가하고 연락처 페이지에 대한보기를 편집했습니다. 나는 다음과 같은 한 static_pages_spec.rb에서5 장의 레이아웃 링크 부분에 페이지를 추가하는 중 오류가 발생했습니다. (Michael Hartl)

Failures: 

    1) Static Pages Contact page should have the h1 'Contact' 
Failure/Error: visit '/static_pages/contact' 
ActionView::Template::Error: 
    /Users/themaktravels/rails_projects/happy_app/app/views/static_pages/contact.html.erb:1: syntax error, unexpected ',', expecting ')' 
    ...putBuffer.new; provide (:title, 'Contact') 
    ...        ^
    /Users/themaktravels/rails_projects/happy_app/app/views/static_pages/contact.html.erb:1: syntax error, unexpected ')', expecting keyword_end 
    ...ew; provide (:title, 'Contact') 
    ...        ^
# <internal:prelude>:10:in `synchronize' 
# ./spec/requests/static_pages_spec.rb:56:in `block (3 levels) in <top (required)>' 

    2) Static Pages Contact page should have the title 'Contact' 
Failure/Error: visit '/static_pages/contact' 
ActionView::Template::Error: 
    /Users/themaktravels/rails_projects/happy_app/app/views/static_pages/contact.html.erb:1: syntax error, unexpected ',', expecting ')' 
    ...putBuffer.new; provide (:title, 'Contact') 
    ...        ^
    /Users/themaktravels/rails_projects/happy_app/app/views/static_pages/contact.html.erb:1: syntax error, unexpected ')', expecting keyword_end 
    ...ew; provide (:title, 'Contact') 
    ...        ^
# <internal:prelude>:10:in `synchronize' 
# ./spec/requests/static_pages_spec.rb:61:in `block (3 levels) in <top (required)>' 

Finished in 0.53514 seconds 
9 examples, 2 failures 

Failed examples: 

rspec ./spec/requests/static_pages_spec.rb:55 # Static Pages Contact page should have the h1 'Contact' 
rspec ./spec/requests/static_pages_spec.rb:60 # Static Pages Contact page should have the title 'Contact' 

: :이 출력되는 RoR에 튜토리얼에서

describe "Contact page" do 

    it "should have the h1 'Contact'" do 
    visit '/static_pages/contact' 
    page.should have_selector('h1', :text => 'Contact') 
end 

    it "should have the title 'Contact'" do 
    visit '/static_pages/contact' 
    page.should have_selector('title', 
     :text => "Ruby on Rails Tutorial Happy App | Contact") 
end 

, 이것은 당신이 static_pages_spec.rb에서이 지시하는 것입니다 :

describe "Contact page" do 

    it "should have the h1 'Contact'" do 
    visit '/static_pages/contact' 
    page.should have_selector('h1', text: 'Contact') 
    end 

    it "should have the title 'Contact'" do 
    visit '/static_pages/contact' 
    page.should have_selector('title', 
       text: "Ruby on Rails Tutorial Sample App | Contact") 
    end 

static_pages_spec.rb에서 만든 변경 사항은 (1) "Happy App"에 "Sample App"을, ": text =>"대신에 (2) "text :"를 사용하여 형식이 일관되게 유지되도록했습니다. 코드는 static_pages_spec.rb입니다. 문제를 해결할 때 "텍스트"버전과 "텍스트"버전을 전환하여 같은 결과를 얻었습니다.

내가 오류를 해결하기 위해 무엇을 찾고 있어야하는지에 대한 제안 사항이 있습니까? 또한 오류 메시지를 읽는 방법에 대해 확신이 없습니다. 즉 오류의 첫 번째 섹션에 적절한 방법이 표시되거나 그 반대가됩니다.

감사합니다.

+1

? 오류가 표시되면 구문 오류가있는 것처럼 보입니다. –

+0

는 <% 제공 (: 제목을 '기업') %>

연락

\t 연락 루비 \t contact page에서 해피 앱 소개 레일 튜토리얼에.

LearningHowToCode

답변

1

제공하는 라인에 불필요한 공간이있는 것 같습니다. 그것은해야

<% provide(:title, 'Contact') %> 

하지

처럼 ** 응용 프로그램/뷰/static_pages/contact.html.erb **보기 파일보기를 무엇
<% provide (:title, 'Contact') %> 
+0

감사합니다. 나는이 여분의 공간을 보지 못했을 정도로 오랫동안 이것을보고있었습니다. – LearningHowToCode

+0

우리 모두에게 발생합니다 :-) –

관련 문제