Files
news.gitea.happylizard.me/bin/gems/faraday-2.9.0/spec/faraday/middleware_registry_spec.rb
T
pizza2d1 4cee170d66
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s
Add bin and edit workflow
2026-09-16 13:11:16 -06:00

32 lines
1.1 KiB
Ruby

# 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