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
Raise Webrat::NotFoundErrors instead of RuntimeErrors to make error catching 
easier
brynary (author)
Tue Nov 18 17:55:55 -0800 2008
commit  10d5d7695f2754637912608aa2707d65dae9602b
tree    5289b3e93d14988324f4e54ecabf2d07f60c3f25
parent  df9d8179c0d8ed2061c5f91a9dd55d8c86fc5e26
...
2
3
4
5
6
7
8
...
2
3
4
 
5
6
7
0
@@ -2,7 +2,6 @@ require "webrat/core/configuration"
0
 require "webrat/core/xml"
0
 require "webrat/core/nokogiri"
0
 require "webrat/core/logging"
0
-require "webrat/core/flunk"
0
 require "webrat/core/form"
0
 require "webrat/core/scope"
0
 require "webrat/core/link"
...
8
9
10
11
 
12
13
14
15
16
 
17
18
19
20
21
 
22
23
24
25
26
 
27
28
29
...
56
57
58
59
 
60
61
62
...
67
68
69
70
 
71
72
73
74
75
76
 
77
78
79
...
84
85
86
87
 
88
89
90
...
93
94
95
96
 
97
98
99
...
8
9
10
 
11
12
13
14
15
 
16
17
18
19
20
 
21
22
23
24
25
 
26
27
28
29
...
56
57
58
 
59
60
61
62
...
67
68
69
 
70
71
72
73
74
75
 
76
77
78
79
...
84
85
86
 
87
88
89
90
...
93
94
95
 
96
97
98
99
0
@@ -8,22 +8,22 @@ module Webrat
0
       find_field_with_id(*args) ||
0
       find_field_named(*args)   ||
0
       field_labeled(*args)      ||
0
-      flunk("Could not find field: #{args.inspect}")
0
+      raise(NotFoundError.new("Could not find field: #{args.inspect}"))
0
     end
0
     
0
     def field_labeled(label, *field_types)
0
       find_field_labeled(label, *field_types) ||
0
-      flunk("Could not find field labeled #{label.inspect}")
0
+      raise(NotFoundError.new("Could not find field labeled #{label.inspect}"))
0
     end
0
 
0
     def field_named(name, *field_types)
0
       find_field_named(name, *field_types) ||
0
-      flunk("Could not find field named #{name.inspect}")
0
+      raise(NotFoundError.new("Could not find field named #{name.inspect}"))
0
     end
0
     
0
     def field_with_id(id, *field_types)
0
       find_field_with_id(id, *field_types) ||
0
-      flunk("Could not find field with id #{id.inspect}")
0
+      raise(NotFoundError.new("Could not find field with id #{id.inspect}"))
0
     end
0
     
0
     def find_field_labeled(label, *field_types) #:nodoc:
0
@@ -56,7 +56,7 @@ module Webrat
0
         return select_option if select_option
0
       end
0
         
0
-      flunk("Could not find option #{option_text.inspect}")
0
+      raise NotFoundError.new("Could not find option #{option_text.inspect}")
0
     end
0
     
0
     def find_button(value) #:nodoc:
0
@@ -67,13 +67,13 @@ module Webrat
0
       if button
0
         return button
0
       else
0
-        flunk("Could not find button #{value.inspect}")
0
+        raise NotFoundError.new("Could not find button #{value.inspect}")
0
       end
0
     end
0
     
0
     def find_area(area_name) #:nodoc:
0
       areas.detect { |area| area.matches_text?(area_name) } ||
0
-      flunk("Could not find area with name #{area_name}")
0
+      raise(NotFoundError.new("Could not find area with name #{area_name}"))
0
     end
0
     
0
     def find_link(text_or_title_or_id) #:nodoc:
0
@@ -84,7 +84,7 @@ module Webrat
0
       if matching_links.any?
0
         matching_links.min { |a, b| a.text.length <=> b.text.length }
0
       else
0
-        flunk("Could not find link with text or title or id #{text_or_title_or_id.inspect}")
0
+        raise NotFoundError.new("Could not find link with text or title or id #{text_or_title_or_id.inspect}")
0
       end
0
     end
0
 
0
@@ -93,7 +93,7 @@ module Webrat
0
       if label
0
         label.for_id
0
       else
0
-        flunk("Could not find the label with text #{label_text}")
0
+        raise NotFoundError.new("Could not find the label with text #{label_text}")
0
       end
0
     end
0
     
...
2
3
4
 
 
 
5
6
7
8
9
10
...
96
97
98
99
 
100
101
102
...
131
132
133
134
 
135
136
137
...
165
166
167
168
 
169
170
171
...
2
3
4
5
6
7
8
9
 
10
11
12
...
98
99
100
 
101
102
103
104
...
133
134
135
 
136
137
138
139
...
167
168
169
 
170
171
172
173
0
@@ -2,9 +2,11 @@ require "webrat/core/form"
0
 require "webrat/core/locators"
0
 
0
 module Webrat
0
+  class NotFoundError < WebratError
0
+  end
0
+  
0
   class Scope
0
     include Logging
0
-    include Flunk
0
     include Locators
0
     
0
     def self.from_page(session, response, response_body) #:nodoc:
0
@@ -96,7 +98,7 @@ module Webrat
0
         option.choose
0
       else
0
         select_box_text = options[:from] ? " in the '#{options[:from]}' select box" : '' 
0
-        flunk("The '#{option_text}' option was not found#{select_box_text}") 
0
+        raise NotFoundError.new("The '#{option_text}' option was not found#{select_box_text}") 
0
        end
0
     end
0
 
0
@@ -131,7 +133,7 @@ module Webrat
0
       
0
       id_prefix = locate_id_prefix(options) do
0
         year_field = find_field_with_id(/(.*?)_#{DATE_TIME_SUFFIXES[:year]}$/)
0
-        flunk("No date fields were found") unless year_field && year_field.id =~ /(.*?)_1i/
0
+        raise NotFoundError.new("No date fields were found") unless year_field && year_field.id =~ /(.*?)_1i/
0
         $1
0
       end
0
         
0
@@ -165,7 +167,7 @@ module Webrat
0
 
0
       id_prefix = locate_id_prefix(options) do
0
         hour_field = find_field_with_id(/(.*?)_#{DATE_TIME_SUFFIXES[:hour]}$/)
0
-        flunk("No time fields were found") unless hour_field && hour_field.id =~ /(.*?)_4i/
0
+        raise NotFoundError.new("No time fields were found") unless hour_field && hour_field.id =~ /(.*?)_4i/
0
         $1
0
       end
0
         

Comments