2012-01-15 17 views
0

私はHartlのRoRチュートリアルを行っており、今は統合テストのセクションに入っています。指示通り私は.autotest修正:オートテストは統合テストのテストに失敗する

require 'autotest/growl' 
require 'autotest/fsevent' 
require "autotest/restart" 

Autotest.add_hook :initialize do |autotest| 
    autotest.add_mapping(/^spec\/requests\/.*_spec\.rb$/) do 
    autotest.files_matching(/^spec\/requests\/.*_spec\.rb$/) 
    end 
end 

私のセットアップ:エラーはその小さなニンジンを持っていることを私は見

/Users/zkidd/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -rrubygems -S /Users/zkidd/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/bin/rspec --tty '/Users/zkidd/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb' '/Users/zkidd/rails_projects/sample_app/spec/requests/layout_links_spec.rb' 
Exception encountered: #<SyntaxError: /Users/zkidd/rails_projects/sample_app/spec/requests/layout_links_spec.rb:7: syntax error, unexpected ':', expecting ')' 
    response.should have_selector('title,' :content => 'Home') 
              ^
/Users/zkidd/rails_projects/sample_app/spec/requests/layout_links_spec.rb:7: syntax error, unexpected ')', expecting keyword_end> 
backtrace: . . . . 

:私のエラーが読み出さ

Z-Kidds-MacBook-Air:sample_app zkidd$ ruby -v 
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0] 
Z-Kidds-MacBook-Air:sample_app zkidd$ rails -v 
Rails 3.1.3 

がこれです:autotestがコロンの代わりに ")"を期待しているという内容の:しかし、チュートリアルの詳細は、私が書いたものです。ここであなたが投稿コードで

require 'spec_helper' 

describe "LayoutLinks" do 

    it "should have a Home page at '/'" do 
    get '/' 
    response.should have_selector('title,' :content => 'Home') 
    end 

    it "should have a Contact page at '/contact'" do 
     get '/contact' 
     response.should have_selector('title,' :content => "Contact") 
    end 

    it "should have an About page at '/about'" do 
    get '/contact' 
    response.should have_selector('title,' :content => "About") 
    end 

    it "should have a Help page at '/help'" do 
    get '/help' 
    response.should have_selector('/title' :content => "Help") 
    end 

end 

答えて

1

layout_links_spec.rbがあり、

response.should have_selector('title,' :content => 'Home') 

のように、すべての行が

response.should have_selector('title', :content => 'Home') 

(カンマは文字列の外にある)でなければなりません。

最後のテストでは、'/title'の代わりに'title'

関連する問題