Sha256: ca0b5b43af9ecb8dbe0b1c426ef56395f13588dbb43f64ba669012df30eeccd0

Contents?: true

Size: 775 Bytes

Versions: 11

Compression:

Stored size: 775 Bytes

Contents

require 'spec_helper'

describe Clearance::RackSession do
  it 'injects a clearance session into the environment' do
    expected_session = 'the session'
    expected_session.stubs :add_cookie_to_headers
    Clearance::Session.stubs :new => expected_session
    headers = { 'X-Roaring-Lobster' => 'Red' }

    app = Rack::Builder.new do
      use Clearance::RackSession
      run lambda { |env| Rack::Response.new(env[:clearance], 200, headers).finish }
    end

    env = Rack::MockRequest.env_for('/')

    response = Rack::MockResponse.new(*app.call(env))

    Clearance::Session.should have_received(:new).with(env)
    response.body.should == expected_session
    expected_session.should have_received(:add_cookie_to_headers).
      with(has_entries(headers))
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
clearance-1.2.0 spec/clearance/rack_session_spec.rb
clearance-1.1.0 spec/clearance/rack_session_spec.rb
clearance-1.0.1 spec/clearance/rack_session_spec.rb
clearance-1.0.0 spec/clearance/rack_session_spec.rb
clearance-1.0.0.rc8 spec/clearance/rack_session_spec.rb
clearance-1.0.0.rc7 spec/clearance/rack_session_spec.rb
clearance-1.0.0.rc6 spec/clearance/rack_session_spec.rb
clearance-1.0.0.rc4 spec/clearance/rack_session_spec.rb
clearance-1.0.0.rc3 spec/clearance/rack_session_spec.rb
clearance-1.0.0.rc2 spec/clearance/rack_session_spec.rb
clearance-1.0.0.rc1 spec/clearance/rack_session_spec.rb