Fix bug with empty select list
This commit is contained in:
parent
275611a0a3
commit
f9ff509f02
@ -237,6 +237,7 @@ module Webrat
|
|||||||
selected_options = @element / "option[@selected='selected']"
|
selected_options = @element / "option[@selected='selected']"
|
||||||
selected_options = @element / "option:first" if selected_options.empty?
|
selected_options = @element / "option:first" if selected_options.empty?
|
||||||
selected_options.map do |option|
|
selected_options.map do |option|
|
||||||
|
return "" if option.nil?
|
||||||
option["value"] || option.innerHTML
|
option["value"] || option.innerHTML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,6 +56,17 @@ class SelectsTest < Test::Unit::TestCase
|
|||||||
@session.selects "January", :from => "month"
|
@session.selects "January", :from => "month"
|
||||||
@session.clicks_button
|
@session.clicks_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_should_work_with_empty_select_lists
|
||||||
|
@response.stubs(:body).returns(<<-EOS)
|
||||||
|
<form method="post" action="/login">
|
||||||
|
<select name="month"></select>
|
||||||
|
<input type="submit" />
|
||||||
|
</form>
|
||||||
|
EOS
|
||||||
|
@session.expects(:post_via_redirect).with("/login", 'month' => '')
|
||||||
|
@session.clicks_button
|
||||||
|
end
|
||||||
|
|
||||||
def test_should_work_without_specifying_the_field_name_or_label
|
def test_should_work_without_specifying_the_field_name_or_label
|
||||||
@response.stubs(:body).returns(<<-EOS)
|
@response.stubs(:body).returns(<<-EOS)
|
||||||
|
Loading…
Reference in New Issue
Block a user