2013-04-01 65 views
1

我使用RSpec +水豚測試測試,但我已經得到了錯誤:URI :: InvalidURIError雖然我使用RSpec +水豚

Failure/Error: page.should have_selector('title', :text => "YourPos | About") 
    expected #has_selector?("title", {:text=>"YourPos | About"}) to return true, got false 
# ./spec/requests/static_pages_spec.rb:14:in `block (3 levels) in <top (required)>' 

而且我static_pages_spec.rb

require 'spec_helper' 

describe "Static pages" do 

    describe "About page" do 

    it "should have the title 'About' " do 
     visit '/static_pages/about' 
     page.should have_selector('title', :text => "YourPos | About") 
    end 
    end 

end 

和我的應用程序/ views/static_pages/about.html.erb

<!DOCTYPE html> 
<html> 
    <head> 
     <title>YourPos | About</title> 
    </head> 
    <body> 
     <p>Find me in app/views/static_pages/home.html.erb</p> 
    </body> 
</html> 

希望有人會幫助我,非常感謝。

回答

1

嘗試改變

visit 'static_pages/about' 

visit '/static_pages/about' 
+0

我這樣做,但我得到的另一個錯誤。我改變了問題的細節,現在有什麼問題? – hsming

+0

它告訴你,你正在尋找的文本不在返回的頁面上。當您正常訪問該頁面時會發生什麼? – muttonlamb

+0

它運作良好,標題是'YourPos |關於' – hsming