raising an error if someone forgets to provide a hash to fill_in

This commit is contained in:
Len Smith 2010-04-21 17:55:33 -04:00
parent 32b3b6a796
commit a550cc458a
2 changed files with 6 additions and 1 deletions

View File

@ -62,6 +62,7 @@ module Capybara
def fill_in(locator, options={})
msg = "cannot fill in, no text field, text area or password field with id, name, or label '#{locator}' found"
raise "Must pass a hash containing 'with'" unless options.kind_of? Hash && !options.index(:with).nil?
locate(:xpath, XPath.fillable_field(locator), msg).set(options[:with])
end

View File

@ -82,7 +82,11 @@ shared_examples_for "fill_in" do
@session.click_button('awesome')
extract_results(@session)['name'].should == 'Ford Prefect'
end
it "should throw an exception if a hash containing 'with' is not provided" do
lambda{@session.fill_in 'Name', 'ignu'}.should raise_error
end
context "with ignore_hidden_fields" do
before { Capybara.ignore_hidden_elements = true }
after { Capybara.ignore_hidden_elements = false }