Class: Shoulda::Matchers::ActionController::RespondWithContentTypeMatcher

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(content_type) ⇒ RespondWithContentTypeMatcher

Returns a new instance of RespondWithContentTypeMatcher.



25
26
27
# File 'lib/shoulda/matchers/action_controller/respond_with_content_type_matcher.rb', line 25

def initialize(content_type)
  @content_type = look_up_content_type(content_type)
end

Instance Method Details

#descriptionObject



29
30
31
# File 'lib/shoulda/matchers/action_controller/respond_with_content_type_matcher.rb', line 29

def description
  "respond with content type of #{@content_type}"
end

#failure_messageObject



42
43
44
# File 'lib/shoulda/matchers/action_controller/respond_with_content_type_matcher.rb', line 42

def failure_message
  "Expected #{expectation}"
end

#failure_message_for_shouldObject



38
39
40
# File 'lib/shoulda/matchers/action_controller/respond_with_content_type_matcher.rb', line 38

def failure_message_for_should
  "Expected #{expectation}"
end

#failure_message_for_should_notObject



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

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

#failure_message_when_negatedObject



50
51
52
# File 'lib/shoulda/matchers/action_controller/respond_with_content_type_matcher.rb', line 50

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

#matches?(controller) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/shoulda/matchers/action_controller/respond_with_content_type_matcher.rb', line 33

def matches?(controller)
  @controller = controller
  content_type_matches_regexp? || content_type_matches_string?
end