spec/unit/rack/render_spec.rb in goliath-0.9.1 vs spec/unit/rack/render_spec.rb in goliath-0.9.2
- old
+ new
@@ -39,29 +39,34 @@
status, headers, body = render.call(env)
headers['Vary'].should == 'Accept'
end
end
+ CONTENT_TYPES = {
+ 'rss' => 'application/rss+xml',
+ 'xml' => 'application/xml',
+ 'html' => 'text/html',
+ 'json' => 'application/json',
+ 'yaml' => 'text/yaml',
+ }
+
describe 'Content-Type' do
before(:each) do
app.should_receive(:call).and_return([200, {}, {}])
end
describe 'from header' do
- %w(application/json text/html application/rss+xml application/xml).each do |type|
+ CONTENT_TYPES.values.each do |type|
it "handles content type for #{type}" do
env['HTTP_ACCEPT'] = type
status, headers, body = render.call(env)
headers['Content-Type'].should =~ /^#{Regexp.escape(type)}/
end
end
end
describe 'from URL param' do
- {'rss' => 'application/rss+xml',
- 'xml' => 'application/xml',
- 'html' => 'text/html',
- 'json' => 'application/json'}.each_pair do |format, content_type|
+ CONTENT_TYPES.each_pair do |format, content_type|
it "converts #{format} to #{content_type}" do
env['params']['format'] = format
status, headers, body = render.call(env)
headers['Content-Type'].should =~ /^#{Regexp.escape(content_type)}/
end