This gems allow to output requests specs into readable markdown files.
It links the output to the example file where it was run.
This currently only work with RSpec 2
In your spec_helper.rb
RSpec file:
require 'tests_doc'
config.include ::TestsDoc::RecordSpecHelper, type: :request
TestsDoc.configure do |config|
config.changes_whitelist_regex = /(.*\"((id)|([\w]+((_id)|(_at))))\":.*\n)|(.*_ids":\s\[\s*\w+\s*\])/ # default: ""
# OR
config.changes_whitelist_regexes = [
/\"id\":.*\n/,
/_id\":.*\n/,
/_at\":.*\n/,
/.*_ids":\s\[\s*\w+\s*\]/
]
config.root_folder = Rails.root.join("api_interactions") # default: tests-doc
config.add_spec_file_number = false # default: true
config.add_index_timestamps = false # default: true
config.debug = true # default: false
end
You can generate the index file that list all endpoint using the following rake command.
rake tests_doc:index:build
If you want to only build it if there is a git changes on your file:
rake tests_doc:index:build_if_changed
You could also specify which folder to use for the index file:
rake "tests_doc:index:build_if_changed[api_interactions]"
It's also possible to rewrite the index after the RSpec suite:
config.after :suite do |test|
# block executed when there is any api interactions were recorded during the RSpec
TestsDoc.with_api_interaction do
require 'rake'
require 'tests_doc/tasks'
Rake::Task["tests_doc:index:build_if_changed"].invoke(TestsDoc.configuration.root_folder)
end
end
- Add tests
- Publish gem
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request