2015-12-19 03:29:48 +08:00
require 'spec_helper'
def details
2016-05-07 03:00:36 +08:00
<<-DETAILS
2015-12-19 03:29:48 +08:00
# Burgers in Heaven
> A burger doesn ' t come for free
If you want to reserve a burger in heaven , you have to do
some crazy stuff on earth .
` ` `
def do_good
puts 'help people'
end
` ` `
* _Will go to Heaven : _ Probably
* _Will go to Hell : _ Probably not
DETAILS
end
describe 'details' do
2016-05-07 03:00:36 +08:00
describe 'take deatils as it is' do
2016-05-07 09:12:26 +08:00
include_context " #{ MODEL_PARSER } swagger example "
2015-12-19 03:29:48 +08:00
before :all do
module TheApi
class DetailApi < Grape :: API
format :json
desc 'This returns something' ,
2016-05-07 03:00:36 +08:00
detail : 'detailed description of the route' ,
entity : Entities :: UseResponse ,
failure : [ { code : 400 , model : Entities :: ApiError } ]
2015-12-19 03:29:48 +08:00
get '/use_detail' do
2016-05-07 03:00:36 +08:00
{ 'declared_params' = > declared ( params ) }
2015-12-19 03:29:48 +08:00
end
desc 'This returns something' do
detail 'detailed description of the route inside the `desc` block'
entity Entities :: UseResponse
2016-05-07 03:00:36 +08:00
failure [ { code : 400 , model : Entities :: ApiError } ]
2015-12-19 03:29:48 +08:00
end
get '/use_detail_block' do
2016-05-07 03:00:36 +08:00
{ 'declared_params' = > declared ( params ) }
2015-12-19 03:29:48 +08:00
end
add_swagger_documentation
end
end
end
def app
TheApi :: DetailApi
end
subject do
get '/swagger_doc'
JSON . parse ( last_response . body )
end
specify do
expect ( subject [ 'paths' ] [ '/use_detail' ] [ 'get' ] ) . to include ( 'description' )
2016-04-08 09:05:35 +08:00
expect ( subject [ 'paths' ] [ '/use_detail' ] [ 'get' ] [ 'description' ] ) . to eql " This returns something \n detailed description of the route "
2015-12-19 03:29:48 +08:00
end
specify do
expect ( subject [ 'paths' ] [ '/use_detail_block' ] [ 'get' ] ) . to include ( 'description' )
2016-04-08 09:05:35 +08:00
expect ( subject [ 'paths' ] [ '/use_detail_block' ] [ 'get' ] [ 'description' ] ) . to eql " This returns something \n detailed description of the route inside the `desc` block "
2015-12-19 03:29:48 +08:00
end
end
describe 'details, convert markdown with kramdown' do
2016-05-07 09:12:26 +08:00
include_context " #{ MODEL_PARSER } swagger example "
2015-12-19 03:29:48 +08:00
before :all do
module TheApi
class GfmDetailApi < Grape :: API
format :json
desc 'This returns something' ,
2016-05-07 03:00:36 +08:00
detail : details ,
entity : Entities :: UseResponse ,
failure : [ { code : 400 , model : Entities :: ApiError } ]
2015-12-19 03:29:48 +08:00
get '/use_gfm_detail' do
2016-05-07 03:00:36 +08:00
{ 'declared_params' = > declared ( params ) }
2015-12-19 03:29:48 +08:00
end
add_swagger_documentation markdown : GrapeSwagger :: Markdown :: KramdownAdapter . new
end
end
end
def app
TheApi :: GfmDetailApi
end
subject do
get '/swagger_doc'
JSON . parse ( last_response . body )
end
specify do
expect ( subject [ 'paths' ] [ '/use_gfm_detail' ] [ 'get' ] ) . to include ( 'description' )
expect ( subject [ 'paths' ] [ '/use_gfm_detail' ] [ 'get' ] [ 'description' ] ) . to eql (
2016-04-08 09:05:35 +08:00
" <h1 id= \" this-returns-something \" >This returns something</h1> \n <p> # Burgers in Heaven</p> \n \n <blockquote> \n <p>A burger doesn’ t come for free</p> \n </blockquote> \n \n <p>If you want to reserve a burger in heaven, you have to do<br /> \n some crazy stuff on earth.</p> \n \n <pre><code>def do_good \n puts 'help people' \n end \n </code></pre> \n \n <ul> \n <li><em>Will go to Heaven:</em> Probably</li> \n <li><em>Will go to Hell:</em> Probably not</li> \n </ul> "
2015-12-19 03:29:48 +08:00
)
end
end
2016-02-02 03:54:23 +08:00
describe 'details, convert markdown with redcarpet' , unless : RUBY_PLATFORM . eql? ( 'java' ) do
2016-05-07 09:12:26 +08:00
include_context " #{ MODEL_PARSER } swagger example "
2015-12-19 03:29:48 +08:00
before :all do
module TheApi
class GfmRcDetailApi < Grape :: API
format :json
desc 'This returns something' ,
2016-05-07 03:00:36 +08:00
detail : details ,
entity : Entities :: UseResponse ,
failure : [ { code : 400 , model : Entities :: ApiError } ]
2015-12-19 03:29:48 +08:00
get '/use_gfm_rc_detail' do
2016-05-07 03:00:36 +08:00
{ 'declared_params' = > declared ( params ) }
2015-12-19 03:29:48 +08:00
end
add_swagger_documentation markdown : GrapeSwagger :: Markdown :: RedcarpetAdapter . new
end
end
end
def app
TheApi :: GfmRcDetailApi
end
subject do
get '/swagger_doc'
JSON . parse ( last_response . body )
end
specify do
expect ( subject [ 'paths' ] [ '/use_gfm_rc_detail' ] [ 'get' ] ) . to include ( 'description' )
expect ( subject [ 'paths' ] [ '/use_gfm_rc_detail' ] [ 'get' ] [ 'description' ] ) . to eql (
2016-06-18 01:56:24 +08:00
" <h1>This returns something</h1> \n \n <p> # Burgers in Heaven</p> \n \n <blockquote> \n <p>A burger doesn& # 39;t come for free</p> \n </blockquote> \n \n <p>If you want to reserve a burger in heaven, you have to do \n some crazy stuff on earth.</p> \n <pre class= \" highlight plaintext \" ><code>def do_good \n puts 'help people' \n end \n </code></pre> \n <ul> \n <li><em>Will go to Heaven:</em> Probably</li> \n <li><em>Will go to Hell:</em> Probably not</li> \n </ul> "
2015-12-19 03:29:48 +08:00
)
end
end
end