Class: Shoulda::Matchers::ActionController::RedirectToMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/matchers/action_controller/redirect_to_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url_or_description, context, &block) ⇒ RedirectToMatcher

Returns a new instance of RedirectToMatcher.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 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

Instance Attribute Details

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



44
45
46
# File 'lib/shoulda/matchers/action_controller/redirect_to_matcher.rb', line 44

def failure_message
  @failure_message
end

#failure_message_when_negatedObject (readonly)

Returns the value of attribute failure_message_when_negated.



44
45
46
# File 'lib/shoulda/matchers/action_controller/redirect_to_matcher.rb', line 44

def failure_message_when_negated
  @failure_message_when_negated
end

Instance Method Details

#descriptionObject



71
72
73
# File 'lib/shoulda/matchers/action_controller/redirect_to_matcher.rb', line 71

def description
  "redirect to #{@location.inspect}"
end

#in_context(context) ⇒ Object



61
62
63
64
# File 'lib/shoulda/matchers/action_controller/redirect_to_matcher.rb', line 61

def in_context(context)
  @context = context
  self
end

#matches?(controller) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
69
# File 'lib/shoulda/matchers/action_controller/redirect_to_matcher.rb', line 66

def matches?(controller)
  @controller = controller
  redirects_to_url?
end