2010-11-26 29 views
0

我定義了一個在wsp_controller稱爲定位功能:的Rails 3 - 渲染布局腐化測試

def location 
    @title ="Edit account" 
    @page_name = "edit" 
    end 

,它工作正常。但是當我嘗試渲染這樣的佈局時:

def location 
    @title ="Edit account" 
    @page_name = "edit" 
    render :layout => 'signup_login' 
    end 

RSpec測試開始失敗。然而,該應用程序做了什麼,但測試失敗。 我有佈局的JavaScript代碼,當我去/位置時,如果我把JavaScript的應用程序佈局,它的工作原理(測試和應用程序),但是沒有必要把它放在那裏,所以我想一個新的佈局並渲染它。

我該怎麼做?

編輯:下面是我在routes.rb中

match '/wsps/:id/location', :to =>'wsps#location' 

感謝。

編輯:

RSpec的錯誤的部分:

Failures: 
    1) WspsController GET 'index' for non-signed-in wsps should deny access to 'index' 
    Failure/Error: get :index 
    You have a nil object when you didn't expect it! 
    You might have expected an instance of ActiveRecord::Base. 
    The error occurred while evaluating nil.errors 

它簡單不,當我呈現佈局通過測試。但只有這種方法。

+0

失敗消息在您的Rspec測試上說了些什麼? – jergason 2010-11-27 02:09:24

回答

0

您可能需要提供一些關於您遇到的故障的更多信息。你提到你需要在頁面呈現時運行javascript嗎?不要忘記,在功能測試中,頁面呈現爲html,但沒有使用真正的瀏覽器,所以沒有運行javascript。對於涉及JavaScript的測試,您應該看看類似Cucumber的內容來定義一些驗收測試,並結合使用Watir或Selenium來驅動瀏覽器。

+0

我添加了更多信息。謝謝 – donald 2010-11-27 14:17:53