module MinitestToRspec::Type
Runtime type assertions.
Public Class Methods
assert(types, value)
click to toggle source
# File lib/minitest_to_rspec/type.rb, line 7 def assert(types, value) unless array_wrap(types).any? { |t| value.is_a?(t) } raise TypeError, "Expected #{types}, got #{value}" end end
bool(value)
click to toggle source
# File lib/minitest_to_rspec/type.rb, line 13 def bool(value) unless [false, true].include?(value) raise TypeError, "Expected Boolean, got #{value}" end end
Private Class Methods
array_wrap(object)
click to toggle source
Implementation copied from Array.wrap in ActiveSupport 5
# File lib/minitest_to_rspec/type.rb, line 22 def array_wrap(object) if object.nil? [] elsif object.respond_to?(:to_ary) object.to_ary || [object] else [object] end end