私はMichaelHartlのRoRチュートリアルのセクション5.3にいます。ここでは、連絡先ページを追加しています。走っ$ bundle exec rspec spec/requests/static_pages_spec.rb
た。エラーがわかりません。spec / requests / static_pages_spec.rbに変更を加え、連絡先ページの適切なルートとアクションを追加し、連絡先ページのビューを編集しました。これは出力です:
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'
で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 Happy App | Contact")
end
RoRチュートリアルでは、これが次のように指示されています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)「SampleApp」を「HappyApp」に変更し、(2)「:text =>」の代わりに「text:」を使用したため、のコード全体で形式が一貫していましたstatic_pages_spec.rb
。トラブルシューティング時に、両方の「テキスト」バージョンを切り替えたところ、同じ結果が得られました。
エラーを解決するために何を探すべきかについての提案はありますか?また、エラーメッセージの読み方がわかりません。つまり、エラーの最初のセクションに適切な方法が示されていますか、またはその逆ですか。
ありがとうございました!