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



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

def initialize status_code
  @status_code = status_code
end

Instance Method Details

#failure_messageObject

What do we tell the user when it fails?



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

def failure_message
  a = "  expected the location header to be \#{@status_code.inspect}\n                      instead it was \#{@target_status.inspect}\n  EOF\nend\n"

#matches?(target) ⇒ Boolean

Does the given target object match the required status code?

Returns:

  • (Boolean)


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

def matches? target
  (@target_status = target.status) == @status_code
end

#negative_failure_messageObject

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



62
63
64
# File 'lib/responses.rb', line 62

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