Skip to content

Commit

Permalink
Added integration test for injected cookie_jar. Also updated it to us…
Browse files Browse the repository at this point in the history
…e the new expect() syntax
  • Loading branch information
cameron-martin committed Jan 22, 2014
1 parent 7549ea7 commit 20f49fa
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions spec/faraday-cookie_jar/integration/cookie_jar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe Faraday::CookieJar do
let(:conn) { Faraday.new(:url => 'https://faraday.example.com') }
let(:cookie_jar) { HTTP::CookieJar.new }

before do
conn.use :cookie_jar
Expand All @@ -10,19 +11,32 @@

it 'get default cookie' do
conn.get('/default')
conn.get('/dump').body.should == 'foo=bar'
expect(conn.get('/dump').body).to eq('foo=bar')
end

it 'does not send cookies to wrong path' do
conn.get('/path')
conn.get('/dump').body.should_not == 'foo=bar'
expect(conn.get('/dump').body).to_not eq('foo=bar')
end

it 'expires cookie' do
conn.get('/expires')
conn.get('/dump').body.should == 'foo=bar'
expect(conn.get('/dump').body).to eq('foo=bar')
sleep 2
conn.get('/dump').body.should_not == 'foo=bar'
expect(conn.get('/dump').body).to_not eq('foo=bar')
end

it 'fills an injected cookie jar' do

conn_with_jar = Faraday.new(:url => 'https://faraday.example.com') do |conn|
conn.use :cookie_jar, jar: cookie_jar
conn.adapter :net_http # for sham_rock
end

conn_with_jar.get('/default')

expect(cookie_jar.empty?).to be_false

end

it 'multiple cookies' do
Expand Down

0 comments on commit 20f49fa

Please sign in to comment.