{"id":20764173,"url":"https://github.com/mickey/ruby-recorder","last_synced_at":"2025-07-27T09:39:40.352Z","repository":{"id":3961688,"uuid":"5055525","full_name":"mickey/ruby-recorder","owner":"mickey","description":"Recorder dumps the result of your ruby code to a YAML file for faster tests or to compare the result between two runs.","archived":false,"fork":false,"pushed_at":"2012-12-17T19:40:55.000Z","size":124,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-30T08:11:52.557Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://mickey.github.com/ruby-recorder","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/mickey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-15T11:19:16.000Z","updated_at":"2017-04-05T08:56:08.000Z","dependencies_parsed_at":"2022-09-03T10:50:55.283Z","dependency_job_id":null,"html_url":"https://github.com/mickey/ruby-recorder","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickey%2Fruby-recorder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickey%2Fruby-recorder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickey%2Fruby-recorder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickey%2Fruby-recorder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mickey","download_url":"https://codeload.github.com/mickey/ruby-recorder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251666336,"owners_count":21624295,"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-17T10:49:03.039Z","updated_at":"2025-04-30T08:11:57.895Z","avatar_url":"https://github.com/mickey.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruby Recorder\n\n[![Build Status](https://secure.travis-ci.org/mickey/ruby-recorder.png)](http://travis-ci.org/mickey/ruby-recorder)\n\nRecorder dumps the result of your ruby code to a YAML file for faster tests or to compare the result between two execution.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'ruby-recorder'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install ruby-recorder\n\n## Exemples\n\n### Refactor\n\nImagine you want to refactor an endpoint on your backend api and want to make sure the response is the same:\n\n```ruby\n  Recorder.config do |c|\n    c.verbose = true\n    c.stubb = false\n  end\n\n  # this will call your backend and \n  # dump the result in refactor.yml\n  # let's say the response is : [{\"username\"=\u003e\"Michael Bensoussan\"}]\n  Recorder.dump_to('refactor.yml') do\n    HTTParty.get('http://my_backend/users').parsed_response\n  end\n\n  # this will call your backend and compare the result to\n  # what's in refactor.yml ([{\"username\"=\u003e\"Michael Bensoussan\"}])\n  # let's say the new response is [{\"username\"=\u003e\"Michael\"}]\n  Recorder.dump_to('refactor.yml') do\n    HTTParty.get('http://my_backend/users').parsed_response\n  end\n\n```\n\nExecuting this code will outputs a (colored) diff :\n\n```\n  Recorder: result is different from last run\n  ---\n  - username: Michael Bensoussan- username: Michael\n```\n\n### Faster tests\n\nThe first time you run this test, you will call the backend but for all the following runs `Recorder` will load the result from the YAML file.\n\n```ruby\n  class TestRecorder \u003c MiniTest::Unit::TestCase\n\n    def setup\n      Recorder.config do |c|\n        c.verbose = true\n        c.stubb = true\n        c.records_dir = 'backend_responses/'\n      end\n    end\n\n    def test_users\n      users = Recorder.dump_to('refactor.yml') do\n        HTTParty.get('http://my_backend/users').parsed_response\n      end\n\n      assert_equal [{\"username\"=\u003e\"Michael Bensoussan\"}], users\n    end\n\n  end\n```\n\n## Usage\n\n```ruby\n  Recorder.config do |c|\n    c.verbose = true\n    c.records_dir = 'records/'\n    c.stubb = false\n  end\n```\n\n### records_dir\n\nThe `records_dir` option sets the directory where your records will be saved.\n\n### stubb\n\nWhen `stubb = true`, your code will only be run once. Future runs will load the result from the yaml file.\nWhen `stubb = false`, your code will be run every time.\n\n### verbose\n\nThe `verbose` option will outputs a nice diff (with the `differ` gem) if the output is different from the last run.\nOf course this only works if `stubb = false`.\n\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmickey%2Fruby-recorder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmickey%2Fruby-recorder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmickey%2Fruby-recorder/lists"}