2011-02-01 55 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