module ShapeOf::Assertions

To be included in a MiniTest test class

Public Instance Methods

assert_shape_of(object, shape) click to toggle source
# File lib/shape_of.rb, line 90
def assert_shape_of(object, shape)
  if shape.respond_to? :shape_of?
    assert_operator shape, :shape_of?, object
  elsif shape.instance_of? ::Array
    assert_operator Array[shape.first], :shape_of?, object
  elsif shape.instance_of? ::Hash
    assert_operator Hash[shape], :shape_of?, object
  else
    raise TypeError, "Expected #{Shape.inspect}, an #{::Array.inspect}, or a #{::Hash.inspect} as the shape"
  end
end
refute_shape_of(object, shape) click to toggle source
# File lib/shape_of.rb, line 102
def refute_shape_of(object, shape)
  if shape.respond_to? :shape_of?
    refute_operator shape, :shape_of?, object
  elsif shape.instance_of? ::Array
    refute_operator Array[shape.first], :shape_of?, object
  elsif shape.instance_of? ::Hash
    refute_operator Hash[shape], :shape_of?, object
  else
    raise TypeError, "Expected #{Shape.inspect}, an #{::Array.inspect}, or a #{::Hash.inspect} as the shape"
  end
end