faraday-cookie_jar 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/faraday-cookie_jar.gemspec +1 -1
- data/lib/faraday/cookie_jar.rb +3 -1
- data/lib/faraday/cookie_jar/version.rb +1 -1
- data/spec/faraday-cookie_jar/cookie_jar_spec.rb +19 -5
- metadata +2 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8195f07090b241910a6e10b5507219a4e1b0bb0
|
4
|
+
data.tar.gz: cfdbddb3fd497aa3e1afc96b9d0987e0817d2459
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b97438bab250cb4ce8a6f3d03f0df750adfa3bd5b82ced61bf50dd52d995967c875e9eec207d50826833d4f5a6c218e86b8b72b0d159acb819f0ee2c24c66bf4
|
7
|
+
data.tar.gz: 93c1ee9c3fa64a9491a442028ee2ce1f12921722419613b43bd4481b61920bdab81e19087f591e67afea1ed74c5a80ab5a3f823f8d3c4584aa3b2ef378d6a140
|
data/CHANGELOG.md
CHANGED
data/faraday-cookie_jar.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "faraday", ">= 0.7.4"
|
21
|
+
spec.add_dependency "faraday", ">= 0.7.4"
|
22
22
|
spec.add_dependency "http-cookie", "~> 1.0.0"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
data/lib/faraday/cookie_jar.rb
CHANGED
@@ -5,7 +5,7 @@ module Faraday
|
|
5
5
|
class CookieJar < Faraday::Middleware
|
6
6
|
def initialize(app, options = {})
|
7
7
|
super(app)
|
8
|
-
@jar = HTTP::CookieJar.new
|
8
|
+
@jar = options[:jar] || HTTP::CookieJar.new
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(env)
|
@@ -32,4 +32,6 @@ end
|
|
32
32
|
|
33
33
|
if Faraday.respond_to? :register_middleware
|
34
34
|
Faraday.register_middleware :cookie_jar => lambda { Faraday::CookieJar }
|
35
|
+
elsif Faraday::Middleware.respond_to? :register_middleware
|
36
|
+
Faraday::Middleware.register_middleware :cookie_jar => Faraday::CookieJar
|
35
37
|
end
|
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Faraday::CookieJar do
|
4
4
|
let(:conn) { Faraday.new(:url => 'http://faraday.example.com') }
|
5
|
+
let(:cookie_jar) { HTTP::CookieJar.new }
|
5
6
|
|
6
7
|
before do
|
7
8
|
conn.use :cookie_jar
|
@@ -10,19 +11,32 @@ describe Faraday::CookieJar do
|
|
10
11
|
|
11
12
|
it 'get default cookie' do
|
12
13
|
conn.get('/default')
|
13
|
-
conn.get('/dump').body.
|
14
|
+
expect(conn.get('/dump').body).to eq('foo=bar')
|
14
15
|
end
|
15
16
|
|
16
17
|
it 'does not send cookies to wrong path' do
|
17
18
|
conn.get('/path')
|
18
|
-
conn.get('/dump').body.
|
19
|
+
expect(conn.get('/dump').body).to_not eq('foo=bar')
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'expires cookie' do
|
22
23
|
conn.get('/expires')
|
23
|
-
conn.get('/dump').body.
|
24
|
+
expect(conn.get('/dump').body).to eq('foo=bar')
|
24
25
|
sleep 2
|
25
|
-
conn.get('/dump').body.
|
26
|
+
expect(conn.get('/dump').body).to_not eq('foo=bar')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'fills an injected cookie jar' do
|
30
|
+
|
31
|
+
conn_with_jar = Faraday.new(:url => 'http://faraday.example.com') do |conn|
|
32
|
+
conn.use :cookie_jar, jar: cookie_jar
|
33
|
+
conn.adapter :net_http # for sham_rock
|
34
|
+
end
|
35
|
+
|
36
|
+
conn_with_jar.get('/default')
|
37
|
+
|
38
|
+
expect(cookie_jar.empty?).to be_false
|
39
|
+
|
26
40
|
end
|
27
41
|
|
28
42
|
it 'multiple cookies' do
|
@@ -33,7 +47,7 @@ describe Faraday::CookieJar do
|
|
33
47
|
request.headers.merge!({:Cookie => 'language=english'})
|
34
48
|
end
|
35
49
|
|
36
|
-
response.body.
|
50
|
+
expect(response.body).to eq('foo=bar;language=english')
|
37
51
|
end
|
38
52
|
end
|
39
53
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday-cookie_jar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuhiko Miyagawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.7.4
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 0.9.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 0.7.4
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 0.9.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: http-cookie
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|