Class: Shoulda::ActionController::Matchers::RespondWithContentTypeMatcher
- Inherits:
-
Object
- Object
- Shoulda::ActionController::Matchers::RespondWithContentTypeMatcher
- Defined in:
- lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(content_type) ⇒ RespondWithContentTypeMatcher
constructor
A new instance of RespondWithContentTypeMatcher.
- #matches?(controller) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(content_type) ⇒ RespondWithContentTypeMatcher
Returns a new instance of RespondWithContentTypeMatcher.
26 27 28 29 30 31 32 |
# File 'lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb', line 26 def initialize(content_type) @content_type = if content_type.is_a?(Symbol) lookup_by_extension(content_type) else content_type end end |
Instance Method Details
#description ⇒ Object
34 35 36 |
# File 'lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb', line 34 def description "respond with content type of #{@content_type}" end |
#failure_message ⇒ Object
47 48 49 |
# File 'lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb', line 47 def "Expected #{expectation}" end |
#matches?(controller) ⇒ Boolean
38 39 40 41 42 43 44 45 |
# File 'lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb', line 38 def matches?(controller) @controller = controller if @content_type.is_a?(Regexp) response_content_type =~ @content_type else response_content_type == @content_type end end |
#negative_failure_message ⇒ Object
51 52 53 |
# File 'lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb', line 51 def "Did not expect #{expectation}" end |