2012-08-29 23 views
1

我很新的RoR,並遵循Rails教程。我創建了一個頁面控制器,並首先創建了主頁和聯繫人頁面並運行測試。這兩個例子都通過了。接下來,我手動添加了第三個「關於」頁面並進行了適當的更改。然而,第三個「關於」的例子在spork運行中失敗。一旦我關閉spork,例子就通過了。 這裏是叉勺運行輸出:Ruby on Rails - rspec失敗1 spork的例子,但沒有它的工作

Failed examples: 

rspec ./spec/controllers/pages_controller_spec.rb:21 # PagesController GET 'about' returns http success 

Randomized with seed 15477 

這裏是我的pages_controller_spec.rb:

require 'spec_helper' 

describe PagesController do 
    render_views 

    describe "GET 'home'" do 
    it "returns http success" do 
     get 'home' 
     response.should be_success 
    end 
    end 

    describe "GET 'contact'" do 
    it "returns http success" do 
     get 'contact' 
     response.should be_success 
    end 
    end 

    describe "GET 'about'" do 
    it "returns http success" do 
     get 'about' 
     response.should be_success 
    end 
    end 

end 

添加了此行的routes.rb:

get "pages/about" 

該行添加到pages_controller .rb:

def about 
    end 

並在views文件夾中添加about.html.erb。

另外,url-localhost:3000/pages/about可以在瀏覽器中使用。 我不確定爲什麼這個例子失敗。

+0

是否沒有堆棧跟蹤? – varatis

+0

你使用'spork'嗎? – prusswan

+0

我不太確定如何獲取堆棧跟蹤。該頁面將在瀏覽器中顯示。就像我說的,我是RoR的新手。 –

回答

1

如果您已經在運行spork並嘗試對路由進行更改,則只有在spork重新啓動之後,纔會反映這些更改。這很可能是特定測試失敗的原因。

相關問題