5

次の問題に悩まされています。カピバラを使用するのはこれが初めてです。この問題を解決する方法を教えてください。ありがとう

Rails 3.0.0 と以下の gem を使用しています

gem 'rails', '3.0.0'
gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails'
gem 'cucumber'
gem 'rspec-rails'
gem 'spork'
gem 'launchy'

私のシナリオには次のものがあります

When I go to the new customer page
And I fill in "Email" with "john@example.com"

私のcustomer_steps.rbには

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

私からしてみれば

- form_for @customer do |f|
  = f.label :email, 'Email'
  = f.text_field :email
  = f.submit

シナリオを実行すると、このエラー メッセージが表示されます

 Scenario: Register new customer                  # features/manage_customers.feature:7
    When I go to the new customer page             # features/step_definitions/customer_steps.rb:1
    And I fill in "Email" with "john@example.com"  # features/step_definitions/customer_steps.rb:5
      cannot fill in, no text field, text area or password field with id, name, or label 'Email' found (Capybara::ElementNotFound)
      ./features/step_definitions/customer_steps.rb:6:in `/^I fill in "([^"]*)" with "([^"]*)"$/'
      features/manage_customers.feature:9:in `And I fill in "Email" with "john@example.com"'
4

2 に答える 2

4

間違いを見つけました!!!

When I go to the new customer page

ステップの前に

When /^I go to (.+)$/ do |page_name|
  path_to page_name 
end

訪問を忘れました...

When /^I go to (.+)$/ do |page_name|
  visit path_to(page_name) 
end
于 2010-09-05T17:08:10.260 に答える
2

代わりにこのフィールドの id を使用してください。

そして、「customer_email」に「john@example.com」を入力します

@customer がオブジェクト カスタマー モデルの場合

于 2010-09-04T22:35:17.207 に答える