Class: RSpec::Rails::Matchers::HaveHttpStatus::GenericStatus Private
- Inherits:
 - 
      Matchers::BuiltIn::BaseMatcher
        
- Object
 - Matchers::BuiltIn::BaseMatcher
 - RSpec::Rails::Matchers::HaveHttpStatus::GenericStatus
 
 - Includes:
 - RSpec::Rails::Matchers::HaveHttpStatus
 - Defined in:
 - lib/rspec/rails/matchers/have_http_status.rb
 
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides an implementation for have_http_status matching
against ActionDispatch::TestResponse http status category
queries.
Not intended to be instantiated directly.
Class Method Summary (collapse)
- 
  
      + (Array<Symbol>) valid_statuses 
  
  private
    
Of status codes which represent a HTTP status code “group”.
 
Instance Method Summary (collapse)
- - (String) description private
 - 
  
      - (String) failure_message 
  
  private
    
Explaining why the match failed.
 - 
  
      - (String) failure_message_when_negated 
  
  private
    
Explaining why the match failed.
 - 
  
      - (GenericStatus) initialize(type) 
  
    constructor
  private
    
A new instance of GenericStatus.
 - 
  
      - (Boolean) matches?(response) 
  
  private
    
trueif Rack's associated numeric HTTP code matched theresponsecode. 
Methods included from RSpec::Rails::Matchers::HaveHttpStatus
as_test_response, #invalid_response_type_message, matcher_for_status
Constructor Details
- (GenericStatus) initialize(type)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of GenericStatus
      249 250 251 252 253 254 255 256  | 
    
      # File 'lib/rspec/rails/matchers/have_http_status.rb', line 249 def initialize(type) unless self.class.valid_statuses.include?(type) raise ArgumentError, "Invalid generic HTTP status: #{type.inspect}" end @expected = type @actual = nil @invalid_response = nil end  | 
  
Class Method Details
+ (Array<Symbol>) valid_statuses
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns of status codes which represent a HTTP status code “group”
      245 246 247  | 
    
      # File 'lib/rspec/rails/matchers/have_http_status.rb', line 245 def self.valid_statuses [:error, :success, :missing, :redirect] end  | 
  
Instance Method Details
- (String) description
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
      270 271 272  | 
    
      # File 'lib/rspec/rails/matchers/have_http_status.rb', line 270 def description "respond with #{}" end  | 
  
- (String) failure_message
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns explaining why the match failed
      275 276 277 278  | 
    
      # File 'lib/rspec/rails/matchers/have_http_status.rb', line 275 def || "expected the response to have #{} but it was #{actual}" end  | 
  
- (String) failure_message_when_negated
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns explaining why the match failed
      281 282 283 284  | 
    
      # File 'lib/rspec/rails/matchers/have_http_status.rb', line 281 def || "expected the response not to have #{} but it was #{actual}" end  | 
  
- (Boolean) matches?(response)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true if Rack's associated numeric HTTP code
matched the response code
      260 261 262 263 264 265 266 267  | 
    
      # File 'lib/rspec/rails/matchers/have_http_status.rb', line 260 def matches?(response) test_response = as_test_response(response) @actual = test_response.response_code test_response.send("#{expected}?") rescue TypeError => _ignored @invalid_response = response false end  |