Sha256: c8f4fc61733997d3949bb0dbeaff2eb8ba847c6ed80bf813fe53bc048eafce4b
Contents?: true
Size: 944 Bytes
Versions: 58
Compression:
Stored size: 944 Bytes
Contents
module BeHttp include Spec::Matchers def be_http(status, headers, body) SimpleMatcher.new(nil) do |given, matcher| description = (<<-DESC).gsub(/^ +/, "") be an http of expected status: #{status.inspect} actual status : #{given.status.inspect} expected headers containing: #{headers.inspect} actual headers : #{given.headers.inspect} expected body containing: #{body.inspect} actual body : #{given.body.inspect} DESC matcher.failure_message = description matcher.negative_failure_message = "not #{description}" passed = true unless given.status == status passed = false end unless headers.all?{|k, v| given.headers[k] == headers[k]} passed = false end unless body.is_a?(Regexp) ? given.body =~ body : given.body.include?(body) passed = false end passed end end end
Version data entries
58 entries across 30 versions & 8 rubygems