2010-11-26 32 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