Class: RSpec::Rails::Matchers::RedirectTo::RedirectTo

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

Instance Method Summary collapse

Constructor Details

#initialize(scope, expected) ⇒ RedirectTo

Returns a new instance of RedirectTo.



6
7
8
9
# File 'lib/rspec/rails/matchers/redirect_to.rb', line 6

def initialize(scope, expected)
  super(expected)
  @scope = scope
end

Instance Method Details

#failure_message_for_shouldObject

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
# File 'lib/rspec/rails/matchers/redirect_to.rb', line 19

def failure_message_for_should
  rescued_exception.message
end

#failure_message_for_should_notObject

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.



24
25
26
# File 'lib/rspec/rails/matchers/redirect_to.rb', line 24

def failure_message_for_should_not
  "expected not to redirect to #{expected.inspect}, but did"
end

#matches?(actual) ⇒ 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.

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/rspec/rails/matchers/redirect_to.rb', line 12

def matches?(actual)
  match_unless_raises ActiveSupport::TestCase::Assertion do
    @scope.assert_redirected_to(expected)
  end
end