Sha256: f3cb06f41353dc071211c3c107697aa78539a541027a41a40917f760c24b94e0

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'rack-nullsession'

describe 'inserting a null rack session into the middleware stack' do

  let(:result)     { double "some application response" }
  let(:app)        { double "app", :call => result }
  let(:env)        { { "some" => "environment params", "other" => "etc" } }

  let(:middleware) { Rack::NullSession.new app }

  subject(:call_app) { middleware.call env }

  it "calls the application with rack.session value of Hash" do
    expect(app).to receive(:call).with hash_including("rack.session" => {})
    call_app
  end
  it "calls the application preserving the original env" do
    expect(app).to receive(:call).with hash_including(env)
    call_app
  end
  it "preserves the application response" do
    expect(call_app).to eq(result)
  end

  context "but rack.session already exists" do
    let(:existing_session) { double }

    before { env["rack.session"] = existing_session }

    it 'leaves the existing session alone' do
      expect(app).to receive(:call).with hash_including("rack.session" => existing_session)
      call_app
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-nullsession-1.0.0 spec/unit/rack/null_session_spec.rb