2013-05-28 35 views
1

只是試圖通過Michael Hartl的Ruby on Rails教程第5章的最後一部分,並得到運行RSpec測試的另一個錯誤。第5章 - Ruby on Rails教程 - 未定義的方法`has_title?'當運行RSpec測試

輸出是:

Static pages should have the right links on the layout Failure/Error: expect(page).to have_title('About Us') NoMethodError: undefined method has_title?' for #<Capybara::Session> # ./spec/requests/static_pages_spec.rb:59:in block (2 levels) in '

,並從線結果,從預期(頁)在下面的代碼中static_pages_spec.rb:

it "should have the right links on the layout" do 
    visit root_path 
    click_link "About" 
    expect(page).to have_title(full_title('About Us')) 
end 

注:發生這種情況運行有或沒有Spork

任何人都可以指向正確的方向請 ?

感謝, 巴扎

回答

7

have_title功能是從水豚2.1的支持。我想你的Gemfile裏有一個老版本的水豚。因此,更新您的Gemfile與

gem 'capybara', '2.1.0' 

然後更新水豚這樣

bundle update capybara 

,並使用RSpec的重新運行規範。它現在應該工作

請參閱此post其他選項

相關問題