[rspec-users] how to check for empty field value?
dchelimsky at gmail.com
Tue Dec 30 10:11:22 EST 2008
On Tue, Dec 30, 2008 at 8:34 AM, Jonathan Linowes
<jonathan at parkerhill.com> wrote:
> On Dec 30, 2008, at 12:56 AM, Josh Knowles wrote:
>> On Mon, Dec 29, 2008 at 10:59 PM, Jonathan Linowes
>> <jonathan at parkerhill.com> wrote:
>>> # Then /^the email_confirmation field should be cleared$/ do
>>> # #how to write this ????
>>> # #selector( "input[name=user[email_confirmation]")[:value].should
>>> # end
>> Are you using Webrat? If so try:
>> field_labeled("Email Confirmation").value.should be_nil
> I'll try that, but by the method name, I assume it looks for a <label> tag
> for the field rather than the name attribute of the <input> ?
That is correct, and encourages a good habit of associating labels
with input fields in the HTML. That way, steps can say things like
"the Email Confirmation field should be empty" instead of "the
email_confirmation field should be empty."
If you don't want to be encouraged to do that, you can use this instead:
or some such.
>> Josh Knowles
>> phone: 509-979-1593
>> email: joshknowles at gmail.com
>> web: http://joshknowles.com
>> rspec-users mailing list
>> rspec-users at rubyforge.org
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users