lib/api_taster/route.rb in api_taster-0.6.0 vs lib/api_taster/route.rb in api_taster-0.7.0

- old
+ new

@@ -7,22 +7,22 @@ cattr_accessor :obsolete_definitions cattr_accessor :comments cattr_accessor :metadata class << self - - def map_routes + def map_routes(path = ApiTaster.route_path) self.route_set = Rails.application.routes self.supplied_params = {} self.obsolete_definitions = [] self.comments = {} self.metadata = {} normalise_routes! begin - Mapper.instance_eval(&self.mappings.call) + ApiTaster::RouteCollector.collect(path) + Mapper.instance_eval(&self.mappings) rescue Route.mappings = {} end end @@ -33,14 +33,15 @@ unless route_set.respond_to?(:routes) raise ApiTaster::Exception.new('Route definitions are missing, have you defined ApiTaster.routes?') end route_set.routes.each do |route| - next if route.app.is_a?(ActionDispatch::Routing::Mapper::Constraints) next if route.app.is_a?(Sprockets::Environment) next if route.app == ApiTaster::Engine - if (rack_app = discover_rack_app(route.app)) && rack_app.respond_to?(:routes) + rack_app = discover_rack_app(route.app) + + if rack_app && rack_app.respond_to?(:routes) && rack_app.routes.respond_to?(:routes) rack_app.routes.routes.each do |rack_route| self.routes << normalise_route(rack_route, route.path.spec) end end