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
Add set_hidden_field and submit_form methods ND/BH
brynary (author)
Mon Nov 17 11:21:16 -0800 2008
commit  5ee4357cd69fb14057729301a8b6328efca60134
tree    ae1d42a5be5503758f5794cac0abb87cecacf296
parent  3abaa924cc289dde19e004ae27292d0159e2b606
...
74
75
76
 
 
 
 
77
78
79
...
74
75
76
77
78
79
80
81
82
83
0
@@ -74,6 +74,10 @@ module Webrat
0
       labels.detect { |label| label.matches_text?(label_text) }
0
     end
0
     
0
+    def matches_id?(id)
0
+      @element["id"] == id.to_s
0
+    end
0
+    
0
   protected
0
   
0
     def fields_by_type(field_types)
...
44
45
46
 
 
 
 
 
47
48
49
...
256
257
258
 
 
 
 
 
259
260
261
...
44
45
46
47
48
49
50
51
52
53
54
...
261
262
263
264
265
266
267
268
269
270
271
0
@@ -44,6 +44,11 @@ module Webrat
0
 
0
     alias_method :fills_in, :fill_in
0
     
0
+    def set_hidden_field(field_locator, options = {})
0
+      field = locate_field(field_locator, HiddenField)
0
+      field.set(options[:to])
0
+    end
0
+    
0
     # Verifies that an input checkbox exists on the current page and marks it
0
     # as checked, so that the value will be submitted with the form.
0
     #
0
@@ -256,6 +261,11 @@ module Webrat
0
 
0
     alias_method :clicks_button, :click_button
0
     
0
+    def submit_form(id)
0
+      form = forms.detect { |f| f.matches_id?(id) }
0
+      form.submit
0
+    end
0
+    
0
     def dom # :nodoc:
0
       return @dom if @dom
0
       
...
180
181
182
 
 
183
184
185
...
180
181
182
183
184
185
186
187
0
@@ -180,6 +180,8 @@ module Webrat
0
     end
0
     
0
     def_delegators :current_scope, :fill_in,            :fills_in
0
+    def_delegators :current_scope, :set_hidden_field
0
+    def_delegators :current_scope, :submit_form
0
     def_delegators :current_scope, :check,              :checks
0
     def_delegators :current_scope, :uncheck,            :unchecks
0
     def_delegators :current_scope, :choose,             :chooses

Comments