2010-01-12 72 views
3

有谁知道如何断言复选框或输入被禁用?我找不到任何东西来表示这是支持的 我正在用webrat和测试/单元编写黄瓜测试。Ruby断言和禁用的输入

我想要一个能够assert_disabled的步骤:some_checkbox || assert_disabled:some_input。

或某种方式,我可以检查复选框的属性。

+1

我想没有人读,我使用的测试/单元 – brad 2010-10-21 13:56:16

回答

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

应该为你做。

0

你可以给这个一展身手:

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

我得到了皮特的回答工作,但不得不改用field_with_id。

field_with_id(label).should be_disabled 
3

这可能不会帮助你Webrat和测试/股,但对于利用水豚的人,你可以使用

Then /^the "([^\"]+)" field should be disabled$/ do |field| 
    find_field(field)[:disabled].should == 'disabled' 
end 
+0

这是唯一的解决方案,为我工作。谢谢! – Myxtic 2013-06-03 14:58:58