From c51a232bbcfbbd8f90e0a9abaf222a016ae42898 Mon Sep 17 00:00:00 2001 From: Jo Liss Date: Fri, 8 Jul 2011 12:48:25 +0200 Subject: [PATCH] Fix rack-test to ignore maxlength="", closes #396 --- lib/capybara/rack_test/node.rb | 5 ++++- lib/capybara/spec/views/form.erb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/capybara/rack_test/node.rb b/lib/capybara/rack_test/node.rb index 8dbf142ee..3dd3e33af 100644 --- a/lib/capybara/rack_test/node.rb +++ b/lib/capybara/rack_test/node.rb @@ -23,7 +23,10 @@ def set(value) native.remove_attribute('checked') end elsif tag_name == 'input' - if (type == 'text' || type == 'password') && self[:maxlength] + if (type == 'text' || type == 'password') && self[:maxlength] && + !self[:maxlength].empty? + # Browser behavior for maxlength="0" is inconsistent, so we stick with + # Firefox, allowing no input value = value[0...self[:maxlength].to_i] end native['value'] = value.to_s diff --git a/lib/capybara/spec/views/form.erb b/lib/capybara/spec/views/form.erb index 9ed9a1069..de6f8520e 100644 --- a/lib/capybara/spec/views/form.erb +++ b/lib/capybara/spec/views/form.erb @@ -50,7 +50,7 @@