Sha256: c0225267a7cd630c8e82bbea2b8c06c3d8fc280b645718ff7c8615867a7a2f8b
Contents?: true
Size: 644 Bytes
Versions: 4
Compression:
Stored size: 644 Bytes
Contents
RSpec::Matchers.define :a_postmark_json do |string| def postmark_key?(key) key == ::Postmark::Inflector.to_postmark(key) end def postmark_object?(obj) case obj when Hash return false unless obj.keys.all? { |k| postmark_key?(k) } return false unless obj.values.all? { |v| postmark_object?(v) } when Array return false unless obj.all? { |v| postmark_object?(v) } end true end def postmark_json?(str) return false unless str.is_a?(String) json = Postmark::Json.decode(str) postmark_object?(json) rescue false end match do |actual| postmark_json?(actual) end end
Version data entries
4 entries across 4 versions & 1 rubygems