3

Does anyone know how to assert that a checkbox or input is disabled? I can't find anything to indicated that this is supported I'm writing cucumber tests with webrat and test/unit.

I'd like to have a step that is able to assert_disabled :some_checkbox || assert_disabled :some_input.

Or some way that I can check a property of the checkbox.

Rimian
  • 36,864
  • 16
  • 117
  • 117
brad
  • 31,987
  • 28
  • 102
  • 155

4 Answers4

4
Then /^the "([^\"]*)" field should be disabled$/ do |label|
  field_labeled(label).should be_disabled
end

should do it for you.

Pete Hodgson
  • 15,644
  • 5
  • 38
  • 46
3

This probably wont help you with Webrat and Test/Unit, but for people using Capybara, you can use

Then /^the "([^\"]+)" field should be disabled$/ do |field|
  find_field(field)[:disabled].should == 'disabled'
end
Ryan Ahearn
  • 7,886
  • 7
  • 51
  • 56
0

You could give this a go:

Then /^the "([^\"]*)" field should be disabled$/ do |label|
  field_labeled(label)['disabled'].should == true
end
Vijay
  • 36
  • 4
0

I got Pete's answer to work but had to switch to field_with_id.

field_with_id(label).should be_disabled
alan
  • 187
  • 1
  • 3
  • 12