Sha256: aab30e7b98075f9f475efd5a82266cd8680f6dfb76bcaf5da38864951fbc3d10

Contents?: true

Size: 1.1 KB

Versions: 17

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require "hanami/config/actions"

RSpec.describe Hanami::Config::Actions, "#sessions" do
  let(:config) { described_class.new }
  subject(:sessions) { config.sessions }

  context "no session config specified" do
    it "is not enabled" do
      expect(sessions).not_to be_enabled
    end

    it "returns nil storage" do
      expect(sessions.storage).to be_nil
    end

    it "returns empty options" do
      expect(sessions.options).to eq []
    end

    it "returns no session middleware" do
      expect(sessions.middleware).to eq []
    end
  end

  context "valid session config provided" do
    before do
      config.sessions = :cookie, {secret: "abc"}
    end

    it "is enabled" do
      expect(sessions).to be_enabled
    end

    it "returns the given storage" do
      expect(sessions.storage).to eq :cookie
    end

    it "returns the given options" do
      expect(sessions.options).to eq [secret: "abc"]
    end

    it "returns an array of middleware classes and options" do
      expect(sessions.middleware).to eq [Rack::Session::Cookie, {secret: "abc"}]
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
hanami-2.2.1 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.2.0 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.2.0.rc1 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.2.0.beta2 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.2.0.beta1 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.1.0 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.1.0.rc3 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.1.0.rc2 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.1.0.rc1 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.1.0.beta2.1 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.1.0.beta2 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.1.0.beta1 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.0.3 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.0.2 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.0.1 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.0.0 spec/unit/hanami/config/actions/sessions_spec.rb
hanami-2.0.0.rc1 spec/unit/hanami/config/actions/sessions_spec.rb