From a550cc458a12080d054e22dd3f0b44d06a68935d Mon Sep 17 00:00:00 2001 From: Len Smith Date: Wed, 21 Apr 2010 17:55:33 -0400 Subject: [PATCH] raising an error if someone forgets to provide a hash to fill_in --- lib/capybara/session.rb | 1 + lib/capybara/spec/session/fill_in_spec.rb | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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 }