10
私はCucumberとWebrat with Railsを学んでいて、 "編集"フォームをテストする最善の方法についてアドバイスをしたいと思います。ユーザーのプロフィールを参照すると、ユーザーの情報がフォームフィールドにあらかじめ入力された編集フォームが表示されます。フィールドには実際に私が期待する情報が含まれていることをテストできるようにしたいと思います。CucumberとWebratを使用してフォームに値があらかじめ入力されていることを確認するにはどうすればよいですか?
Scenario: View My Profile
Given I am logged in as "Mike" with password "secret"
When I go to my profile page
Then I should see "Mike" in the "Login" field
And I should see "[email protected]" in the "Email" field
And I should see a blank "Password" field
And I should see a blank "Password confirmation" field
キュウリが正しく、私に語った、私は次のカスタム手順を定義する必要があります:ここに私のシナリオです
Then /^I should see "([^\"]*)" in the "([^\"]*)" field$/ do |arg1, arg2|
pending
end
Then /^I should see a blank "([^\"]*)" field$/ do |arg1|
pending
end
私はこれらの手順を評価する実装するいくつかの厄介な正規表現を把握することができます確信しています私ができることはすでに存在しているか、よりエレガントなものがなければならないと感じています。フォームフィールドにあらかじめデータが入力されているフォームをどのように評価しますか?ダン
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
field_labeled(field).value.should =~ /#{value}/
end
: – SingleShot