{"id":13878522,"url":"https://github.com/r7kamura/rspec-request_describer","last_synced_at":"2025-10-05T07:57:00.283Z","repository":{"id":20178154,"uuid":"23449077","full_name":"r7kamura/rspec-request_describer","owner":"r7kamura","description":"RSpec plugin to write self-documenting request-specs.","archived":false,"fork":false,"pushed_at":"2025-09-17T22:05:07.000Z","size":87,"stargazers_count":186,"open_issues_count":2,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-18T00:13:19.721Z","etag":null,"topics":["rspec"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"QueenHopeJaquez/Sonic8Forum","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r7kamura.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"r7kamura"}},"created_at":"2014-08-29T01:49:43.000Z","updated_at":"2025-09-17T22:05:09.000Z","dependencies_parsed_at":"2024-06-12T08:09:00.191Z","dependency_job_id":"28f1b0da-76bc-4196-bea3-49fb4f4404af","html_url":"https://github.com/r7kamura/rspec-request_describer","commit_stats":{"total_commits":107,"total_committers":13,"mean_commits":8.23076923076923,"dds":"0.14018691588785048","last_synced_commit":"3bc82b56ecf2f1d65e67a4048e8a33cdf9b0e03b"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/r7kamura/rspec-request_describer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Frspec-request_describer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Frspec-request_describer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Frspec-request_describer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Frspec-request_describer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r7kamura","download_url":"https://codeload.github.com/r7kamura/rspec-request_describer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Frspec-request_describer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278425493,"owners_count":25984687,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["rspec"],"created_at":"2024-08-06T08:01:52.059Z","updated_at":"2025-10-05T07:57:00.262Z","avatar_url":"https://github.com/r7kamura.png","language":"Ruby","funding_links":["https://github.com/sponsors/r7kamura"],"categories":["Ruby"],"sub_categories":[],"readme":"# RSpec::RequestDescriber\n\n[![test](https://github.com/r7kamura/rspec-request_describer/actions/workflows/test.yml/badge.svg)](https://github.com/r7kamura/rspec-request_describer/actions/workflows/test.yml)\n[![Gem Version](https://badge.fury.io/rb/rspec-request_describer.svg)](https://rubygems.org/gems/rspec-request_describer)\n\nRSpec plugin to write self-documenting request-specs.\n\nThis gem is designed for:\n\n- [rack-test](https://github.com/rack-test/rack-test)\n- [rspec-rails](https://github.com/rspec/rspec-rails)\n\n## Setup\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngroup :test do\n  gem 'rspec-request_describer'\nend\n```\n\nAnd then include `RSpec::RequestDescriber`:\n\n```ruby\n# spec/rails_helper.rb\nRSpec.configure do |config|\n  config.include RSpec::RequestDescriber, type: :request\nend\n```\n\n## Usage\n\nWrite HTTP method and URL path in the top-level description of your request-specs.\n\n```ruby\n# spec/requests/users/index_spec.rb\nRSpec.describe 'GET /users' do\n  it 'returns 200' do\n    subject\n    expect(response).to have_http_status(200)\n  end\nend\n```\n\nInternally, `RSpec::RequestDescriber` defines `subject` and some `let` from its top-level description like this:\n\n```ruby\nRSpec.describe 'GET /users' do\n  subject do\n    __send__(http_method, path, headers:, params:)\n  end\n\n  let(:http_method) do\n    'get'\n  end\n\n  let(:path) do\n    '/users'\n  end\n\n  let(:headers) do\n    {}\n  end\n\n  let(:params) do\n    {}\n  end\n\n  it 'returns 200' do\n    subject\n    expect(response).to have_http_status(200)\n  end\nend\n```\n\n### headers\n\nIf you want to modify request headers, change `headers`:\n\n```ruby\nRSpec.describe 'GET /users' do\n  context 'with Authorization header' do\n    before do\n      headers['Authorization'] = 'token 12345'\n    end\n\n    it 'returns 200' do\n      subject\n      expect(response).to have_http_status(200)\n    end\n  end\nend\n```\n\n### params\n\nIf you want to modify request parameters, change `params`:\n\n```ruby\nRSpec.describe 'GET /users' do\n  context 'with sort parameter' do\n    before do\n      params['sort'] = 'id'\n    end\n\n    it 'returns 200 with expected JSON body' do\n      subject\n      expect(response).to have_http_status(200)\n      expect(response.parsed_body).to match(\n        [\n          hash_including('id' =\u003e 1),\n          hash_including('id' =\u003e 2),\n        ]\n      )\n    end\n  end\nend\n```\n\n### path parameters\n\nYou can embed variables in URL path like `/users/:user_id`.\nIn this example, the returned value from `#user_id` method will be embedded as its real value.\n\n```ruby\nRSpec.describe 'GET /users/:user_id' do\n  let(:user) do\n    User.create(name: 'alice')\n  end\n\n  let(:user_id) do\n    user.id\n  end\n\n  it 'returns 200' do\n    subject\n    expect(response).to have_http_status(200)\n  end\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr7kamura%2Frspec-request_describer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr7kamura%2Frspec-request_describer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr7kamura%2Frspec-request_describer/lists"}