当我执行以下黄瓜脚本时:
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
我查看了功能/ support / env.rb ,似乎需要正确使用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
有什么想法吗?
答案 0 :(得分:2)
web_steps.rb中的步骤需要fill in
之后的引用值,即您必须更改:
When I fill in Name with "Test Company"
到
When I fill in "Name" with "Test Company"
应该得到承认。