forked from ruby-grape/grape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeeply_included_options_spec.rb
56 lines (46 loc) · 1.11 KB
/
deeply_included_options_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'spec_helper'
module DeeplyIncludedOptionsSpec
module Defaults
extend ActiveSupport::Concern
included do
format :json
end
end
module Admin
module Defaults
extend ActiveSupport::Concern
include DeeplyIncludedOptionsSpec::Defaults
end
class Users < Grape::API
include DeeplyIncludedOptionsSpec::Admin::Defaults
resource :users do
get do
status 200
end
end
end
end
class Main < Grape::API
mount DeeplyIncludedOptionsSpec::Admin::Users
end
end
describe Grape::API do
subject { DeeplyIncludedOptionsSpec::Main }
def app
subject
end
it 'works for unspecified format' do
get '/users'
expect(last_response.status).to eql 200
expect(last_response.content_type).to eql 'application/json'
end
it 'works for specified format' do
get '/users.json'
expect(last_response.status).to eql 200
expect(last_response.content_type).to eql 'application/json'
end
it "doesn't work for format different than specified" do
get '/users.txt'
expect(last_response.status).to eql 404
end
end