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