class RSpec::Rails::Matchers::RoutingMatchers::RouteToMatcher
Public Class Methods
new(scope, *expected)
click to toggle source
# File lib/rspec/rails/matchers/routing_matchers.rb, line 7 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 38 def description "route #{@actual.inspect} to #{@expected.inspect}" end
failure_message_for_should()
click to toggle source
@api private
# File lib/rspec/rails/matchers/routing_matchers.rb, line 34 def failure_message_for_should rescued_exception.message end
matches?(verb_to_path_map)
click to toggle source
@api private
# File lib/rspec/rails/matchers/routing_matchers.rb, line 19 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_query(query) ) end end