Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-add register middleware w/ Symbol, String, Proc
Reintroduce the possibility to register middleware with symbols, strings or procs. Fixes #1389
- Loading branch information
1 parent
33563e3
commit be93a4c
Showing
4 changed files
with
54 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
class CustomMiddleware < Faraday::Middleware | ||
end | ||
|
||
RSpec.describe Faraday::MiddlewareRegistry do | ||
let(:dummy) { Class.new { extend Faraday::MiddlewareRegistry } } | ||
|
||
after { dummy.unregister_middleware(:custom) } | ||
|
||
it 'allows to register with constant' do | ||
dummy.register_middleware(custom: CustomMiddleware) | ||
expect(dummy.lookup_middleware(:custom)).to eq(CustomMiddleware) | ||
end | ||
|
||
it 'allows to register with symbol' do | ||
dummy.register_middleware(custom: :CustomMiddleware) | ||
expect(dummy.lookup_middleware(:custom)).to eq(CustomMiddleware) | ||
end | ||
|
||
it 'allows to register with string' do | ||
dummy.register_middleware(custom: 'CustomMiddleware') | ||
expect(dummy.lookup_middleware(:custom)).to eq(CustomMiddleware) | ||
end | ||
|
||
it 'allows to register with Proc' do | ||
dummy.register_middleware(custom: -> { CustomMiddleware }) | ||
expect(dummy.lookup_middleware(:custom)).to eq(CustomMiddleware) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters