Skip to content

Commit

Permalink
Better exception message on select options
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagopradi committed Sep 11, 2009
1 parent 8772505 commit b11fc98
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/webrat/core/locators/select_option_locator.rb
Expand Up @@ -43,7 +43,7 @@ def option_elements

def error_message
if @id_or_name_or_label
"The '#{@option_text}' option was not found in the #{@id_or_name_or_label.inspect} select box"
"The '#{@option_text}' option was not found in the #{@id_or_name_or_label.inspect} select box - The Available Options are: #{option_elements.collect{|j| j.inner_html}.join(' | ')}"
else
"Could not find option #{@option_text.inspect}"
end
Expand Down
3 changes: 2 additions & 1 deletion spec/public/select_spec.rb
Expand Up @@ -6,12 +6,13 @@
<html>
<form method="get" action="/login">
<select name="month"><option value="1">January</option></select>
<select name="month"><option value="1">March</option></select>
</form>
</html>
HTML

lambda { select "February", :from => "month" }.should raise_error(Webrat::NotFoundError,
"The 'February' option was not found in the \"month\" select box")
"The 'February' option was not found in the \"month\" select box - The Available Options are: January | March")
end

it "should fail if option not found in list specified by element name" do
Expand Down

0 comments on commit b11fc98

Please sign in to comment.