helpful error message for missing option values, closes #40
This commit is contained in:
parent
6cd76fa08e
commit
4dd1c4b62d
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
* Allow clicking links by id and id regexp (gaffo)
|
* Allow clicking links by id and id regexp (gaffo)
|
||||||
* Raise Webrat::PageLoadError when a failure occurs so that application exceptions can be more accurately tested (Ryan Briones)
|
* Raise Webrat::PageLoadError when a failure occurs so that application exceptions can be more accurately tested (Ryan Briones)
|
||||||
|
* Helpful error message for missing option in select box. (Ben Mabey, Ticket #40)
|
||||||
|
|
||||||
== 0.3.2 / 2008-11-08
|
== 0.3.2 / 2008-11-08
|
||||||
|
|
||||||
|
@ -87,7 +87,12 @@ module Webrat
|
|||||||
# selects "February", :from => "event_month"
|
# selects "February", :from => "event_month"
|
||||||
# selects "February", :from => "Event Month"
|
# selects "February", :from => "Event Month"
|
||||||
def selects(option_text, options = {})
|
def selects(option_text, options = {})
|
||||||
find_select_option(option_text, options[:from]).choose
|
if option = find_select_option(option_text, options[:from])
|
||||||
|
option.choose
|
||||||
|
else
|
||||||
|
select_box_text = options[:from] ? " in the '#{options[:from]}' select box" : ''
|
||||||
|
flunk("The '#{option_text}' option was not found#{select_box_text}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :select, :selects
|
alias_method :select, :selects
|
||||||
|
@ -7,14 +7,15 @@ describe "selects" do
|
|||||||
@session = Webrat::TestSession.new
|
@session = Webrat::TestSession.new
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail if option not found" do
|
it "should fail with a helpful message when option not found" do
|
||||||
@session.response_body = <<-EOS
|
@session.response_body = <<-EOS
|
||||||
<form method="get" action="/login">
|
<form method="get" action="/login">
|
||||||
<select name="month"><option value="1">January</option></select>
|
<select name="month"><option value="1">January</option></select>
|
||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
lambda { @session.selects "February", :from => "month" }.should raise_error
|
lambda { @session.selects "February", :from => "month" }.should raise_error(
|
||||||
|
Exception, "The 'February' option was not found in the 'month' select box")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail if option not found in list specified by element name" do
|
it "should fail if option not found in list specified by element name" do
|
||||||
|
Loading…
Reference in New Issue
Block a user