This repository was archived by the owner on Dec 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathapp.rb
101 lines (81 loc) · 1.62 KB
/
app.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
require 'rubygems'
require 'sinatra'
set :static, true
set :public, Proc.new { File.expand_path('.') }
get '/tests.js' do
content_type 'application/javascript'
files = []
Dir["#{File.join(File.expand_path('.'), 'test', 'unit')}/*.html"].each do |file|
files << "'#{File.basename(file)}'"
end
"var test_files = [#{files.join(',')}];"
end
get '/reviews' do
'[{"id": "1", "title":"Local, baby"}]'
end
get '/reviews_with_content_type' do
content_type 'application/json'
'[{"id": "1", "title":"Local, baby"}]'
end
post '/reviews' do
'{"id": "1"}'
end
post '/alternate_reviews' do
'{"id": "2"}'
end
get '/string_back/1' do
'found a string'
end
post '/string_back' do
'some string'
end
post '/test_id' do
if params[:alternate_object]
if params[:id]
'fail'
end
else
'ok'
end
end
get '/rails_reviews' do
'[{"rails_review": {"id":"1", "title": "Did you include the root?"}}]'
end
post '/rails_reviews' do
if params[:rails_review]
'{"rails_review": {"id":"1"}}'
else
'fail'
end
end
get '/rails_reviews/1' do
'{"rails_review": {"id":"1"}}'
end
get '/alternate_rails_reviews/1' do
'{"alternate_rails_review": {"id":"1"}}'
end
post '/alternate_rails_reviews' do
if params[:alternate_object]
'ok'
else
'fail'
end
end
post '/auth_token' do
params[:authenticity_token]
end
get '/reviews/2' do
'{"id": "2", "title":"funtimes"}'
end
get '/reviews/:id' do
'{"id": "1", "title":"More Magic!"}'
end
get '/my/reviews/:id' do
'{"id": "1", "title":"Prefixed"}'
end
put '/reviews/:id' do
'{"id": "1", "title":"Updated"}'
end
delete '/reviews/:id' do
'Deleted OK'
end