class Sus::Have::Key
def call(assertions, subject)
def call(assertions, subject) # We want to group all the assertions in to a distinct group: assertions.nested(self, distinct: true) do |assertions| assertions.assert(subject.key?(@name), "has key") if @predicate Expect.new(assertions, subject[@name]).to(@predicate) end end end
def initialize(name, predicate = nil)
def initialize(name, predicate = nil) @name = name @predicate = predicate end
def print(output)
def print(output) output.write("key ", :variable, @name.inspect, :reset, " ", @predicate, :reset) end