File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ - Fix OpenapiFirst.load when MultiJson is configured to return symbol keys
6+
57## 2.9.2
68
79- OpenapiFirst::Test reports all non-covered requests now
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ def load(file_path)
1313
1414 body = File . read ( file_path )
1515 extname = File . extname ( file_path )
16- return JSON . parse ( body ) if extname == '.json'
16+ return :: JSON . parse ( body ) if extname == '.json'
1717 return YAML . unsafe_load ( body ) if [ '.yaml' , '.yml' ] . include? ( extname )
1818
1919 body
Original file line number Diff line number Diff line change 22
33RSpec . describe OpenapiFirst ::FileLoader do
44 describe '.load' do
5- it 'loads .json' do
6- contents = described_class . load ( './spec/data/petstore.json' )
7- expect ( contents [ 'openapi' ] ) . to eq ( '3.0.0' )
5+ begin
6+ require 'multi_json'
7+ before do
8+ MultiJson . load_options = { symbolize_keys : true }
9+ end
10+
11+ after do
12+ MultiJson . load_options = { symbolize_keys : false }
13+ end
14+ rescue LoadError # rubocop:disable Lint/SuppressedException
815 end
916
1017 it 'loads .yaml' do
1724 expect ( contents [ 'openapi' ] ) . to eq ( '3.0.0' )
1825 end
1926
27+ it 'loads .json' do
28+ contents = described_class . load ( './spec/data/petstore.json' )
29+ expect ( contents [ 'openapi' ] ) . to eq ( '3.0.0' )
30+ end
31+
2032 it 'raises FileNotFoundError if file was not found' do
2133 expect { described_class . load ( './spec/data/unknown.yaml' ) } . to raise_error ( OpenapiFirst ::FileNotFoundError , 'File not found "./spec/data/unknown.yaml"' )
2234 end
You can’t perform that action at this time.
0 commit comments