{"id":13428124,"url":"https://github.com/r7kamura/response_code_matchers","last_synced_at":"2025-10-12T05:10:17.576Z","repository":{"id":5688297,"uuid":"6898698","full_name":"r7kamura/response_code_matchers","owner":"r7kamura","description":"Provide rspec matchers to match http response code","archived":false,"fork":false,"pushed_at":"2017-06-05T19:53:50.000Z","size":20,"stargazers_count":61,"open_issues_count":0,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-10-02T21:31:30.920Z","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":"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}},"created_at":"2012-11-28T08:26:41.000Z","updated_at":"2025-09-21T06:44:22.000Z","dependencies_parsed_at":"2022-08-19T10:32:34.550Z","dependency_job_id":null,"html_url":"https://github.com/r7kamura/response_code_matchers","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/r7kamura/response_code_matchers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Fresponse_code_matchers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Fresponse_code_matchers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Fresponse_code_matchers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Fresponse_code_matchers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r7kamura","download_url":"https://codeload.github.com/r7kamura/response_code_matchers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Fresponse_code_matchers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007610,"owners_count":26084336,"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-11T02:00:06.511Z","response_time":55,"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":[],"created_at":"2024-07-31T01:00:46.809Z","updated_at":"2025-10-12T05:10:17.543Z","avatar_url":"https://github.com/r7kamura.png","language":"Ruby","readme":"# ResponseCodeMatchers [![Build Status](https://travis-ci.org/r7kamura/response_code_matchers.svg?branch=master)](https://travis-ci.org/r7kamura/response_code_matchers)\nProvide rspec matchers to match http response code.  \nThe receiver of this matcher should have `#code` or `#status` method which returns http status code,\n and `#header` and `#headers` methods.\n\n## Installation\n```\n$ gem install response_code_matchers\n```\n\n## Usage\nIn Rails example:\n\n```ruby\n# spec/spec_helper.rb\nrequire \"response_code_matchers\"\n\nRSpec.configure do |config|\n  config.include ResponseCodeMatchers\nend\n```\n\n```ruby\n# spec/controllers/blogs_controller.rb\ndescribe BlogsController do\n  describe \"#create\" do\n    subject do\n      post :create, params\n    end\n\n    let(:params) do\n      { :title =\u003e \"title\", :body =\u003e \"body\", :token =\u003e \"token\", :user_id =\u003e 1 }\n    end\n\n    # 201\n    context \"with valid token\" do\n      it { should be_created }\n    end\n\n    # 400\n    context \"without user_id\" do\n      before do\n        params.delete(:user_id)\n      end\n\n      it { should be_bad_request }\n    end\n\n    # 401\n    context \"with invalid token\" do\n      before do\n        params[:token] = \"invalid\"\n      end\n\n      it { should be_unauthorized }\n    end\n  end\nend\n```\n\n\n## Advantage\n[Rack::Response](https://github.com/rack/rack/blob/master/lib/rack/response.rb) has predicative methods like `#not_found?`, `#bad_request?`, and etc. so we can use `response.should be_not_found` without this gem.\n\nThere are 2 advantages to use this gem.\n\n1. The range of differences that Rack::Response does not have\n2. Useful failure messages for each failed reason\n\n```\n# without response_code_matchers.gem\nexpected not_found? to return true, got false\n\n# with response_code_matchers.gem\nexpected response code to be 404, got 400\n```\n\n\n## Matchers\n```ruby\n100: response.should be_continue\n101: response.should be_switching_protocols\n102: response.should be_processing\n200: response.should be_ok\n201: response.should be_created\n202: response.should be_accepted\n203: response.should be_non_authoritative_information\n204: response.should be_no_content\n205: response.should be_reset_content\n206: response.should be_partial_content\n207: response.should be_multi_status\n226: response.should be_im_used\n300: response.should be_multiple_choices\n301: response.should be_moved_permanently\n302: response.should be_found\n303: response.should be_see_other\n304: response.should be_not_modified\n305: response.should be_use_proxy\n307: response.should be_temporary_redirect\n400: response.should be_bad_request\n401: response.should be_unauthorized\n402: response.should be_payment_required\n403: response.should be_forbidden\n404: response.should be_not_found\n405: response.should be_method_not_allowed\n406: response.should be_not_acceptable\n407: response.should be_proxy_authentication_required\n408: response.should be_request_timeout\n409: response.should be_conflict\n410: response.should be_gone\n411: response.should be_length_required\n412: response.should be_precondition_failed\n413: response.should be_payload_too_large\n414: response.should be_uri_too_long\n415: response.should be_unsupported_media_type\n416: response.should be_range_not_satisfiable\n417: response.should be_expectation_failed\n418: response.should be_im_a_teapot\n422: response.should be_unprocessable_entity\n423: response.should be_locked\n424: response.should be_failed_dependency\n426: response.should be_upgrade_required\n500: response.should be_internal_server_error\n501: response.should be_not_implemented\n502: response.should be_bad_gateway\n503: response.should be_service_unavailable\n504: response.should be_gateway_timeout\n505: response.should be_http_version_not_supported\n506: response.should be_variant_also_negotiates\n507: response.should be_insufficient_storage\n510: response.should be_not_extended\n```\n","funding_links":[],"categories":["Testing","测试"],"sub_categories":["Omniauth"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr7kamura%2Fresponse_code_matchers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr7kamura%2Fresponse_code_matchers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr7kamura%2Fresponse_code_matchers/lists"}