sr (owner)

Revisions

  • 91733c sr Thu Jun 25 08:47:55 -0700 2009
gist: 135934 Download_button fork
public
Public Clone URL: git://gist.github.com/135934.git
Embed All Files: show embed
Text #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
commit ba0b883d044825abae158eab7b4e177c0593bae5
Author: Simon Rozet <simon@rozet.name>
Date: Sat Jun 20 13:39:42 2009 +0200
 
    within_spec
 
diff --git a/spec/public/within_spec.rb b/spec/public/within_spec.rb
index ab083d2..4e9e5f3 100644
--- a/spec/public/within_spec.rb
+++ b/spec/public/within_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
 
 describe "within" do
   it "should work when nested" do
@@ -13,12 +13,15 @@ describe "within" do
       </html>
     HTML
 
- webrat_session.should_receive(:get).with("/page2", {})
     within "#container" do
       within "div" do
         click_link "Link"
       end
     end
+
+ last_request.should be_get
+ last_request.path_info.should == "/page2"
+ last_request.GET.should be_empty
   end
 
   it "should click links within a scope" do
@@ -31,10 +34,13 @@ describe "within" do
       </html>
     HTML
 
- webrat_session.should_receive(:get).with("/page2", {})
     within "#container" do
       click_link "Link"
     end
+
+ last_request.should be_get
+ last_request.path_info.should == "/page2"
+ last_request.GET.should be_empty
   end
 
   it "should submit forms within a scope" do
@@ -51,11 +57,14 @@ describe "within" do
       </html>
     HTML
 
- webrat_session.should_receive(:get).with("/form2", "email" => "test@example.com")
     within "#form2" do
       fill_in "Email", :with => "test@example.com"
       click_button
     end
+
+ last_request.should be_get
+ last_request.path_info.should == "/form2"
+ last_request.GET.should == {"email" => "test@example.com"}
   end
 
   it "should work when the scope is inside the form" do
@@ -70,12 +79,15 @@ describe "within" do
       </html>
     HTML
 
- webrat_session.should_receive(:get).with("/form2", "email" => "test@example.com")
     within ".important" do
       fill_in "Email", :with => "test@example.com"
     end
 
     submit_form "form2"
+
+ last_request.should be_get
+ last_request.path_info.should == "/form2"
+ last_request.GET.should == {"email" => "test@example.com"}
   end
 
   it "should work when the form submission occurs inside a scope" do
@@ -92,11 +104,14 @@ describe "within" do
       </html>
     HTML
 
- webrat_session.should_receive(:get).with("/form2", "email" => "test@example.com")
     within "form[@action='/form2']" do
       fill_in "Email", :with => "test@example.com"
       click_button "Add"
     end
+
+ last_request.should be_get
+ last_request.path_info.should == "/form2"
+ last_request.GET.should == {"email" => "test@example.com"}
   end
 
   it "should work when there are multiple forms with the same label text" do
@@ -117,11 +132,14 @@ describe "within" do
       </html>
     HTML
 
- webrat_session.should_receive(:get).with("/form2", "email2" => "test@example.com")
     within "form[@action='/form2']" do
       fill_in "Email", :with => "test@example.com"
       click_button "Add"
     end
+
+ last_request.should be_get
+ last_request.path_info.should == "/form2"
+ last_request.GET.should == {"email2" => "test@example.com"}
   end
 
   it "should not find fields outside of the scope" do
@@ -138,11 +156,14 @@ describe "within" do
       </html>
     HTML
 
- webrat_session.should_receive(:get).with("/form2", "email" => "test@example.com")
     within "#form2" do
       fill_in "Email", :with => "test@example.com"
       click_button "Add"
     end
+
+ last_request.should be_get
+ last_request.path_info.should == "/form2"
+ last_request.GET.should == {"email" => "test@example.com"}
   end
 
   it "should not find buttons outside of the scope" do
@@ -170,8 +191,7 @@ describe "within" do
     HTML
 
     lambda {
- within "#form2" do
- end
+ within "#form2"
     }.should raise_error(Webrat::NotFoundError)
   end
 end