diff --git a/lib/capybara/session.rb b/lib/capybara/session.rb index eeacc069..77d47f7b 100644 --- a/lib/capybara/session.rb +++ b/lib/capybara/session.rb @@ -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 diff --git a/lib/capybara/spec/session/fill_in_spec.rb b/lib/capybara/spec/session/fill_in_spec.rb index ddbe6dd3..b1974646 100644 --- a/lib/capybara/spec/session/fill_in_spec.rb +++ b/lib/capybara/spec/session/fill_in_spec.rb @@ -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 }