Sha256: 3e3eeb9d7607d2b31bf88a69ae33a9cca0a7d08c33c103dd74b1a2f3945f14db

Contents?: true

Size: 922 Bytes

Versions: 4

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

require "hanami/configuration/actions"

RSpec.describe Hanami::Configuration::Actions, "#cookies" do
  let(:configuration) { described_class.new }
  subject(:cookies) { configuration.cookies }

  context "default config" do
    it "is enabled" do
      expect(cookies).to be_enabled
    end

    it "is an empty hash" do
      expect(cookies.to_h).to eq({})
    end
  end

  context "options given" do
    before do
      configuration.cookies = {max_age: 300}
    end

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

    it "returns the given options" do
      expect(cookies.to_h).to eq(max_age: 300)
    end
  end

  context "nil value given" do
    before do
      configuration.cookies = nil
    end

    it "is not enabled" do
      expect(cookies).not_to be_enabled
    end

    it "returns an empty hash" do
      expect(cookies.to_h).to eq({})
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hanami-2.0.0.beta3 spec/unit/hanami/configuration/actions/cookies_spec.rb
hanami-2.0.0.beta2 spec/unit/hanami/configuration/actions/cookies_spec.rb
hanami-2.0.0.beta1.1 spec/unit/hanami/configuration/actions/cookies_spec.rb
hanami-2.0.0.beta1 spec/unit/hanami/configuration/actions/cookies_spec.rb