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
Fixed bug where choosing radio button in a series where a later radio button is 
defaulted to on resulted in the incorrect field value being submitted.
lukemelia (author)
Sun Sep 14 18:16:39 -0700 2008
commit  7c46a6fed0fe1b5ff4319515b6eeb60464133ce5
tree    bc6603ce59faea0559bd5a2481748d54d6a1ea66
parent  f904be9b2ce8260e61dd1eeb66d4ba6605ca4f2b
...
213
214
215
216
 
217
218
219
...
213
214
215
 
216
217
218
219
0
@@ -213,7 +213,7 @@ module Webrat
0
     
0
     def choose
0
       other_options.each do |option|
0
-        option.unset
0
+        option.set(nil)
0
       end
0
       
0
       set(@element["value"] || "on")
...
77
78
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
...
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
0
@@ -77,4 +77,19 @@ describe "chooses" do
0
     @session.should_receive(:post).with("/login", "first_option" => "on")
0
     @session.clicks_button
0
   end
0
+  
0
+  it "should result in the value of the selected radio button being posted when a subsequent one is checked by default" do
0
+    @session.response_body = <<-EOS
0
+      <form method="post" action="/login">
0
+        <input id="user_gender_male" name="user[gender]" type="radio" value="M" />
0
+        <label for="user_gender_male">Male</label>
0
+        <input id="user_gender_female" name="user[gender]" type="radio" value="F" checked="checked" />
0
+        <label for="user_gender_female">Female</label>
0
+        <input type="submit" />
0
+      </form>
0
+    EOS
0
+    @session.should_receive(:post).with("/login", "user" => {"gender" => "M"})
0
+    @session.chooses "Male"
0
+    @session.clicks_button
0
+  end
0
 end

Comments