diff --git a/lib/webrat/sinatra.rb b/lib/webrat/sinatra.rb index d2f69a4..e71bba5 100644 --- a/lib/webrat/sinatra.rb +++ b/lib/webrat/sinatra.rb @@ -20,6 +20,7 @@ module Webrat %w(get head post put delete).each do |verb| define_method(verb) do |*args| # (path, data, headers = nil) path, data, headers = *args + data = data.inject({}) {|data, (key,value)| data[key] = Rack::Utils.unescape(value); data } params = data.merge(:env => headers || {}) self.__send__("#{verb}_it", path, params) end diff --git a/spec/integration/sinatra/app.rb b/spec/integration/sinatra/app.rb index 4efcc21..2fbb706 100644 --- a/spec/integration/sinatra/app.rb +++ b/spec/integration/sinatra/app.rb @@ -17,6 +17,7 @@ end post "/go" do @user = params[:name] + @email = params[:email] erb :hello end @@ -36,10 +37,17 @@ __END__ @@ go
- - +
+ + +
+
+ + +
@@ hello -

Hello, <%= @user %>

\ No newline at end of file +

Hello, <%= @user %>

+

Your email is: <%= @email %>

\ No newline at end of file diff --git a/spec/integration/sinatra/test/webrat_test.rb b/spec/integration/sinatra/test/webrat_test.rb index b62ecf1..ad5feb8 100644 --- a/spec/integration/sinatra/test/webrat_test.rb +++ b/spec/integration/sinatra/test/webrat_test.rb @@ -12,9 +12,11 @@ class WebratTest < Test::Unit::TestCase def test_submits_form visit "/go" fill_in "Name", :with => "World" + fill_in "Email", :with => "world@example.org" click_button "Submit" assert response_body.include?("Hello, World") + assert response_body.include?("Your email is: world@example.org") end def test_follows_redirects