summaryrefslogtreecommitdiff
path: root/test/spec_media_type.rb
diff options
context:
space:
mode:
authorArtūrs Mekšs <arturs.mekss@gmail.com>2015-03-17 23:44:50 +0100
committerArtūrs Mekšs <arturs.mekss@gmail.com>2015-06-12 12:35:33 +0200
commita193c5763de43bd61c5b4a13cd05497247b5cadb (patch)
treea39b18a7020386b1e0c3ff1c9052f1fd706c275c /test/spec_media_type.rb
parentdf941b3cc45b15d544f3445e3bfcbdd9add362a6 (diff)
downloadrack-a193c5763de43bd61c5b4a13cd05497247b5cadb.tar.gz
Added media_type methods in Rack::Response
Diffstat (limited to 'test/spec_media_type.rb')
-rw-r--r--test/spec_media_type.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/spec_media_type.rb b/test/spec_media_type.rb
new file mode 100644
index 00000000..e4fac0a8
--- /dev/null
+++ b/test/spec_media_type.rb
@@ -0,0 +1,41 @@
+require 'rack/media_type'
+
+describe Rack::MediaType do
+ before { @empty_hash = {} }
+
+ describe 'when content_type nil' do
+ before { @content_type = nil }
+
+ it '#type is nil' do
+ Rack::MediaType.type(@content_type).should.be.nil
+ end
+
+ it '#params is empty' do
+ Rack::MediaType.params(@content_type).should.equal @empty_hash
+ end
+ end
+
+ describe 'when content_type contains only media_type' do
+ before { @content_type = 'application/text' }
+
+ it '#type is application/text' do
+ Rack::MediaType.type(@content_type).should.equal 'application/text'
+ end
+
+ it '#params is empty' do
+ Rack::MediaType.params(@content_type).should.equal @empty_hash
+ end
+ end
+
+ describe 'when content_type contains media_type and params' do
+ before { @content_type = 'application/text;CHARSET="utf-8"' }
+
+ it '#type is application/text' do
+ Rack::MediaType.type(@content_type).should.equal 'application/text'
+ end
+
+ it '#params has key "charset" with value "utf-8"' do
+ Rack::MediaType.params(@content_type)['charset'].should.equal 'utf-8'
+ end
+ end
+end