Skip to content

Instantly share code, notes, and snippets.

@sharnik
Created March 28, 2014 15:16
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 sharnik/9835178 to your computer and use it in GitHub Desktop.
Save sharnik/9835178 to your computer and use it in GitHub Desktop.
rspec_api_documentation usage example
class FancyAPI < API
patch '/:id' do
object = FancyObject.find(params[:id])
object.update(params[:fancy_object]
object.to_json
end
end
resource "FancyObject" do
set_app FancyAPI
before { @object = FancyObject.create(default_params) }
patch '/:id' do
example_request 'Updating the object', id: @object.id do
expect(status).to == 200
expect(JSON.parse(response_body)['my_fancy_field']).to == 'fancy value'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment