File tree Expand file tree Collapse file tree 4 files changed +17
-6
lines changed
Expand file tree Collapse file tree 4 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -10,4 +10,5 @@ group :development, :test do
1010 gem 'rb-fsevent'
1111 gem 'growl'
1212 gem 'json'
13+ gem 'debugger'
1314end
Original file line number Diff line number Diff line change @@ -310,7 +310,7 @@ You can also set the default format. The order for choosing the format is the fo
310310* Use the format, if specified by the ` format ` option.
311311* Attempt to find an acceptable format from the ` Accept ` header.
312312* Use the default format, if specified by the ` default_format ` option.
313- * Default to ` :txt ` otherwise.
313+ * Default to ` :json ` otherwise.
314314
315315``` ruby
316316class Twitter ::API < Grape ::API
@@ -319,6 +319,16 @@ class Twitter::API < Grape::API
319319end
320320```
321321
322+ By default, Grape understands the following content types:
323+
324+ ``` ruby
325+ :xml => ' application/xml' ,
326+ :json => ' application/json' ,
327+ :atom => ' application/atom+xml' ,
328+ :rss => ' application/rss+xml' ,
329+ :txt => ' text/plain'
330+ ```
331+
322332## Writing Tests
323333
324334You can test a Grape API with RSpec by making HTTP requests and examining the response.
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class Formatter < Base
77
88 def default_options
99 {
10- :default_format => :txt ,
10+ :default_format => :json ,
1111 :formatters => { } ,
1212 :content_types => { } ,
1313 :parsers => { }
Original file line number Diff line number Diff line change @@ -70,16 +70,16 @@ def to_xml
7070
7171 it 'should use the default format if none is provided' do
7272 subject . call ( { 'PATH_INFO' => '/info' } )
73- subject . env [ 'api.format' ] . should == :txt
73+ subject . env [ 'api.format' ] . should == :json
7474 end
7575
7676 it 'should use the requested format if provided in headers' do
77- subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT' => 'application/json ' } )
78- subject . env [ 'api.format' ] . should == :json
77+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT' => 'text/plain ' } )
78+ subject . env [ 'api.format' ] . should == :txt
7979 end
8080
8181 it 'should use the file extension format if provided before headers' do
82- subject . call ( { 'PATH_INFO' => '/info.txt' , 'HTTP_ACCEPT' => 'application/json ' } )
82+ subject . call ( { 'PATH_INFO' => '/info.txt' , 'HTTP_ACCEPT' => 'text/plain ' } )
8383 subject . env [ 'api.format' ] . should == :txt
8484 end
8585
You can’t perform that action at this time.
0 commit comments