Class: Shoulda::Matchers::ActionController::RespondWithMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(status) ⇒ RespondWithMatcher

Returns a new instance of RespondWithMatcher.



93
94
95
# File 'lib/shoulda/matchers/action_controller/respond_with_matcher.rb', line 93

def initialize(status)
  @status = symbol_to_status_code(status)
end

Instance Method Details

#descriptionObject



110
111
112
# File 'lib/shoulda/matchers/action_controller/respond_with_matcher.rb', line 110

def description
  "respond with #{@status}"
end

#failure_messageObject



102
103
104
# File 'lib/shoulda/matchers/action_controller/respond_with_matcher.rb', line 102

def failure_message
  "Expected #{expectation}"
end

#failure_message_when_negatedObject



106
107
108
# File 'lib/shoulda/matchers/action_controller/respond_with_matcher.rb', line 106

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

#matches?(controller) ⇒ Boolean

Returns:

  • (Boolean)


97
98
99
100
# File 'lib/shoulda/matchers/action_controller/respond_with_matcher.rb', line 97

def matches?(controller)
  @controller = controller
  correct_status_code? || correct_status_code_range?
end