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
Switch to using Nokogiri.parse for XML/XHTML autodetection [#66 state:resolved]
brynary (author)
Sat Nov 22 13:46:03 -0800 2008
commit  a8e02a6b6e686cc4fd7b9c16b5fec88ae14179c9
tree    9c87ae34b37b0ee7df56fbd9aeae243c114f4323
parent  bb5eac701d2ec5201f212ec079733f2c3ee34b55
...
10
11
12
13
 
14
15
 
16
17
 
18
19
20
...
10
11
12
 
13
14
 
15
16
 
17
18
19
20
0
@@ -10,11 +10,11 @@ module Webrat
0
     elsif Nokogiri::XML::NodeSet === stringlike
0
       stringlike
0
     elsif StringIO === stringlike
0
-      Nokogiri::HTML(stringlike.string)
0
+      Nokogiri.parse(stringlike.string)
0
     elsif stringlike.respond_to?(:body)
0
-      Nokogiri::HTML(stringlike.body.to_s)
0
+      Nokogiri.parse(stringlike.body.to_s)
0
     else
0
-      Nokogiri::HTML(stringlike.to_s)
0
+      Nokogiri.parse(stringlike.to_s)
0
     end
0
   end
0
   
...
91
92
93
94
95
96
97
98
99
 
 
 
 
 
 
 
 
100
101
102
...
91
92
93
 
 
 
 
 
 
94
95
96
97
98
99
100
101
102
103
104
0
@@ -91,12 +91,14 @@ describe "click_button" do
0
   
0
   it "should submit the form with the specified button" do
0
     @session.response_body = <<-EOS
0
-      <form method="get" action="/form1">
0
-        <input type="submit" />
0
-      </form>
0
-      <form method="get" action="/form2">
0
-        <input type="submit" value="Form2" />
0
-      </form>
0
+      <html>
0
+        <form method="get" action="/form1">
0
+          <input type="submit" />
0
+        </form>
0
+        <form method="get" action="/form2">
0
+          <input type="submit" value="Form2" />
0
+        </form>
0
+      </html>
0
     EOS
0
     @session.should_receive(:get).with("/form2", {})
0
     @session.click_button "Form2"
...
254
255
256
257
258
 
 
 
 
259
260
261
...
264
265
266
267
 
 
 
268
269
270
...
284
285
286
 
287
288
289
290
 
291
292
293
...
254
255
256
 
 
257
258
259
260
261
262
263
...
266
267
268
 
269
270
271
272
273
274
...
288
289
290
291
292
293
294
295
296
297
298
299
0
@@ -254,8 +254,10 @@ describe "click_link" do
0
   
0
   it "should choose the shortest link text match" do
0
     @session.response_body = <<-EOS
0
-    <a href="/page1">Linkerama</a>
0
-    <a href="/page2">Link</a>
0
+    <html>
0
+      <a href="/page1">Linkerama</a>
0
+      <a href="/page2">Link</a>
0
+    </html>
0
     EOS
0
     
0
     @session.should_receive(:get).with("/page2", {})
0
@@ -264,7 +266,9 @@ describe "click_link" do
0
   
0
   it "should treat non-breaking spaces as spaces" do
0
     @session.response_body = <<-EOS
0
-    <a href="/page1">This&nbsp;is&nbsp;a&nbsp;link</a>
0
+    <html>
0
+      <a href="/page1">This&nbsp;is&nbsp;a&nbsp;link</a>
0
+    </html>
0
     EOS
0
     
0
     @session.should_receive(:get).with("/page1", {})
0
@@ -284,10 +288,12 @@ describe "click_link" do
0
   
0
   it "should click link within a selector" do
0
     @session.response_body = <<-EOS
0
+    <html>
0
     <a href="/page1">Link</a>
0
     <div id="container">
0
       <a href="/page2">Link</a>
0
     </div>
0
+    </html>
0
     EOS
0
     
0
     @session.should_receive(:get).with("/page2", {})
...
18
19
20
21
22
23
24
...
18
19
20
 
21
22
23
0
@@ -18,7 +18,6 @@ describe Webrat::Matchers do
0
   
0
   describe "#have_xpath" do
0
     it "should work with non-HTML documents" do
0
-      pending "Bugfix"
0
       xml = '<foo bar="baz"></foo>'
0
       xml.should have_xpath('/foo[@bar="baz"]')
0
     end
...
7
8
9
 
10
11
12
13
14
15
 
16
17
18
...
25
26
27
 
28
29
30
31
 
32
33
34
...
39
40
41
 
42
43
44
...
47
48
49
 
50
51
52
...
58
59
60
 
61
62
63
64
65
 
66
67
68
...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
27
28
29
30
31
32
33
34
35
36
37
38
...
43
44
45
46
47
48
49
...
52
53
54
55
56
57
58
...
64
65
66
67
68
69
70
71
72
73
74
75
76
0
@@ -7,12 +7,14 @@ describe "within" do
0
   
0
   it "should work when nested" do
0
     @session.response_body = <<-EOS
0
+      <html>
0
       <div>
0
         <a href="/page1">Link</a>
0
       </div>
0
       <div id="container">
0
         <div><a href="/page2">Link</a></div>
0
       </div>
0
+      </html>
0
     EOS
0
     
0
     @session.should_receive(:get).with("/page2", {})
0
@@ -25,10 +27,12 @@ describe "within" do
0
   
0
   it "should click links within a scope" do
0
     @session.response_body = <<-EOS
0
+      <html>
0
       <a href="/page1">Link</a>
0
       <div id="container">
0
         <a href="/page2">Link</a>
0
       </div>
0
+      </html>
0
     EOS
0
     
0
     @session.should_receive(:get).with("/page2", {})
0
@@ -39,6 +43,7 @@ describe "within" do
0
   
0
   it "should submit forms within a scope" do
0
     @session.response_body = <<-EOS
0
+      <html>
0
       <form id="form1" action="/form1">
0
         <label>Email: <input type="text" name="email" />
0
         <input type="submit" value="Add" />
0
@@ -47,6 +52,7 @@ describe "within" do
0
         <label>Email: <input type="text" name="email" />
0
         <input type="submit" value="Add" />
0
       </form>
0
+      </html>
0
     EOS
0
     
0
     @session.should_receive(:get).with("/form2", "email" => "test@example.com")
0
@@ -58,11 +64,13 @@ describe "within" do
0
   
0
   it "should not find buttons outside of the scope" do
0
     @session.response_body = <<-EOS
0
+      <html>
0
       <form action="/form1">
0
         <input type="submit" value="Add" />
0
       </form>
0
       <form id="form2" action="/form2">
0
       </form>
0
+      </html>
0
     EOS
0
     
0
     @session.within "#form2" do

Comments