Sha256: e6434dd70312981b0b461ce8e4b47fafb4ae860058433e9069c9b0bafea6ec39

Contents?: true

Size: 1.31 KB

Versions: 8

Compression:

Stored size: 1.31 KB

Contents

RSpec.describe Rails::Auth::Env do
  let(:rack_env)          { Rack::MockRequest.env_for("https://www.example.com") }
  let(:example_authority) { "some-authority" }

  subject(:example_env) { described_class.new(rack_env) }

  it "stores authorization state in the Rack environment" do
    expect(example_env).not_to be_authorized
    expect(example_env.to_rack.key?(described_class::AUTHORIZED_ENV_KEY)).to eq false
    expect(example_env.to_rack.key?(described_class::ALLOWED_BY_ENV_KEY)).to eq false

    example_env.authorize(example_authority)
    expect(example_env).to be_authorized
    expect(example_env.to_rack[described_class::AUTHORIZED_ENV_KEY]).to eq true
    expect(example_env.to_rack[described_class::ALLOWED_BY_ENV_KEY]).to eq example_authority
  end

  it "stores authorizers in the Rack environment" do
    expect(example_env.allowed_by).to be_nil
    expect(example_env.to_rack.key?(described_class::ALLOWED_BY_ENV_KEY)).to eq false

    example_env.allowed_by = example_authority
    expect(example_env.allowed_by).to eq example_authority
    expect(example_env.to_rack[described_class::ALLOWED_BY_ENV_KEY]).to eq example_authority
  end

  # TODO: this could probably be a bit more extensive
  it "stores credentials in the Rack enviroment" do
    expect(example_env.credentials).to be_a Rails::Auth::Credentials
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails-auth-2.1.4 spec/rails/auth/env_spec.rb
rails-auth-2.1.3 spec/rails/auth/env_spec.rb
rails-auth-2.1.2 spec/rails/auth/env_spec.rb
rails-auth-2.1.1 spec/rails/auth/env_spec.rb
rails-auth-2.1.0 spec/rails/auth/env_spec.rb
rails-auth-2.0.3 spec/rails/auth/env_spec.rb
rails-auth-2.0.2 spec/rails/auth/env_spec.rb
rails-auth-2.0.1 spec/rails/auth/env_spec.rb