Class: ResponseMatchers::ResponseStatusMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/responses.rb

Overview

Response matcher that examines ActionController::Response headers for the required status code

Instance Method Summary collapse

Constructor Details

#initialize(status_code) ⇒ ResponseStatusMatcher

Set up this matcher as required



39
40
41
# File 'lib/responses.rb', line 39

def initialize status_code
  @status_code = status_code
end

Instance Method Details

#failure_messageObject

What do we tell the user when it fails?



49
50
51
# File 'lib/responses.rb', line 49

def failure_message
  "expected the response to be #{@status_code}"
end

#matches?(target) ⇒ Boolean

Does the given target object match the required status code?

Returns:

  • (Boolean)


44
45
46
# File 'lib/responses.rb', line 44

def matches? target
  target.headers['Status'] == @status_code
end

#negative_failure_messageObject

What do we tell the user when it shouldn’t fail but does



54
55
56
# File 'lib/responses.rb', line 54

def negative_failure_message
  "expected the response to be different to #{@status_code}"
end