Class: RouteMechanic::Testing::ErrorInspector

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/route_mechanic/testing/error_inspector.rb

Instance Method Summary collapse

Constructor Details

#initialize(aggregator) ⇒ ErrorInspector

Returns a new instance of ErrorInspector.

Parameters:



10
11
12
# File 'lib/route_mechanic/testing/error_inspector.rb', line 10

def initialize(aggregator)
  @aggregator = aggregator
end

Instance Method Details

#messageString

Returns:

  • (String)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/route_mechanic/testing/error_inspector.rb', line 15

def message
  buffer = []

  if unused_actions_errors.present?
    buffer << "  No route matches to the controllers and action methods below"
    buffer << unused_actions_errors.map {|r| "    #{r[:controller]}##{r[:action]}" }
  end

  if unused_routes_errors.present?
    verb_width, path_width = widths
    buffer << "  No controller and action matches to the routes below"
    buffer << unused_routes_errors.map { |w| "    #{w.verb.ljust(verb_width)} #{w.path.ljust(path_width)} #{w.reqs}" }
  end

  ["[Route Mechanic]", buffer].join("\n") + "\n"
end