class Logux::Test::Matchers::ResponseChunks
Attributes
excludes[R]
includes[R]
meta[R]
Public Class Methods
new(meta:, includes:, excludes: [])
click to toggle source
# File lib/logux/test/matchers/response_chunks.rb, line 11 def initialize(meta:, includes:, excludes: []) @meta = meta @includes = includes @excludes = excludes end
Public Instance Methods
failure_message()
click to toggle source
# File lib/logux/test/matchers/response_chunks.rb, line 23 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
matches?(actual)
click to toggle source
# File lib/logux/test/matchers/response_chunks.rb, line 17 def matches?(actual) @actual = JSON.parse(actual.body) match_includes? && match_excludes? end
Private Instance Methods
match_excludes?()
click to toggle source
# File lib/logux/test/matchers/response_chunks.rb, line 40 def match_excludes? @actual.empty? || @actual.none? do |command| excludes.include?(command.first) end end
match_includes?()
click to toggle source
# File lib/logux/test/matchers/response_chunks.rb, line 33 def match_includes? @actual.any? do |command| includes.include?(command.first) && (meta.nil? || (!meta.empty? && command[1] == meta)) end end