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

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

Instance Method Summary (collapse)

Constructor Details

- (RedirectTo) initialize(scope, expected)

Returns a new instance of RedirectTo



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

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

Instance Method Details

- (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.



18
19
20
# File 'lib/rspec/rails/matchers/redirect_to.rb', line 18

def failure_message_for_should
  rescued_exception.message
end

- (Object) failure_message_for_should_not

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.



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

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

- (Boolean) matches?(_)

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)


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

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