Class: RSpec::Rails::Matchers::RoutingMatchers::BeRoutableMatcher

Inherits:
Matchers::BuiltIn::BaseMatcher
  • Object
show all
Defined in:
lib/rspec/rails/matchers/routing_matchers.rb

Instance Method Summary (collapse)

Constructor Details

- (BeRoutableMatcher) initialize(scope)

Returns a new instance of BeRoutableMatcher

66
67
68
# File 'lib/rspec/rails/matchers/routing_matchers.rb', line 66
def initialize(scope)
  @scope = scope
end

Instance Method Details

- (Object) failure_message_for_should

80
81
82
# File 'lib/rspec/rails/matchers/routing_matchers.rb', line 80
def failure_message_for_should
  "expected #{@actual.inspect} to be routable"
end

- (Object) failure_message_for_should_not

84
85
86
# File 'lib/rspec/rails/matchers/routing_matchers.rb', line 84
def failure_message_for_should_not
  "expected #{@actual.inspect} not to be routable, but it routes to #{@routing_options.inspect}"
end

- (Boolean) matches?(path)

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.

Returns:

  • (Boolean)
71
72
73
74
75
76
77
78
# File 'lib/rspec/rails/matchers/routing_matchers.rb', line 71
def matches?(path)
  @actual = path
  match_unless_raises ActionController::RoutingError do
    @routing_options = @scope.routes.recognize_path(
      path.values.first, :method => path.keys.first
    )
  end
end