public
Description: Webrat - Ruby Acceptance Testing for Web applications
Homepage: http://www.brynary.com/uploads/webrat/rdoc/index.html
Clone URL: git://github.com/brynary/webrat.git
Basic spike of WWW:Mechanize support
brynary (author)
Sun May 11 21:23:37 -0700 2008
commit  5bb3026dafc7e32f1a2ea2197a5183e05c97f9a3
tree    86264f360b8e2dd388292e11ff752322b6855e97
parent  cf6b9d26c08acac09d09a70727c1439a2eb8466a
...
12
13
14
 
15
16
17
...
12
13
14
15
16
17
18
0
@@ -12,6 +12,7 @@
0
 
0
   * Fix bug with empty select list option (Patch from Kyle Hargraves)
0
   * Fix regression of not sending default values in password fields
0
+ * Don't explode if encountering inputs with no type attribute (assume text)
0
   
0
 == 0.2.0 / 2008-04-04
0
 
...
56
57
58
59
 
60
61
62
...
56
57
58
 
59
60
61
62
0
@@ -56,7 +56,7 @@ end
0
 
0
 require 'spec/rake/verify_rcov'
0
 RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
0
- t.threshold = 91.4 # Make sure you have rcov 0.7 or higher!
0
+ t.threshold = 95.7 # Make sure you have rcov 0.7 or higher!
0
 end
0
 
0
 remove_task "default"
...
2
3
4
 
 
 
5
6
 
...
2
3
4
5
6
7
8
 
9
0
@@ -2,5 +2,8 @@ module Webrat
0
   VERSION = '0.2.1'
0
 end
0
 
0
+require "rubygems"
0
+require "active_support"
0
+
0
 require File.dirname(__FILE__) + "/webrat/core"
0
-require File.dirname(__FILE__) + "/webrat/rails"
0
+require File.dirname(__FILE__) + "/webrat/rails" if defined?(RAILS_ENV)
...
6
7
8
9
 
10
11
12
...
93
94
95
 
 
96
97
98
...
6
7
8
 
9
10
11
12
...
93
94
95
96
97
98
99
100
0
@@ -6,7 +6,7 @@ module Webrat
0
         if %w[submit image].include?(element["type"])
0
           field_class = "button"
0
         else
0
- field_class = element["type"]
0
+ field_class = element["type"] || "text"
0
         end
0
       else
0
         field_class = element.name
0
@@ -93,6 +93,8 @@ module Webrat
0
       if defined?(CGIMethods)
0
         CGIMethods
0
       else
0
+ require "action_controller"
0
+ require "action_controller/integration"
0
         ActionController::AbstractRequest
0
       end
0
     end
...
 
1
2
3
...
105
106
107
108
 
109
110
111
112
 
 
 
 
113
114
 
 
115
116
117
...
256
257
258
259
260
261
262
263
264
265
266
267
268
269
...
1
2
3
4
...
106
107
108
 
109
110
 
 
 
111
112
113
114
115
 
116
117
118
119
120
...
259
260
261
 
262
263
264
 
 
 
 
265
266
267
0
@@ -1,3 +1,4 @@
0
+require "rubygems"
0
 require "hpricot"
0
 require "English"
0
 
0
@@ -105,13 +106,15 @@ module Webrat
0
     # Example:
0
     # save_and_open
0
     def save_and_open
0
- return unless File.exist?(RAILS_ROOT + "/tmp")
0
+ return unless File.exist?(session.saved_page_dir)
0
 
0
- filename = "webrat-#{Time.now.to_i}.html"
0
- File.open(RAILS_ROOT + "/tmp/#{filename}", "w") do |f|
0
- f.write response.body
0
+ filename = "#{session.saved_page_dir}/webrat-#{Time.now.to_i}.html"
0
+
0
+ File.open(filename, "w") do |f|
0
+ f.write session.response_body
0
       end
0
- `open tmp/#{filename}`
0
+
0
+ `open #{filename}`
0
     end
0
 
0
     # Issues a request for the URL pointed to by a link on the current page,
0
@@ -256,14 +259,9 @@ module Webrat
0
     
0
     def reset_dom
0
       @dom = nil
0
- @links = nil
0
       @forms = nil
0
     end
0
     
0
- def links
0
- @links ||= links_within(nil)
0
- end
0
-
0
     def links_within(selector)
0
       (dom / selector / "a[@href]").map do |link_element|
0
         Link.new(self, link_element)
...
1
2
 
 
 
 
 
3
4
5
...
16
17
18
 
 
 
 
19
20
21
...
23
24
25
 
26
27
28
...
1
2
3
4
5
6
7
8
9
10
...
21
22
23
24
25
26
27
28
29
30
...
32
33
34
35
36
37
38
0
@@ -1,5 +1,10 @@
0
 module Webrat
0
   class Session
0
+
0
+ def saved_page_dir
0
+ File.expand_path(".")
0
+ end
0
+
0
     def current_page
0
       @current_page ||= Page.new(self)
0
     end
0
@@ -16,6 +21,10 @@ module Webrat
0
       super || current_page.respond_to?(name)
0
     end
0
     
0
+ def save_and_open_page
0
+ current_page.save_and_open
0
+ end
0
+
0
     def method_missing(name, *args)
0
       if current_page.respond_to?(name)
0
         current_page.send(name, *args)
0
@@ -23,5 +32,6 @@ module Webrat
0
         super
0
       end
0
     end
0
+
0
   end
0
 end
0
\ No newline at end of file
...
5
6
7
 
 
 
 
8
9
10
...
5
6
7
8
9
10
11
12
13
14
0
@@ -5,6 +5,10 @@ module Webrat
0
       @integration_session = integration_session
0
     end
0
     
0
+ def saved_page_dir
0
+ File.expand_path(File.join(RAILS_ROOT, "tmp"))
0
+ end
0
+
0
     def get(url, data)
0
       @integration_session.get_via_redirect(url, data)
0
     end
...
15
16
17
18
19
20
21
22
23
24
...
15
16
17
 
 
 
 
18
19
20
0
@@ -15,10 +15,6 @@ module ActionController
0
         Webrat::Page.new(webrat_session, *args)
0
       end
0
 
0
- def save_and_open_page
0
- webrat_session.save_and_open_page
0
- end
0
-
0
       def respond_to?(name)
0
         super || webrat_session.respond_to?(name)
0
       end
...
5
6
7
 
8
9
10
...
5
6
7
8
9
10
11
0
@@ -5,6 +5,7 @@ RAILS_ROOT = "." unless defined?(RAILS_ROOT)
0
 describe "reloads" do
0
   before do
0
     @session = Webrat::TestSession.new
0
+ @session.response_body = "Hello world"
0
   end
0
 
0
   it "should reload the page" do
...
5
6
7
 
8
9
10
...
5
6
7
8
9
10
11
0
@@ -5,6 +5,7 @@ RAILS_ROOT = "." unless defined?(RAILS_ROOT)
0
 describe "visits" do
0
   before do
0
     @session = Webrat::TestSession.new
0
+ @session.response_body = "Hello world"
0
   end
0
 
0
   it "should use get" do

Comments

    No one has commented yet.