{"id":19055759,"url":"https://github.com/taskrabbit/tests_doc","last_synced_at":"2025-04-24T04:29:29.730Z","repository":{"id":2406331,"uuid":"46468978","full_name":"taskrabbit/tests_doc","owner":"taskrabbit","description":"Rspec request specs recorded as Markdown files","archived":false,"fork":false,"pushed_at":"2023-06-13T18:16:51.000Z","size":86,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-04-13T07:07:43.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taskrabbit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-11-19T05:07:27.000Z","updated_at":"2022-06-03T20:46:54.000Z","dependencies_parsed_at":"2023-07-05T19:48:58.178Z","dependency_job_id":null,"html_url":"https://github.com/taskrabbit/tests_doc","commit_stats":{"total_commits":36,"total_committers":4,"mean_commits":9.0,"dds":0.25,"last_synced_commit":"7eadebaf61580840f206a10ddd12621e334b3585"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taskrabbit%2Ftests_doc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taskrabbit%2Ftests_doc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taskrabbit%2Ftests_doc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taskrabbit%2Ftests_doc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taskrabbit","download_url":"https://codeload.github.com/taskrabbit/tests_doc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250564030,"owners_count":21450942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T23:46:54.166Z","updated_at":"2025-04-24T04:29:29.704Z","avatar_url":"https://github.com/taskrabbit.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TestsDoc\n\nThis library allow to output requests specs into readable markdown files.\nIt can link the markdown file to the spec ran.\n\n**This library supports RSpec 2 and RSpec 3**\n\n## Install\n\n`gem install tests_doc`\n\n## Example Output\n\n# GET users\n\nRspec description: Users GET /users renders users\n\n[spec/requests/users_spec.rb:5](/examples/rails-4.2.5/spec/requests/users_spec.rb#L5)\n\n# Parameters\n\n```json\n{\n}\n```\n\n# Response\n\n```\nHTTP CODE = 200\n```\n\n```json\n[\n  {\n    \"id\": 298486374,\n    \"email\": \"MyString\",\n    \"first_name\": \"MyString\",\n    \"last_name\": \"MyString\",\n    \"created_at\": \"2015-11-19T01:11:08.000Z\",\n    \"updated_at\": \"2015-11-19T01:11:08.000Z\"\n  },\n]\n```\n\n## Example App\n\nYou can see a [Rails 4 example app](/examples/rails-4.2.5) with the recorded markdown inside the [tests-doc folder](/examples/rails-4.2.5/tests-doc)\n\n## Usage\n\nIn your `spec_helper.rb` RSpec file:\n\n```ruby\nrequire 'tests_doc'\n\nconfig.include ::TestsDoc::RecordSpecHelper, type: :request\n\nTestsDoc.configure do |config|\n  # The regexes allow you to by pass run time object updated_at and other ids\n  # run time object between each execution\n  config.changes_whitelist_regex      = /(.*\\\"((id)|([\\w]+((_id)|(_at))))\\\":.*\\n)|(.*_ids\":\\s\\[\\s*\\w+\\s*\\])/ # default: \"\"\n\n  # OR\n  config.changes_whitelist_regexes = [\n    /\\\"id\\\":.*\\n/,\n    /_id\\\":.*\\n/,\n    /_at\\\":.*\\n/,\n    /.*_ids\":\\s\\[\\s*\\w+\\s*\\]/\n  ]\n\n  # Folder location where the tests doc will be stored\n  config.root_folder = Rails.root.join(\"api_interactions\")  # default: tests-doc\n\n  # Folder name where the tests doc will be stored\n  config.doc_folder  = 'api' # default: api\n\n  # Key separator between the path and the key\n  config.key_separator = '@' # default: @\n\n  # Add RSpec line number to the test doc\n  config.add_spec_file_number = false # default: true\n\n  # tests-doc file will save the timestamps of the last modification\n  config.add_index_timestamps = false # default: true\n\n  # Will output the diff debug of recorded test docs\n  config.debug = true # default: false\nend\n\n```\n\n### Recording interactions in your tests\n\nIn your request spec file simply wrap your request with `recording_api_interaction`:\n\n```ruby\nrecording_api_interaction do\n  get users_path\nend\n```\n\nYou can also set options for the recording:\n\n* The `key` option allows to record a test doc and append to the file name the key:\n\n```ruby\nrecording_api_interaction do |options|\n  options.key = 'with-filter'\n  get posts_path(published: true)\nend\n```\n\nWill generate a markdown file named `posts@with-filter.md`.\n\n* The `path` option allows to specify the path you want, a good reason for that is that you want to extract the id of you ActiveRecord object.\n\n```ruby\nrecording_api_interaction do |options|\n  options.path = 'users/@id/posts'\n  get user_posts_path(User.first)\nend\n```\n\nWill generate here a markdown file named `posts.md` in the [users/@id](/examples/rails-4.2.5/tests-doc/api/users/@id) folder.\n\n* the `whitelist` option allow you to add on the global regex whitelist:\n\n```ruby\nrecording_api_interaction do |options|\n  options.whitelist = /\\\"token\\\":.*\\n/\n  get users_path(User.first)\nend\n```\n\n### Generating the Index file\n\nYou can generate the index file that list all endpoint using the following rake command.\n\n`rake tests_doc:index:build`\n\nIf you want to only build it if there is a git changes on your file:\n\n`rake tests_doc:index:build_if_changed`\n\nYou could also specify which folder to use for the index file:\n\n`rake \"tests_doc:index:build_if_changed[api_interactions]\"`\n\nIt's also possible to rewrite the index after the RSpec suite:\n\n```ruby\nconfig.after :suite do |test|\n  # block executed when there is any api interactions were recorded during the RSpec\n  TestsDoc.with_api_interaction do\n    require 'rake'\n    require 'tests_doc/tasks'\n\n    Rake::Task[\"tests_doc:index:build_if_changed\"].invoke(TestsDoc.configuration.root_folder)\n  end\nend\n```\n\n## TODO\n\n* Add tests\n* Publish gem\n* Fix warnings\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaskrabbit%2Ftests_doc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaskrabbit%2Ftests_doc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaskrabbit%2Ftests_doc/lists"}