class Shoulda::Matchers::ActionController::RedirectToMatcher

@private

Attributes

failure_message[R]
failure_message_when_negated[R]

Public Class Methods

new(url_or_description, context, &block) click to toggle source
# File lib/shoulda/matchers/action_controller/redirect_to_matcher.rb, line 46
def initialize(url_or_description, context, &block)
  @url_block = nil
  @url = nil
  @context = context
  @failure_message = nil
  @failure_message_when_negated = nil

  if block
    @url_block = block
    @location = url_or_description
  else
    @location = @url = url_or_description
  end
end

Public Instance Methods

description() click to toggle source
# File lib/shoulda/matchers/action_controller/redirect_to_matcher.rb, line 71
def description
  "redirect to #{@location.inspect}"
end
in_context(context) click to toggle source
# File lib/shoulda/matchers/action_controller/redirect_to_matcher.rb, line 61
def in_context(context)
  @context = context
  self
end
matches?(controller) click to toggle source
# File lib/shoulda/matchers/action_controller/redirect_to_matcher.rb, line 66
def matches?(controller)
  @controller = controller
  redirects_to_url?
end

Private Instance Methods

redirects_to_url?() click to toggle source
# File lib/shoulda/matchers/action_controller/redirect_to_matcher.rb, line 77
def redirects_to_url?
  begin
    @context.__send__(:assert_redirected_to, url)
    @failure_message_when_negated = "Didn't expect to redirect to #{url}"
    true
  rescue Shoulda::Matchers.assertion_exception_class => error
    @failure_message = error.message
    false
  end
end
url() click to toggle source
# File lib/shoulda/matchers/action_controller/redirect_to_matcher.rb, line 88
def url
  if @url_block
    @context.instance_eval(&@url_block)
  else
    @url
  end
end