Testing Parser Resolution Workflow in ruby-grape/grape
This test suite examines the parser functionality in the Grape framework, focusing on parser selection and registration. It validates the core parser mapping system and custom parser handling capabilities, ensuring proper parser resolution for different content types.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
ruby-grape/grape
spec/grape/parser_spec.rb
# frozen_string_literal: true
describe Grape::Parser do
subject { described_class }
describe '.parser_for' do
let(:options) { {} }
it 'returns parser correctly' do
expect(subject.parser_for(:json)).to eq(Grape::Parser::Json)
end
context 'when parser is available' do
let(:parsers) do
{ customized_json: Grape::Parser::Json }
end
it 'returns registered parser if available' do
expect(subject.parser_for(:customized_json, parsers)).to eq(Grape::Parser::Json)
end
end
context 'when parser does not exist' do
it 'returns nil' do
expect(subject.parser_for(:undefined)).to be_nil
end
end
end
end