Cast to string if field has maxlength value, closes #989
This commit is contained in:
parent
c5e46fdcc8
commit
6ce45f2efb
|
@ -79,7 +79,7 @@ class Capybara::RackTest::Node < Capybara::Driver::Node
|
||||||
string_node.disabled?
|
string_node.disabled?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
native.path
|
native.path
|
||||||
end
|
end
|
||||||
|
@ -87,11 +87,11 @@ class Capybara::RackTest::Node < Capybara::Driver::Node
|
||||||
def find_xpath(locator)
|
def find_xpath(locator)
|
||||||
native.xpath(locator).map { |n| self.class.new(driver, n) }
|
native.xpath(locator).map { |n| self.class.new(driver, n) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_css(locator)
|
def find_css(locator)
|
||||||
native.css(locator, Capybara::RackTest::CSSHandlers.new).map { |n| self.class.new(driver, n) }
|
native.css(locator, Capybara::RackTest::CSSHandlers.new).map { |n| self.class.new(driver, n) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def ==(other)
|
def ==(other)
|
||||||
native == other.native
|
native == other.native
|
||||||
end
|
end
|
||||||
|
@ -153,7 +153,7 @@ private
|
||||||
if text_or_password? && attribute_is_not_blank?(:maxlength)
|
if text_or_password? && attribute_is_not_blank?(:maxlength)
|
||||||
# Browser behavior for maxlength="0" is inconsistent, so we stick with
|
# Browser behavior for maxlength="0" is inconsistent, so we stick with
|
||||||
# Firefox, allowing no input
|
# Firefox, allowing no input
|
||||||
value = value[0...self[:maxlength].to_i]
|
value = value.to_s[0...self[:maxlength].to_i]
|
||||||
end
|
end
|
||||||
if Array === value #Assert multiple attribute is present
|
if Array === value #Assert multiple attribute is present
|
||||||
value.each do |v|
|
value.each do |v|
|
||||||
|
|
|
@ -109,6 +109,12 @@ Capybara::SpecHelper.spec "#fill_in" do
|
||||||
extract_results(@session)['first_name'].should == 'Harry'
|
extract_results(@session)['first_name'].should == 'Harry'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "casts to string if field has maxlength", :focus => true do
|
||||||
|
@session.fill_in(:'form_zipcode', :with => 1234567)
|
||||||
|
@session.click_button('awesome')
|
||||||
|
extract_results(@session)['zipcode'].should == '12345'
|
||||||
|
end
|
||||||
|
|
||||||
context 'on a pre-populated textfield with a reformatting onchange', :requires => [:js] do
|
context 'on a pre-populated textfield with a reformatting onchange', :requires => [:js] do
|
||||||
it 'should only trigger onchange once' do
|
it 'should only trigger onchange once' do
|
||||||
@session.visit('/with_js')
|
@session.visit('/with_js')
|
||||||
|
|
Loading…
Reference in New Issue