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)
- - (Object) description
- - (Object) failure_message_for_should private
- - (Object) failure_message_for_should_not
-
- (RouteToMatcher) initialize(scope, *expected)
constructor
A new instance of RouteToMatcher.
- - (Boolean) matches?(verb_to_path_map) private
Constructor Details
- (RouteToMatcher) initialize(scope, *expected)
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
- (Object) description
42 43 44 |
# File 'lib/rspec/rails/matchers/routing_matchers.rb', line 42 def description "route #{@actual.inspect} to #{@expected.inspect}" end |
- (Object) failure_message_for_should
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 |
- (Object) failure_message_for_should_not
38 39 40 |
# File 'lib/rspec/rails/matchers/routing_matchers.rb', line 38 def "expected #{@actual.inspect} not to route to #{@expected.inspect}" end |
- (Boolean) matches?(verb_to_path_map)
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 |