Testing Greedy Route Pattern Handling in Grape Router
This test suite examines the GreedyRoute class implementation in the Grape router component. It validates core functionality for pattern handling, options management, and parameter processing in the routing system. The tests ensure proper encapsulation and behavior of route attributes.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
ruby-grape/grape
spec/grape/router/greedy_route_spec.rb
# frozen_string_literal: true
RSpec.describe Grape::Router::GreedyRoute do
let(:instance) { described_class.new(pattern, options) }
let(:index) { 0 }
let(:pattern) { :pattern }
let(:params) do
{ a_param: 1 }.freeze
end
let(:options) do
{ params: params }.freeze
end
describe '#pattern' do
subject { instance.pattern }
it { is_expected.to eq(pattern) }
end
describe '#options' do
subject { instance.options }
it { is_expected.to eq(options) }
end
describe '#params' do
subject { instance.params }
it { is_expected.to eq(params) }
end
describe '#attributes' do
subject { instance.attributes }
it { is_expected.to eq(options) }
end
end