-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers_spec.rb
More file actions
63 lines (54 loc) · 1.54 KB
/
users_spec.rb
File metadata and controls
63 lines (54 loc) · 1.54 KB
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
57
58
59
60
61
62
63
# frozen_string_literal: true
require 'swagger_helper'
describe 'Users API' do
path '/users' do
post 'Registers a new User' do
tags 'Users'
consumes 'application/json'
parameter name: :users, in: :body, schema: {
type: :object,
properties: {
name: { type: :string },
email: { type: :string },
password: { type: :string },
password_confirmation: { type: :string }
},
required: %w[name email password password_confirmation]
}
response '201', 'user created' do
let(:user) { { name: 'Ray', email: 'ray@skywaler.org' } }
run_test!
end
response '422', 'invalid request' do
let(:user) { { name: '' } }
run_test!
end
end
end
path '/users/{id}' do
get 'Retrieves a User' do
tags 'Users'
produces 'application/json'
parameter name: :id, in: :path, type: :string
response '200', 'user found' do
schema type: :object,
properties: {
id: { type: :integer },
name: { type: :string },
email: { type: :string }
},
required: %w[id name email]
let(:id) { User.create(name: 'Rao', email: 'ray@skywalker.org').id }
run_test!
end
response '404', 'user not found' do
let(:id) { 'invalid' }
run_test!
end
response '406', 'unsupported accept header' do
let(:Accept) { 'application/foo' }
run_test!
end
end
end
end