<commit_before>require 'spec_helper'

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

  before do
    conn.use :cookie_jar
    conn.adapter :net_http # for sham_rock
  end

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

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

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

  it 'multiple cookies' do
    conn.get('/default')

    response = conn.send('get') do |request|
      request.url '/multiple_cookies'
      request.headers.merge!({:Cookie => 'language=english'})
    end

    response.body.should == 'foo=bar;language=english'
  end
end
<commit_msg>Added integration test for injected cookie_jar. Also updated it to use the new expect() syntax<commit_after>require 'spec_helper'

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

  before do
    conn.use :cookie_jar
    conn.adapter :net_http # for sham_rock
  end

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

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

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

  it 'fills an injected cookie jar' do

    conn_with_jar = Faraday.new(:url => 'http://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
    conn.get('/default')

    response = conn.send('get') do |request|
      request.url '/multiple_cookies'
      request.headers.merge!({:Cookie => 'language=english'})
    end

    response.body.should == 'foo=bar;language=english'
  end
end

{'fraction_non_alphanumeric': 0.15496688741721854, 'fraction_numerical': 0.0008830022075055188, 'mean_word_length': 3.299810246679317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '975969', 'n_tokens_mistral': 797, 'n_tokens_neox': 758, 'n_words': 179}