如何检查一个形式预填充用黄瓜和Webrat值?
-
13-09-2019 - |
题
我学习黄瓜和Webrat与Rails和想在测试的“编辑”形式的最佳途径一些建议。当我浏览到用户的个人资料,我提出了与用户的信息预填充表单字段编辑表单。我想是能够测试领域做其实包含我期望的信息。这里是我的情况:
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 "mike@email.com" 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
我敢肯定,我可以找出一些讨厌的正则表达式来执行评估这些步骤,但我觉得一定有什么东西已经存在的或者更加优雅,我可以做。你如何评价与数据表单字段中预先填充?
形式解决方案
有一个在功能/ step_definitions / webrat_steps.rb,下面的步骤定义看起来像你正在寻找什么:
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
field_labeled(field).value.should =~ /#{value}/
end
不隶属于 StackOverflow