-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
to easily load, cache and reference OADs
- Loading branch information
Showing
8 changed files
with
157 additions
and
21 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
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,31 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Faraday::Openapi do | ||
describe '.register' do | ||
it 'adds an OAD' do | ||
described_class.register('spec/data/dice.yaml') | ||
expect(described_class[:default]['info']['title']).to eq 'Dice API' | ||
end | ||
|
||
it 'raises an error if :default was already registered' do | ||
described_class.register('spec/data/dice.yaml') | ||
expect { described_class.register('spec/data/dice.yaml') }.to raise_error described_class::AlreadyRegisteredError | ||
end | ||
|
||
it 'adds an OAD under a custom name' do | ||
described_class.register('spec/data/dice.yaml', as: :dice) | ||
expect(described_class[:dice]['info']['title']).to eq 'Dice API' | ||
end | ||
end | ||
|
||
describe '.[]' do | ||
it 'returns an error if nothing was registered' do | ||
expect { described_class[:default] }.to raise_error described_class::NotRegisteredError | ||
end | ||
|
||
it 'returns the registered OAD' do | ||
described_class.register('spec/data/dice.yaml') | ||
expect(described_class[:default]['info']['title']).to eq 'Dice API' | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,9 @@ | |
c.syntax = :expect | ||
end | ||
|
||
config.after do | ||
Faraday::Openapi.registry.clear | ||
end | ||
|
||
config.order = :random | ||
end |