黄瓜 step_definitions 中未定义的 webrat 方法 [英] Undefined webrat methods in cucumber step_definitions

查看:14
本文介绍了黄瓜 step_definitions 中未定义的 webrat 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

When i run my features i get this error:

undefined method `visit' for #<Cucumber::Rails::World:0x81b17ac0> (NoMethodError)

This is the relevant part of my Gemfile.

group :development, :test do
  gem "rspec-rails", ">= 2.0.0.beta.19"
  gem "cucumber"
  gem "cucumber-rails", ">= 0.3.2"
  gem 'webrat', ">= 0.7.2.beta.1"
end

The relating step_definition (though i don't think it's important)

When /^I create a movie Caddyshack in the Comendy genre$/ do
  visit movies_path
  click_link "Add Movie"
  fill_in "Title", :with => "Caddyshack"
  check "Comedy"
  click_button "Save"
end

In the env.rb i have the following Webrat configuration:

# […]
require 'webrat'
require 'webrat/core/matchers'

Webrat.configure do |config|
  config.mode = :rails
  config.open_error_files = false # Set to true if you want error pages to pop up in the browser
end
# […]

Anything i am missing here?

解决方案

I had to set config.mode to :rack instead of :rails:

# […]
require 'webrat'
require 'webrat/core/matchers'

Webrat.configure do |config|
  config.mode = :rack
  config.open_error_files = false # Set to true if you want error pages to pop up in the browser
end
# […]

now works as expected.

这篇关于黄瓜 step_definitions 中未定义的 webrat 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆