From 5bbcf7d6a00b1ec8bf2c8878117d4529bbf21f2a Mon Sep 17 00:00:00 2001
From: Anatoliy Lysenko
Date: Sun, 10 Oct 2010 11:18:21 +0300
Subject: [PATCH] Add test to check support of fields with complex names such
user[pictures][][path]. This test fail when use rack test driver. See
http://github.com/jnicklas/capybara/issues#issue/60
---
lib/capybara/spec/session.rb | 19 +++++++++++++++++++
lib/capybara/spec/views/form.erb | 18 ++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/lib/capybara/spec/session.rb b/lib/capybara/spec/session.rb
index b3d6569f..063ab2a4 100644
--- a/lib/capybara/spec/session.rb
+++ b/lib/capybara/spec/session.rb
@@ -68,6 +68,25 @@ shared_examples_for "session" do
it_should_behave_like "unselect"
it_should_behave_like "within"
it_should_behave_like "current_url"
+
+ it "should encode complex field names, like array[][value]" do
+ @session.visit('/form')
+ @session.fill_in('address1_city', :with =>'Paris')
+ @session.fill_in('address1_street', :with =>'CDG')
+ @session.fill_in('address2_city', :with => 'Mikolaiv')
+ @session.fill_in('address2_street', :with => 'PGS')
+ @session.click_button "awesome"
+
+ addresses=extract_results(@session)["addresses"]
+ addresses.should have(2).addresses
+
+ addresses[0]["street"].should == 'CDG'
+ addresses[0]["city"].should == 'Paris'
+
+ addresses[1]["street"].should == 'PGS'
+ addresses[1]["city"].should == 'Mikolaiv'
+ end
+
end
diff --git a/lib/capybara/spec/views/form.erb b/lib/capybara/spec/views/form.erb
index 875ee9a0..5825ff90 100644
--- a/lib/capybara/spec/views/form.erb
+++ b/lib/capybara/spec/views/form.erb
@@ -158,6 +158,24 @@
+
+
+ First address
+
+
+
+
+
+
+
+
+ Second address
+
+
+
+
+
+