has_field? :with => foo works with textareas
This commit is contained in:
parent
95a63f8d30
commit
a0a249a0af
|
@ -76,6 +76,7 @@ module Capybara
|
|||
end
|
||||
|
||||
def text_area(locator, options={})
|
||||
options = options.merge(:text => options[:with]) if options.has_key?(:with)
|
||||
add_field(locator, "//textarea", options)
|
||||
end
|
||||
|
||||
|
@ -84,6 +85,7 @@ module Capybara
|
|||
end
|
||||
|
||||
def input_field(type, locator, options={})
|
||||
options = options.merge(:value => options[:with]) if options.has_key?(:with)
|
||||
add_field(locator, "//input[@type='#{type}']", options)
|
||||
end
|
||||
|
||||
|
@ -133,7 +135,8 @@ module Capybara
|
|||
def extract_postfix(options)
|
||||
options.inject("") do |postfix, (key, value)|
|
||||
case key
|
||||
when :with then postfix += "[@value=#{s(value)}]"
|
||||
when :value then postfix += "[@value=#{s(value)}]"
|
||||
when :text then postfix += "[text()=#{s(value)}]"
|
||||
when :checked then postfix += "[@checked]"
|
||||
when :unchecked then postfix += "[not(@checked)]"
|
||||
end
|
||||
|
|
|
@ -19,11 +19,13 @@ shared_examples_for "has_field" do
|
|||
@session.should have_field('First Name', :with => 'John')
|
||||
@session.should have_field('Phone', :with => '+1 555 7021')
|
||||
@session.should have_field('Street', :with => 'Sesame street 66')
|
||||
@session.should have_field('Description', :with => 'Descriptive text goes here')
|
||||
end
|
||||
|
||||
it "should be false if the given field is not on the page" do
|
||||
@session.should_not have_field('First Name', :with => 'Peter')
|
||||
@session.should_not have_field('Wrong Name', :with => 'John')
|
||||
@session.should_not have_field('Description', :with => 'Monkey')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -44,11 +46,13 @@ shared_examples_for "has_field" do
|
|||
@session.should_not have_no_field('First Name', :with => 'John')
|
||||
@session.should_not have_no_field('Phone', :with => '+1 555 7021')
|
||||
@session.should_not have_no_field('Street', :with => 'Sesame street 66')
|
||||
@session.should_not have_no_field('Description', :with => 'Descriptive text goes here')
|
||||
end
|
||||
|
||||
it "should be true if the given field is not on the page" do
|
||||
@session.should have_no_field('First Name', :with => 'Peter')
|
||||
@session.should have_no_field('Wrong Name', :with => 'John')
|
||||
@session.should have_no_field('Description', :with => 'Monkey')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue