Module: Regressor::Controller::Routing::Rest::Routes

Included in:
Regressor::Controller::Regression
Defined in:
lib/controller/routing/rest/routes.rb

Instance Method Summary collapse

Instance Method Details

#rest_routesObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/controller/routing/rest/routes.rb', line 6

def rest_routes

  controller_path = @controller.constantize.controller_path
  @controller.constantize.action_methods.map do |action_method|
    begin
      journey_route = extract_journey_route(controller_path, action_method)
      required_parts = extract_required_parts(journey_route)
      url = url_for({controller: controller_path, action: action_method, only_path: true}.merge(required_parts))
      generate_example(journey_route, controller_path, action_method, required_parts, url)
    rescue
      puts "Could not generate regression spec for controller #{controller_path} with action: #{action_method}"
      nil
    end
  end.uniq.compact.join("\n  ")
end