spec/session_spec.rb in patron-0.5.1 vs spec/session_spec.rb in patron-0.6.0
- old
+ new
@@ -36,18 +36,34 @@
it "should work when forcing ipv4" do
@session.force_ipv4 = true
expect { @session.get("/test") }.to_not raise_error
end
-
- it "should escape and unescape strings symetrically" do
- string = "foo~bar baz/"
- escaped = @session.escape(string)
- unescaped = @session.unescape(escaped)
- expect(unescaped).to be == string
+
+ describe '.escape and #escape' do
+ it 'makes escape() and unescape() available on the class' do
+ string = "foo~bar baz/"
+ escaped = described_class.escape(string)
+ unescaped = described_class.unescape(escaped)
+ expect(unescaped).to be == string
+ end
+
+ it "should escape and unescape strings symetrically" do
+ string = "foo~bar baz/"
+ escaped = @session.escape(string)
+ unescaped = @session.unescape(escaped)
+ expect(unescaped).to be == string
+ end
+
+ it "should make e and unescape strings symetrically" do
+ string = "foo~bar baz/"
+ escaped = @session.escape(string)
+ unescaped = @session.unescape(escaped)
+ expect(unescaped).to be == string
+ end
end
-
+
it "should raise an error when passed an invalid action" do
expect { @session.request(:bogus, "/test", {}) }.to raise_error(ArgumentError)
end
it "should raise an error when no URL is provided" do
@@ -327,9 +343,20 @@
}.to_not raise_error
expect(body.request_method).to be == "GET"
end
+ it "should automatically decompress using Content-Encoding if requested" do
+ @session.automatic_content_encoding = true
+ response = @session.get('/gzip-compressed')
+
+ expect(response.headers['Content-Length']).to eq('125')
+
+ body = response.body
+ expect(body).to match(/Some highly compressible data/)
+ expect(body.bytesize).to eq(29696)
+ end
+
it "should serialize query params and append them to the url" do
response = @session.request(:get, "/test", {}, :query => {:foo => "bar"})
request = YAML::load(response.body)
request.parse
expect(request.path + '?' + request.query_string).to be == "/test?foo=bar"