diff options
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 |
