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。這是我的問題還是我完全偏離軌道?
在此先感謝。
我得到的「錯誤response.body.should = 〜/#{text}/m「(未定義的方法體),所以我猜測某些東西根本不對,而不是render_template特定的。 – alan 2011-02-02 06:57:00