Browse files

restructure specs for CookieJar. Adds specs for #find method

  • Loading branch information...
1 parent ce198ab commit 3bce3d7703b65cb87a17d82263be4e550b7dfaa0 @niklasb niklasb committed Oct 14, 2011
Showing with 22 additions and 8 deletions.
  1. +22 −8 spec/cookie_jar_spec.rb
View
30 spec/cookie_jar_spec.rb
@@ -15,20 +15,34 @@
subject { Capybara::Driver::Webkit::CookieJar.new(browser) }
- describe "#[]" do
- it "returns the right cookie value for every given domain/path" do
- subject["cookie1", "example.org"].should == "1"
- subject["cookie1", "www.facebook.com"].should == "3"
- subject["cookie2", "sub1.example.org"].should == "4"
+ describe "#find" do
+ it "returns a cookie object" do
+ subject.find("cookie1", "www.facebook.com").domain.should == ".facebook.com"
+ end
+
+ it "returns the right cookie for every given domain/path" do
+ subject.find("cookie1", "example.org").value.should == "1"
+ subject.find("cookie1", "www.facebook.com").value.should == "3"
+ subject.find("cookie2", "sub1.example.org").value.should == "4"
end
it "does not return a cookie from other domain" do
- subject["cookie2", "www.example.org"].should == nil
+ subject.find("cookie2", "www.example.org").should == nil
end
it "respects path precedence rules" do
- subject["cookie1", "www.example.org"].should == "1"
- subject["cookie1", "www.example.org", "/dir1/123"].should == "2"
+ subject.find("cookie1", "www.example.org").value.should == "1"
+ subject.find("cookie1", "www.example.org", "/dir1/123").value.should == "2"
+ end
+ end
+
+ describe "#[]" do
+ it "returns the first matching cookie's value" do
+ subject["cookie1", "example.org"].should == "1"
+ end
+
+ it "returns nil if no cookie is found" do
+ subject["notexisting"].should == nil
end
end
end

0 comments on commit 3bce3d7

Please sign in to comment.