Sha256: c88d08d47c2165242fd6d28af1762428116b6ede82f0b9b2dce5ab12c3701ef2

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 KB

Contents

RSpec.describe Rack::Tracker::Handler do
  def env
    { misc: 'foobar' }
  end

  describe '#tracker_options' do
    context 'without overriding allowed_tracker_options' do
      subject { described_class.new(env, { some_option: 'value' }) }

      it 'returns an empty hash' do
        expect(subject.tracker_options).to eql ({})
      end
    end

    context 'with overridden allowed_tracker_options' do
      subject do
        handler = described_class.new(env, {
          static_option: 'value',
          dynamic_option: lambda { |env| return env[:misc] },
          dynamic_nil_option: lambda { |env| return env[:non_existent_key] },
          non_allowed_option: 'value'
        })

        handler.allowed_tracker_options =
          [:static_option, :dynamic_option, :dynamic_nil_option]

        handler
      end

      it 'evaluates dynamic options, rejecting nonallowed and nil ones' do
        expect(subject.tracker_options).to eql ({
          static_option: 'value',
          dynamic_option: 'foobar'
        })
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rack-tracker-1.13.0 spec/handler/handler_spec.rb
rack-tracker-1.12.1 spec/handler/handler_spec.rb
rack-tracker-1.12.0 spec/handler/handler_spec.rb
rack-tracker-1.11.2 spec/handler/handler_spec.rb
rack-tracker-1.11.1 spec/handler/handler_spec.rb
rack-tracker-1.11.0 spec/handler/handler_spec.rb
rack-tracker-1.10.0 spec/handler/handler_spec.rb
rack-tracker-1.9.0 spec/handler/handler_spec.rb
rack-tracker-1.8.0 spec/handler/handler_spec.rb
rack-tracker-1.7.0 spec/handler/handler_spec.rb
rack-tracker-1.6.0 spec/handler/handler_spec.rb