1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Add options for fill_in

This commit is contained in:
CJ Kihlbom and Jonas Nicklas 2013-02-24 16:41:20 +01:00
parent e67f7bf1c2
commit 1484902a0a
2 changed files with 16 additions and 1 deletions

View file

@ -49,7 +49,8 @@ module Capybara
#
def fill_in(locator, options={})
raise "Must pass a hash containing 'with'" if not options.is_a?(Hash) or not options.has_key?(:with)
find(:fillable_field, locator).set(options[:with])
with = options.delete(:with)
find(:fillable_field, locator, options).set(with)
end
##

View file

@ -138,4 +138,18 @@ Capybara::SpecHelper.spec "#fill_in" do
end.to raise_error(Capybara::ElementNotFound)
end
end
context "with :exact option" do
it "should accept partial matches when false" do
@session.fill_in("Explanation", :with => "Dude", :exact => false)
@session.click_button("awesome")
extract_results(@session)["name_explanation"].should == "Dude"
end
it "should not accept partial matches when true" do
expect do
@session.fill_in("Explanation", :with => "Dude", :exact => true)
end.to raise_error(Capybara::ElementNotFound)
end
end
end