class RSpec::Rails::Matchers::RoutingMatchers::RouteToMatcher

@private

Public Class Methods

new(scope, *expected) click to toggle source
# File lib/rspec/rails/matchers/routing_matchers.rb, line 10
def initialize(scope, *expected)
  @scope = scope
  @expected = expected[1] || {}
  if Hash === expected[0]
    @expected.merge!(expected[0])
  else
    controller, action = expected[0].split('#')
    @expected.merge!(:controller => controller, :action => action)
  end
end

Public Instance Methods

description() click to toggle source
# File lib/rspec/rails/matchers/routing_matchers.rb, line 43
def description
  "route #{@actual.inspect} to #{@expected.inspect}"
end
failure_message() click to toggle source
# File lib/rspec/rails/matchers/routing_matchers.rb, line 35
def failure_message
  rescued_exception.message
end
failure_message_when_negated() click to toggle source
# File lib/rspec/rails/matchers/routing_matchers.rb, line 39
def failure_message_when_negated
  "expected #{@actual.inspect} not to route to #{@expected.inspect}"
end
matches?(verb_to_path_map) click to toggle source
# File lib/rspec/rails/matchers/routing_matchers.rb, line 21
def matches?(verb_to_path_map)
  @actual = @verb_to_path_map = verb_to_path_map
  # assert_recognizes does not consider ActionController::RoutingError an
  # assertion failure, so we have to capture that and Assertion here.
  match_unless_raises ActiveSupport::TestCase::Assertion, ActionController::RoutingError do
    path, query = *verb_to_path_map.values.first.split('?')
    @scope.assert_recognizes(
      @expected,
      { :method => verb_to_path_map.keys.first, :path => path },
      Rack::Utils.parse_nested_query(query)
    )
  end
end