Created
May 22, 2020 06:05
-
-
Save dnesteryuk/3e4af9af179dacf7161ffd3a02710223 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'grape' | |
class API < Grape::API | |
prefix :api | |
version 'v1', using: :path | |
resources :users do | |
desc 'return all users' | |
get '/' do | |
puts 'Users' | |
end | |
desc 'returns a user' | |
params do | |
requires :id, type: Integer | |
end | |
get ':id' do | |
puts "User: #{params[:id]}" | |
end | |
end | |
end | |
options = { | |
method: 'GET' | |
} | |
env = Rack::MockRequest.env_for('/api/v1/users/12', options) | |
API.call env |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment