Sha256: 18e6cdabea01d95abc2228c97fcdb467557478e7f5cf8cf10b7bb62ed76d13a7
Contents?: true
Size: 956 Bytes
Versions: 2
Compression:
Stored size: 956 Bytes
Contents
require './test/test_base.rb' require 'base64' require 'multi_json' class MIMEBuilderJsonTest < Test::Unit::TestCase def test_base test_json = { hello: 'world' } json_part = MIMEBuilder::JSON.new test_json assert_equal 'application/json', json_part.mime.headers.get('Content-Type') assert_equal Base64.encode64(MultiJson.encode(test_json)), json_part.mime.body.to_s assert_equal nil, json_part.mime.headers.get('Content-Id') end def test_no_base64 test_json = { hello: 'world' } test_json = MultiJson.encode test_json json_part = MIMEBuilder::JSON.new test_json, encode_base64: false assert_equal test_json, json_part.mime.body.to_s end def test_base64_raw info = { hello: 'world' } builder = MIMEBuilder::JSON.new info, encode_base64: true assert_equal 'eyJoZWxsbyI6IndvcmxkIn0='.encode('iso-8859-1'), builder.mime.body.to_s.strip assert_equal true, builder.encode_base64? end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mime_builder-0.1.1 | test/test_json.rb |
mime_builder-0.1.0 | test/test_json.rb |