{"id":15406466,"url":"https://github.com/odlp/vcr_better_binary","last_synced_at":"2025-07-11T09:41:51.428Z","repository":{"id":48721526,"uuid":"266184575","full_name":"odlp/vcr_better_binary","owner":"odlp","description":"Persist binary data outside your VCR cassettes","archived":false,"fork":false,"pushed_at":"2021-07-13T11:28:27.000Z","size":39,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-26T06:18:22.981Z","etag":null,"topics":["vcr","vcr-serializer"],"latest_commit_sha":null,"homepage":"","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/odlp.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":"2020-05-22T18:49:32.000Z","updated_at":"2023-05-10T22:36:07.000Z","dependencies_parsed_at":"2022-09-16T00:52:15.694Z","dependency_job_id":null,"html_url":"https://github.com/odlp/vcr_better_binary","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/odlp/vcr_better_binary","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odlp%2Fvcr_better_binary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odlp%2Fvcr_better_binary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odlp%2Fvcr_better_binary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odlp%2Fvcr_better_binary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odlp","download_url":"https://codeload.github.com/odlp/vcr_better_binary/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odlp%2Fvcr_better_binary/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264778058,"owners_count":23662561,"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":["vcr","vcr-serializer"],"created_at":"2024-10-01T16:23:06.113Z","updated_at":"2025-07-11T09:41:51.385Z","avatar_url":"https://github.com/odlp.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VCR: Better Binary Serializer\n\n[![CircleCI](https://circleci.com/gh/odlp/vcr_better_binary.svg?style=shield)](https://circleci.com/gh/odlp/vcr_better_binary)\n\n## What\n\nThis gem is a [VCR] serializer which persists any binary data in the HTTP\nrequest or response bodies outside the cassette.\n\n[VCR]: https://github.com/vcr/vcr\n\n## Why\n\n- Keeps the cassettes human readable\n- You can `git diff` the cassette more easily (and git won't diff the binary\n  data stored elsewhere)\n- Github won't collapse the diffs for cassettes in PRs (the default for large files)\n\nYou can read more about this gem in the following [blog post](https://oliverpeate.com/learning-by-making-small-things/).\n\n## How\n\nAdd the gem to your `Gemfile` and `bundle install`:\n\n```ruby\ngroup :test do\n  gem \"vcr_better_binary\"\nend\n```\n\nConfigure VCR to use the serializer:\n\n```ruby\n# spec/support/vcr.rb (or wherever you configure VCR)\n\nVCR.configure do |config|\n  config.cassette_serializers[:better_binary] = VcrBetterBinary::Serializer.new\n  config.default_cassette_options = { serialize_with: :better_binary } # or specify inline in 'VCR.use_cassette'\nend\n```\n\nWhen you re-record or delete a cassette there may be stale references leftover\nin the storage directory.\n\nAdd a hook after all your tests have run to prevent unused data from building\nup:\n\n```ruby\nRSpec.configure do |config|\n  config.after(:suite) do\n    VcrBetterBinary::Serializer.new.prune_bin_data\n  end\nend\n```\n\nAnd you're set!\n\n## The end-result\n\nWhen you record requests with binary data the resulting cassette will\nlook similar to this:\n\n```yaml\n# Abridged example\nhttp_interactions:\n- request:\n    method: post\n    uri: https://example.com/upload\n    body:\n      encoding: ASCII-8BIT\n      bin_key: lymom-vudim-vunek-mobad-fepak-taset-zosyl-zuhaf-setag\n  response:\n    status:\n      code: 200\n      message: OK\n    body:\n      encoding: ASCII-8BIT\n      bin_key: xohog-badok-paneg-memek-tahum-degab-kasip-pefik-colol\n```\n\nAnd the following files will have been persisted:\n\n```\nspec/fixtures/vcr_cassettes\n├── my-cassette.yml\n└── bin_data\n    ├── lymom-vudim-vunek-mobad-fepak-taset-zosyl-zuhaf-setag\n    └── xohog-badok-paneg-memek-tahum-degab-kasip-pefik-colol\n```\n\nAll remaining VCR functionality will operate as normal; the only adjustment is\nthe storage of binary data.\n\n## Advanced configuration\n\nYou can adjust the underlying serializer to save your cassettes in different\nformats, e.g:\n\n```ruby\n# JSON cassettes\nVcrBetterBinary::Serializer.new(base_serializer: VCR::Cassette::Serializers::JSON)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodlp%2Fvcr_better_binary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodlp%2Fvcr_better_binary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodlp%2Fvcr_better_binary/lists"}