Get route info

This commit is contained in:
Martin Lensment 2015-03-31 17:15:57 +03:00
parent 7d7861090c
commit 7e123f902e
2 changed files with 23 additions and 1 deletions

View file

@ -10,7 +10,7 @@ describe Repp::DomainV1 do
describe 'GET /repp/v1/domains', autodoc: true do describe 'GET /repp/v1/domains', autodoc: true do
it 'returns domains of the current registrar' do it 'returns domains of the current registrar' do
binding.pry
get_with_auth '/repp/v1/domains', { limit: 1, details: true }, @api_user get_with_auth '/repp/v1/domains', { limit: 1, details: true }, @api_user
response.status.should == 200 response.status.should == 200

View file

@ -29,6 +29,28 @@ module Request
) )
}) })
end end
def get_route_info(path)
route = Repp::API.routes.select do |x|
x.route_path.gsub('(.:format)', '').gsub(':version', x.route_version) == path
end.first
route_path = route.route_path.gsub('(.:format)', '').gsub(':version', route.route_version)
puts "#{route.route_method} #{route_path}"
puts " #{route.route_description}" if route.route_description
if route.route_params.is_a?(Hash)
params = route.route_params.map do |name, desc|
required = desc.is_a?(Hash) ? desc[:required] : false
description = desc.is_a?(Hash) ? desc[:description] : desc.to_s
[name, required, " * #{name}: #{description} #{required ? '(required)' : ''}"]
end
puts " parameters:"
params.each { |p| puts p[2] }
end
end
end end
RSpec.configure do |c| RSpec.configure do |c|