2010-08-21 62 views
0

當我執行以下黃瓜腳本: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和它doesn」 Ť似乎承認這一行web_steps.rb:

When /^(?:|I)fill in "([^"]*)" with "([^"]*)"$/ do |field, value| 
    fill_in(field, :with => value) 
end 

我檢查了我功能/支持/ 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 

有什麼想法?

回答

2

在web_steps.rb步驟fill in後預計有引號值,即你必須改變:

When I fill in Name with "Test Company" 

When I fill in "Name" with "Test Company" 

,它應該得到承認。

+0

就是這樣!我不知道你必須使用引號。謝謝! – Rob 2010-08-21 15:43:32