Sha256: e5d1a4f77bac040fa7661a04c01024e3037b3f9fa65e9a7d75adadc250600537
Contents?: true
Size: 929 Bytes
Versions: 2
Compression:
Stored size: 929 Bytes
Contents
# frozen_string_literal: true require "addressable/uri" require "public_suffix" # # Abstraction over WebMock to reduce duplication # # @author Mikael Henriksson <mikael@zoolutions.se> # @since 0.1.0 # module StubRequests # # Module ArgumentValidation provides validation of method arguments # module ArgumentValidation extend self # # Require the value to be any of the types past in # # # @param [Object] value the value to validate # @param [Array<Class>, Array<Module>, Class, Module] is_a # # @raise [InvalidType] when the value is disallowed # # @return [true] when the value is allowed # def validate!(value, is_a:) expected_types = Array(is_a) return true if expected_types.any? { |type| value.is_a?(type) } raise StubRequests::InvalidType, actual: value.class, expected: expected_types.join(", ") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stub_requests-0.1.1 | lib/stub_requests/argument_validation.rb |
stub_requests-0.1.0 | lib/stub_requests/argument_validation.rb |