How to check for empty field value?


#1

Then /^the email_confirmation field should be cleared$/ do

#how to write this ???

#selector( “input[name=user[email_confirmation]”)[:value].should

be_blank

end


#2

On Mon, Dec 29, 2008 at 10:59 PM, Jonathan L.
removed_email_address@domain.invalid wrote:

Then /^the email_confirmation field should be cleared$/ do

#how to write this ???

#selector( “input[name=user[email_confirmation]”)[:value].should

be_blank

end

Are you using Webrat? If so try:

field_labeled(“Email Confirmation”).value.should be_nil


Josh K.
phone: 509-979-1593
email: removed_email_address@domain.invalid
web: http://joshknowles.com


#3

I’ll try that, but by the method name, I assume it looks for a
tag for the field rather than the name attribute of the
?


#4

On Tue, Dec 30, 2008 at 8:34 AM, Jonathan L.
removed_email_address@domain.invalid wrote:

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 tag
for the field rather than the name attribute of the ?

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:

field_with_id(‘user_email_confirmation’).value.should be_blank

or some such.

HTH,
David