Sha256: 84c7906de8d4eeb4e112e81b089a336f6240d9fad2db392229eb53f70f98f62a

Contents?: true

Size: 1.06 KB

Versions: 50

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

RSpec.describe Faraday::MiddlewareRegistry do
  before do
    stub_const('CustomMiddleware', custom_middleware_klass)
  end
  let(:custom_middleware_klass) { Class.new(Faraday::Middleware) }
  let(:dummy) { Class.new { extend Faraday::MiddlewareRegistry } }

  after { dummy.unregister_middleware(:custom) }

  it 'allows to register with constant' do
    dummy.register_middleware(custom: custom_middleware_klass)
    expect(dummy.lookup_middleware(:custom)).to eq(custom_middleware_klass)
  end

  it 'allows to register with symbol' do
    dummy.register_middleware(custom: :CustomMiddleware)
    expect(dummy.lookup_middleware(:custom)).to eq(custom_middleware_klass)
  end

  it 'allows to register with string' do
    dummy.register_middleware(custom: 'CustomMiddleware')
    expect(dummy.lookup_middleware(:custom)).to eq(custom_middleware_klass)
  end

  it 'allows to register with Proc' do
    dummy.register_middleware(custom: -> { custom_middleware_klass })
    expect(dummy.lookup_middleware(:custom)).to eq(custom_middleware_klass)
  end
end

Version data entries

50 entries across 50 versions & 4 rubygems

Version Path
faraday-2.12.1 spec/faraday/middleware_registry_spec.rb
moneykit-0.1.15 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
moneykit-0.1.14 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
faraday-2.12.0 spec/faraday/middleware_registry_spec.rb
faraday-2.11.0 spec/faraday/middleware_registry_spec.rb
moneykit-0.1.13 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
moneykit-0.1.12 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
moneykit-0.1.11 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
faraday-2.10.1 spec/faraday/middleware_registry_spec.rb
faraday-2.10.0 spec/faraday/middleware_registry_spec.rb
faraday-2.9.2 spec/faraday/middleware_registry_spec.rb
faraday-2.9.1 spec/faraday/middleware_registry_spec.rb
moneykit-0.1.10 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
moneykit-0.1.9 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
moneykit-0.1.6 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
moneykit-0.1.5 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
moneykit-0.1.4 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
moneykit-0.1.3 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/middleware_registry_spec.rb
faraday-2.9.0 spec/faraday/middleware_registry_spec.rb
faraday-2.8.1 spec/faraday/middleware_registry_spec.rb