-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reintroduce the possibility to register middleware with symbols, st…
…rings or procs * Update UPGRADING.md to explain the original removal from v2.0 * Update CHANGELOG.md to point to the `releases` page Fixes #1389
- Loading branch information
Showing
5 changed files
with
61 additions
and
17 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
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