Class: Shoulda::Matchers::ActionController::RescueFromMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ RescueFromMatcher

Returns a new instance of RescueFromMatcher.



40
41
42
43
44
# File 'lib/shoulda/matchers/action_controller/rescue_from_matcher.rb', line 40

def initialize(exception)
  @exception = exception
  @expected_method = nil
  @controller = nil
end

Instance Method Details

#descriptionObject



56
57
58
59
60
# File 'lib/shoulda/matchers/action_controller/rescue_from_matcher.rb', line 56

def description
  description = "rescue from #{exception}"
  description << " with ##{expected_method}" if expected_method
  description
end

#failure_messageObject



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

def failure_message
  "Expected #{expectation}"
end

#failure_message_when_negatedObject



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

def failure_message_when_negated
  "Did not expect #{expectation}"
end

#matches?(controller) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/shoulda/matchers/action_controller/rescue_from_matcher.rb', line 51

def matches?(controller)
  @controller = controller
  rescues_from_exception? && method_name_matches? && handler_exists?
end

#with(method) ⇒ Object



46
47
48
49
# File 'lib/shoulda/matchers/action_controller/rescue_from_matcher.rb', line 46

def with(method)
  @expected_method = method
  self
end