Skip to content

Setting up RspecApiDocumentation

oestrich edited this page May 23, 2012 · 5 revisions

Installation

Add RspecApiDocumentation to your Gemfile

gem 'rspec_api_documentation'

Bundle it!

$ bundle

Configuration

By default RspecApiDocumentation will save generated documents into docs. The outputted format is HTML. You can edit spec/spec_helper.rb to change configuration options. The README contains more information about configuration options.

Writing specs

RspecApiDocumentation looks for documentation in spec/acceptance. It will run anything underneath this directory with the suffix _spec.

See the example app for how to use the DSL.

Generate Documentation

The gem contains a Railtie that defines a rake task for generating docs easily with Rails.

$ rake docs:generate

If you are not using Rails, you can use Rake with the following Task:

require 'rspec/core/rake_task'

desc 'Generate API request documentation from API specs'
  RSpec::Core::RakeTask.new('docs:generate') do |t|
  t.pattern = 'spec/acceptance/**/*_spec.rb'
  t.rspec_opts = ["--format RspecApiDocumentation::ApiFormatter"]
end

or

require 'rspec_api_documentation'
load 'tasks/docs.rake'

If you are not using Rake:

$ rspec spec/ --format RspecApiDocumentation::ApiFormatter
Clone this wiki locally