0

私は Ruby on Rails 2nd Ed., Hartl に取り組んでいます。セクション 3.3.3 では、Ruby が埋め込まれた静的テキストを削除した後、テストが失敗しました。以前は問題なくテストに合格していました。

rspec

    require 'spec_helper'

    describe "Home pages" do

      describe "Home page" do
        it "should have the h1 'Sample App'" do
          visit '/static_pages/home'
          page.should have_selector('h1', :text => 'Sample App')
        end

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

home.html.erb

    <% provide (:title, 'Home') %>
    <!DOCTYPE html>
    <html>
       <head>
          <title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
       </head>
       <body>
          <h1>Sample App</h1>
          <p>
             This is the home page for the
             <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
             sample application.
          </p>
       </body>
    </html>

コンソールからのエラー

    C:\Sites\rails_projects\sample_app>bundle exec rspec         spec/requests/static_pages_spec.rb
    ?[31mF?[0m?[31mF?[0m?[32m.?[0m?[32m.?[0m?[32m.?[0m?[32m.?[0m

    Failures:

      1) Home pages Home page should have the h1 'Sample App'
         ?[31mFailure/Error:?[0m ?[31mvisit '/static_pages/home'?[0m
         ?[31mActionView::Template::Error:?[0m
           ?        [31mC:/Sites/rails_projects/sample_app/app/views/static_pages/home.html.erb:1: syntax         error,
     unexpected ',', expecting ')'?[0m
           ?[31m...putBuffer.new; provide (:title, ' Home') ?[0m
           ?[31m...                               ^?[0m
           ?        [31mC:/Sites/rails_projects/sample_app/app/views/static_pages/home.html.erb:1: syntax         error,
     unexpected ')', expecting keyword_end?[0m
           ?[31m....new; provide (:title, ' Home') ?[0m
           ?[31m...                               ^?[0m
    ?[36m     # <internal:prelude>:10:in `synchronize'?[0m
    ?[36m     # ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in <top         (required)>'?[0m

      2) Home pages Home page should have the title 'Home'
         ?[31mFailure/Error:?[0m ?[31mvisit '/static_pages/home'?[0m
         ?[31mActionView::Template::Error:?[0m
           ?        [31mC:/Sites/rails_projects/sample_app/app/views/static_pages/home.html.erb:1: syntax         error,
     unexpected ',', expecting ')'?[0m
           ?[31m...putBuffer.new; provide (:title, ' Home') ?[0m
           ?[31m...                               ^?[0m
           ?        [31mC:/Sites/rails_projects/sample_app/app/views/static_pages/home.html.erb:1: syntax         error,
     unexpected ')', expecting keyword_end?[0m
           ?[31m....new; provide (:title, ' Home') ?[0m
           ?[31m...                               ^?[0m
    ?[36m     # <internal:prelude>:10:in `synchronize'?[0m
    ?[36m     # ./spec/requests/static_pages_spec.rb:12:in `block (3 levels) in <top         (required)>'?[0m

    Finished in 0.51562 seconds
    ?[31m6 examples, 2 failures?[0m

    Failed examples:

    ?[31mrspec ./spec/requests/static_pages_spec.rb:6?[0m ?[36m# Home pages Home page         should have the h1 'Sample App'?[0m
    ?[31mrspec ./spec/requests/static_pages_spec.rb:11?[0m ?[36m# Home pages Home page         should have the title 'Home'?[0m

どんな助けでも大歓迎です

4

1 に答える 1

2

括弧の前の空白を削除する必要があると思います

provide (:title, 'Home')

する必要があります

provide(:title, 'Home')
于 2013-06-13T01:50:57.750 に答える