From a417b0f2a34582618c93740fd74ca1c620a39e54 Mon Sep 17 00:00:00 2001 From: mokha Date: Mon, 14 May 2018 15:16:56 -0600 Subject: attempt to map body using content type header. --- test/net/content_type_mapper_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/net/content_type_mapper_test.rb (limited to 'test') 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 = "" + result = subject.map_from(headers, body) + assert_equal body, result + end +end -- cgit v1.2.3