当我建立一个新的rails 3.1.3项目并用Webrat代码编写Cucumber故事时,如下所示:
response.should contain("abc")我运行rake cucumber,我得到:
undefined method `contain' for #<Cucumber::Rails::World:0x00000003d2c578> (NoMethodError)我认为Cucumber、Webrat或Rails都是坏的,因为我没有做什么特别的事情,而是坚持文档。
以下步骤再现错误:
rvm 1.9.2rails new testapp -d mysqlcd testapprake db:createrake db:migrategem install cucumber-railsgem install webratgem install database_cleaner `Feature: Create movie`Description
Scenario: Create a movie in genre
Given a genre named Comedy
When I create a movie Caddyshack in the Comedy genre
Then Caddyshack should be in the Comedy genre
_step s.rb内容:
`Given /^a genre named Comedy$/ do end`When /^I create a movie Caddyshack in the Comedy genre$/ do
end
Then /^Caddyshack should be in the Comedy genre$/ do
visit genres_path
response.should contain("abc")
end
rake cucumber)
rails 3.1.3
黄瓜1.1.4
黄瓜-rails 1.2.1
微管0.7.3
机架1.3.5
耙0.9.2.2
关于如何解决这个问题有什么提示吗?
发布于 2012-04-10 11:36:39
现在,在默认情况下,黄瓜使用凯布里而不是韦布拉特。
您需要使用have_content代替。
下面是正确的片段:
When /^I create a movie Caddyshack in the Comedy genre$/ do
end
Then /^Caddyshack should be in the Comedy genre$/ do
visit genres_path
response.should have_content("abc")
end发布于 2011-12-15 22:08:27
我刚刚收到了Cucumber (cukes) Google组的回复:
黄瓜-Rails在v0.5.0.beta 1中放弃了对Webrat的支持(见https://github.com/cucumber/cucumber-rails/blob/master/History.md)
使用Capybara代替.
https://stackoverflow.com/questions/8520655
复制相似问题