Sha256: 138b2ea7a296152f7ba1fdee66dfab24b2e2d69cc12ad3a050eeb1c5a44d0efa

Contents?: true

Size: 783 Bytes

Versions: 3

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true

RSpec.shared_context "with mocked rack application" do
  attr_reader :last_rack_environment

  let(:base_app_implementation) do
    ->(env) do
      @last_rack_environment = env

      state = env["keycloak:session"].authenticate! do |m|
        m.success(:authenticated) do
          "authenticated"
        end

        m.success do
          "anonymous"
        end

        m.failure do
          "failed"
        end
      end

      response = {
        "auth_state" => state
      }

      [
        200,
        { "Content-Type" => "application/json" },
        [response.to_json]
      ]
    end
  end

  let(:rack_application) do
    base_app_implementation.tap do |app|
      allow(app).to receive(:call).and_call_original
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
keycloak_rack-1.1.1 spec/support/contexts/mocked_rack_application.rb
keycloak_rack-1.1.0 spec/support/contexts/mocked_rack_application.rb
keycloak_rack-1.0.0 spec/support/contexts/mocked_rack_application.rb