class Webspicy::Tester::Result::ResponseHeaderMet
Attributes
expected[R]
header[R]
strategy[R]
Public Class Methods
new(result, header, expected, strategy = :eq)
click to toggle source
Calls superclass method
Webspicy::Tester::Result::Check::new
# File lib/webspicy/tester/result/response_header_met.rb, line 6 def initialize(result, header, expected, strategy = :eq) unless [:eq, :start_with].include?(strategy) raise ArgumentError, "Invalid strategy `#{strategy.inspect}`" end super(result) @header = header @expected = expected @strategy = strategy end
Public Instance Methods
behavior()
click to toggle source
# File lib/webspicy/tester/result/response_header_met.rb, line 17 def behavior "It has a `#{header}: #{expected}` response header" end
call()
click to toggle source
# File lib/webspicy/tester/result/response_header_met.rb, line 25 def call got = response.headers[header] if got.nil? _! "Expected response header `#{header}` to be set" else msg = "Expected response header `#{header}` to be `#{expected}`, got `#{got}`" case strategy when :eq _!(msg) unless expected == got when :start_with _!(msg) unless got.start_with?(expected) end end end
must?()
click to toggle source
# File lib/webspicy/tester/result/response_header_met.rb, line 21 def must? true end