Skip to content

Instantly share code, notes, and snippets.

@alekseyl
Created November 8, 2017 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alekseyl/91359d4fc65ff21dfb7601b3cd46feb4 to your computer and use it in GitHub Desktop.
Save alekseyl/91359d4fc65ff21dfb7601b3cd46feb4 to your computer and use it in GitHub Desktop.
minitest apidoc quote for API-comparision tech note
require_relative "../../spec_helper"
document Albums::Create do
meta :group, "Albums"
meta :request_method, "POST"
meta :request_path, "/albums"
meta :description, "Creates a new album with the given parameters."
param "name", "Name of the album", required: true
param "artist", "Name of the artist", required: true
param "year", "Year of release", required: true
param "rating", "Album rating (1-5)", required: true
example "Successfully creating an album" do
post "/albums", name: "The Meters", artist: "The Meters", year: "1969", rating: "4" do |json|
json.keys.must_include "album"
json["album"]["name"].must_equal "The Meters"
json["album"]["year"].must_be_kind_of Integer
end
end
example "Failure when some parameters are missing" do
post "/albums", name: "The Meters", year: "1969" do |json|
json.keys.must_include "error"
last_response.status.must_equal 400
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment