Class: RSpec::Rails::Matchers::RoutingMatchers::RouteToMatcher
- Inherits:
-
Matchers::BuiltIn::BaseMatcher
- Object
- Matchers::BuiltIn::BaseMatcher
- RSpec::Rails::Matchers::RoutingMatchers::RouteToMatcher
- Defined in:
- lib/rspec/rails/matchers/routing_matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object private
-
#initialize(scope, *expected) ⇒ RouteToMatcher
constructor
A new instance of RouteToMatcher.
- #matches?(verb_to_path_map) ⇒ Boolean private
Constructor Details
#initialize(scope, *expected) ⇒ RouteToMatcher
Returns a new instance of RouteToMatcher.
7 8 9 10 11 12 13 14 15 16 |
# 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 |
Instance Method Details
#description ⇒ Object
38 39 40 |
# File 'lib/rspec/rails/matchers/routing_matchers.rb', line 38 def description "route #{@actual.inspect} to #{@expected.inspect}" end |
#failure_message_for_should ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/rspec/rails/matchers/routing_matchers.rb', line 34 def rescued_exception. end |
#matches?(verb_to_path_map) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 |