Sha256: 63374e95e50b8e1fb73c4950a0c1678d872e09c23e5914764f19b3158a35e6d0

Contents?: true

Size: 673 Bytes

Versions: 1

Compression:

Stored size: 673 Bytes

Contents

require './test/test_base.rb'

require 'base64'

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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mime_builder-0.0.4 test/test_json.rb