public
Description: Webrat - Ruby Acceptance Testing for Web applications
Homepage: http://gitrdoc.com/brynary/webrat/tree/master/
Clone URL: git://github.com/brynary/webrat.git
Unescape the values passed to the sinatra test helpers
foca (author)
Thu Jan 01 06:42:05 -0800 2009
joshknowles (committer)
Sun Jan 04 19:36:21 -0800 2009
commit  4565a3cea641b79a77661b4bda6d3b21f7644886
tree    72179368207c4ffba6b6f28cb7d8efc4b25eeb50
parent  34ea3e64b896424b5aa1195610d5e61e5be466cf
...
20
21
22
 
23
24
25
...
20
21
22
23
24
25
26
0
@@ -20,6 +20,7 @@ module Webrat
0
     %w(get head post put delete).each do |verb|
0
       define_method(verb) do |*args| # (path, data, headers = nil)
0
         path, data, headers = *args
0
+        data = data.inject({}) {|data, (key,value)| data[key] = Rack::Utils.unescape(value); data }
0
         params = data.merge(:env => headers || {})
0
         self.__send__("#{verb}_it", path, params)
0
       end
...
17
18
19
 
20
21
22
...
36
37
38
39
40
 
 
 
 
 
 
 
 
41
42
43
44
45
46
 
 
47
...
17
18
19
20
21
22
23
...
37
38
39
 
 
40
41
42
43
44
45
46
47
48
49
50
51
 
52
53
54
55
0
@@ -17,6 +17,7 @@ end
0
  
0
 post "/go" do
0
   @user = params[:name]
0
+  @email = params[:email]
0
   erb :hello
0
 end
0
  
0
@@ -36,10 +37,17 @@ __END__
0
  
0
 @@ go
0
 <form method="post" action="/go">
0
-  <label for="name">Name</label>
0
-  <input type="text" name="name" id="name">
0
+  <div>
0
+    <label for="name">Name</label>
0
+    <input type="text" name="name" id="name">
0
+  </div>
0
+  <div>
0
+    <label for="email">Email</label>
0
+    <input type="text" name="email" id="email">
0
+  </div>
0
   <input type="submit" value="Submit" />
0
 </form>
0
  
0
 @@ hello
0
-<p>Hello, <%= @user %></p>
0
\ No newline at end of file
0
+<p>Hello, <%= @user %></p>
0
+<p>Your email is: <%= @email %></p>
0
\ No newline at end of file
...
12
13
14
 
15
16
17
 
18
19
20
...
12
13
14
15
16
17
18
19
20
21
22
0
@@ -12,9 +12,11 @@ class WebratTest < Test::Unit::TestCase
0
   def test_submits_form
0
     visit "/go"
0
     fill_in "Name", :with => "World"
0
+    fill_in "Email", :with => "world@example.org"
0
     click_button "Submit"
0
     
0
     assert response_body.include?("Hello, World")
0
+    assert response_body.include?("Your email is: world@example.org")
0
   end
0
   
0
   def test_follows_redirects

Comments