Webrat (web_steps.rb) 未使用
当我执行以下黄瓜脚本时:
Feature: Manage Customers
In order to store customers
As a user
I want to create and manage customers
Scenario Outline: Create Customer
Given I am on new customer screen
When I fill in Name with "Test Company"
And I press "Create"
Then I should see "Customer created successfully"
我收到以下消息:
When /^I fill in Name with "([^"]*)"$/ do |arg1|
pending # express the regexp above with the code you wish you had
end
但是,我正在使用 webrat,它似乎无法识别 web_steps.rb 中的这一行:
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
fill_in(field, :with => value)
end
我检查了我的 features/support/env.rb< /strong> 和 webrat 似乎是正确需要的:
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/world'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'
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
有什么想法吗?
When I execute the following cucumber script:
Feature: Manage Customers
In order to store customers
As a user
I want to create and manage customers
Scenario Outline: Create Customer
Given I am on new customer screen
When I fill in Name with "Test Company"
And I press "Create"
Then I should see "Customer created successfully"
I get the following message:
When /^I fill in Name with "([^"]*)"$/ do |arg1|
pending # express the regexp above with the code you wish you had
end
However, I am using webrat and it doesn't appear to be recognizing this line in web_steps.rb:
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
fill_in(field, :with => value)
end
I checked my features/support/env.rb and webrat appears to be required properly:
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/world'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'
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
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
web_steps.rb 中的步骤需要在
fill in
之后有一个带引号的值,即您必须将:更改为
并且它应该被识别。
The step in web_steps.rb expects a quoted value after
fill in
, i.e. you have to change:to
and it should be recognized.