Sha256: cea382f0502b89d1389454f7d51709c737a8f19e3d575a29b58db234adf06346
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true require_relative 'base' module Logux module Test module Matchers class ResponseChunks < Base attr_reader :includes, :excludes, :meta def initialize(meta:, includes:, excludes: []) @meta = meta @includes = includes @excludes = excludes end def matches?(actual) @actual = JSON.parse(actual.body) match_includes? && match_excludes? end def failure_message data = "expected that #{pretty(@actual)} to has " \ "#{includes.join(', ')} chunks" !excludes.empty? && data += " and doesn't" \ " has #{excludes.join(', ')} chunks" data end private def match_includes? @actual.any? do |command| includes.include?(command.first) && (meta.nil? || (!meta.empty? && command[1] == meta)) end end def match_excludes? @actual.empty? || @actual.none? do |command| excludes.include?(command.first) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logux-rack-0.1.0 | lib/logux/test/matchers/response_chunks.rb |