2011-02-01 58 views
0

我正在开发Rails开发,并试图设置一个使用RSpec和Cucumber进行测试的Rails 3网站。response.should render_template不能在黄瓜辅助文件中使用rails 3

对于Cucumber的设置,我利用了我以前工作过的一个帮助文件(我不是开发人员,但是参与了编写测试和小小的调整)。

我试图让去简单的情形是这样的:

Scenario: 1. Load the home page 
    When I browse to the 'home' page 
    Then I should see the 'home' page 

这依赖于从黄瓜的辅助文件如下:

Then "I should see the '$page_name' page" do |page_name| 
    if SITE_PAGES[page_name] 
     response.should render_template SITE_PAGES[page_name][:template] 
    else 
     raise "step_definitions/helper.rb: I couldn't find the page you requested" 
    end 
end 

当运行特征,虽然我得到的以下错误:

undefined method `render_template' for #<Cucumber::Rails::World:0x..fdb7fbf9c> (NoMethodError) 
./features/support/helper.rb:97:in `/^I\ should\ see\ the\ '(.*)'\ page$/' 
features/pages.feature:8:in `Then I should see the 'home' page' 

这是Rails 3的问题吗?我发现这个链接提到它已被弃用的最新版本的Rails。这是我的问题还是我完全偏离轨道?

render_template API

在此先感谢。

+0

我得到的“错误response.body.should = 〜/#{text}/m“(未定义的方法体),所以我猜测某些东西根本不对,而不是render_template特定的。 – alan 2011-02-02 06:57:00

回答

0

好吧,我是冲洗。旧帮手文件是为webrat编写的。由于我的新安装是黄瓜/水豚,一些东西不会工作。

哦,不过如果你收到此错误:

undefined local variable or method `node' 

然后参考这篇文章:

Cucumber/Capybara test no longer run in Rails 3 project