Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aryeh-looker/277a196269e9cfc8755f8315f29f39e2 to your computer and use it in GitHub Desktop.
Save aryeh-looker/277a196269e9cfc8755f8315f29f39e2 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'faraday'
conn = Faraday.new(:url => 'http://localhost:4567') do |builder|
builder.adapter(Faraday.default_adapter)
end
get '/run-test' do
response200 = (conn.post '/200').status rescue 'raised error'
response400 = (conn.post '/400').status rescue 'raised error'
response500 = (conn.post '/500').status rescue 'raised error'
[
"response200: #{response200.inspect}",
"response400: #{response400.inspect}",
"response500: #{response500.inspect}"
].join("\n")
end
post '/200' do
status 200
end
post '/400' do
status 400
end
post '/500' do
status 500
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment