{"id":13878198,"url":"https://github.com/conversation/miniproxy","last_synced_at":"2025-07-16T14:31:42.425Z","repository":{"id":32673619,"uuid":"138003492","full_name":"conversation/miniproxy","owner":"conversation","description":"Stub requests for browser tests","archived":false,"fork":false,"pushed_at":"2023-04-27T22:44:59.000Z","size":3114,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-11-18T12:37:06.058Z","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/conversation.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":"2018-06-20T08:33:56.000Z","updated_at":"2023-05-24T07:53:12.000Z","dependencies_parsed_at":"2022-08-07T18:00:32.377Z","dependency_job_id":null,"html_url":"https://github.com/conversation/miniproxy","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conversation%2Fminiproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conversation%2Fminiproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conversation%2Fminiproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conversation%2Fminiproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conversation","download_url":"https://codeload.github.com/conversation/miniproxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138849,"owners_count":17579496,"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-08-06T08:01:42.493Z","updated_at":"2025-07-16T14:31:42.415Z","avatar_url":"https://github.com/conversation.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# MiniProxy\n\nA small stubbable proxy server for testing HTTP(S) interactions.\n\n## Supported Versions\n\n* Ruby 3.2, 3.4, 3.4\n\n## Getting Started\n\nIn your Gemfile:\n\n```ruby\ngem 'miniproxy'\n```\n\nConfigure Capybara (via Chrome and Selenium) to route all requests through the server (`spec/support/capybara_driver.rb`):\n\n```ruby\nchrome_options = Selenium::WebDriver::Chrome::Options.new\nchrome_options.add_argument(\"--proxy-server=#{MiniProxy.host}:#{MiniProxy.port}\")\nchrome_options.add_argument(\"--ignore-certificate-errors\") # Required to test HTTPS\n\nCapybara.register_driver :chrome do |app|\n  Capybara::Selenium::Driver.new(app, browser: :chrome, options: chrome_options)\nend\n```\n\nThis configuration will not work in conjunction with `--headless`, which causes chrome to fetch its configuration\nfrom another source and silently ignore command line parameters. For details, see:\nhttps://groups.google.com/a/chromium.org/forum/#!topic/headless-dev/eiudRsYdc3A\n\nMake sure that RSpec resets the server after each test, and stops the server when the suite is finished (`spec/support/mini_proxy.rb`):\n\n```ruby\nrequire \"miniproxy\"\n\nRSpec.configure do |config|\n  config.before :each, type: :feature do\n    MiniProxy.reset\n  end\n\n  config.after :each, type: :feature do\n    # Ignore any requests made between specs\n    MiniProxy.ignore_all_requests\n  end\n\n  config.after :suite do\n    MiniProxy.stop\n  end\nend\n```\n\nIn your specs, to stub a request:\n\n```ruby\nMiniProxy.stub_request(method: \"POST\", url: /example.com/, response: {\n  headers: { \"Foo\" =\u003e \"bar\" },\n  code: 200,\n  body: \"hello\",\n})\n```\n\nThe default behaviour is to block the request, display a warning and return an empty 200 response.\n\nTo allow unstubbed requests to hit external servers, you can use a driver configured without using MiniProxy as a proxy server. However, this is not recommended as you will almost certainly have unreliable tests.\n\n## Allowed Hosts\n\nMiniProxy allows requests from the `127.0.0.1` and `localhost` by default.\n\nIf your test suite runs at a different address, you can configure a custom host using the `MiniProxy.host` option. Example:\n\n```ruby\nMiniProxy.host = \"95.124.236.242\"\n```\n\nWith this configuration, MiniProxy will allow all requests coming from the configured host.\n\nYou also can permit specific requests to pass through the proxy:\n\n```ruby\nMiniProxy.allow_request(method: \"GET\", url: /example.com/)\n```\n\nThis implicitly allows CONNECT requests for 'example.com' to permit HTTPS.\n\n## Developing\n\nPull requests are welcome, we try our best to stick with [semver](https://semver.org/), avoid breaking changes to the API whenever possible.\n\nRun the unit tests:\n\n```\nbundle exec rspec spec/lib\n```\n\nIntegration tests use capybara/selenium/firefox. So you'll need a modern version of Firefox and Geckodriver on your system PATH. They can be run like so:\n\n```\nbundle exec rspec spec/integration\n```\n\nAlternatively you can just rely on CI to run the integration tests.\n\nAnd of course, to run all the tests:\n\n```\nbundle exec rspec\n```\n\n## Alternatives\n\n- [Puffing Billy](https://github.com/oesmith/puffing-billy) - MiniProxy's more capable and more complex cousin\n- [EvilProxy](https://github.com/bbtfr/evil-proxy) - Lighter weight than Puffing Billy, with a focus on HTTPS MITM support\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconversation%2Fminiproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconversation%2Fminiproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconversation%2Fminiproxy/lists"}