diff options
| author | mokha <mokha@cisco.com> | 2018-05-14 15:16:56 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2018-05-14 15:16:56 -0600 |
| commit | a417b0f2a34582618c93740fd74ca1c620a39e54 (patch) | |
| tree | 04b4922bf963a483a860b81052fbbdc3b450629a /test | |
| parent | 64f0138cff42932a4374c178d1c23d0e7de97fcc (diff) | |
attempt to map body using content type header.
Diffstat (limited to 'test')
| -rw-r--r-- | test/net/content_type_mapper_test.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/net/content_type_mapper_test.rb b/test/net/content_type_mapper_test.rb new file mode 100644 index 0000000..9599202 --- /dev/null +++ b/test/net/content_type_mapper_test.rb @@ -0,0 +1,27 @@ +require 'test_helper' + +class ContentTypeMapperTest < Minitest::Test + def test_returns_json + subject = Net::Hippie::ContentTypeMapper.new + headers = { 'Content-Type' => 'application/json' } + body = { message: 'something witty' } + result = subject.map_from(headers, body) + assert_equal JSON.generate(body), result + end + + def test_returns_json_with_charset + subject = Net::Hippie::ContentTypeMapper.new + headers = { 'Content-Type' => 'application/json; charset=utf-8' } + body = { message: 'something witty' } + result = subject.map_from(headers, body) + assert_equal JSON.generate(body), result + end + + def test_return_html + subject = Net::Hippie::ContentTypeMapper.new + headers = { 'Content-Type' => 'text/html' } + body = "<html></html>" + result = subject.map_from(headers, body) + assert_equal body, result + end +end |
