{"id":13878345,"url":"https://github.com/wilsonsilva/memoria","last_synced_at":"2025-10-24T01:30:38.124Z","repository":{"id":56883265,"uuid":"130372356","full_name":"wilsonsilva/memoria","owner":"wilsonsilva","description":"Capture snapshots to simplify testing and to analyze how state changes over time.","archived":false,"fork":false,"pushed_at":"2023-09-29T09:44:27.000Z","size":64,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-10-10T01:01:09.542Z","etag":null,"topics":["rspec","ruby","snapshot","test","testing"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wilsonsilva.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-20T14:21:16.000Z","updated_at":"2024-02-06T15:11:53.000Z","dependencies_parsed_at":"2024-09-21T18:30:45.411Z","dependency_job_id":null,"html_url":"https://github.com/wilsonsilva/memoria","commit_stats":{"total_commits":57,"total_committers":1,"mean_commits":57.0,"dds":0.0,"last_synced_commit":"b4998003fe2c34374d87e4dac663183a6f487198"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fmemoria","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fmemoria/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fmemoria/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fmemoria/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wilsonsilva","download_url":"https://codeload.github.com/wilsonsilva/memoria/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867198,"owners_count":16555821,"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":["rspec","ruby","snapshot","test","testing"],"created_at":"2024-08-06T08:01:46.876Z","updated_at":"2025-10-24T01:30:32.748Z","avatar_url":"https://github.com/wilsonsilva.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Memoria\n\n[![Gem Version](https://badge.fury.io/rb/memoria.svg)](https://badge.fury.io/rb/memoria)\n![Build Status](https://github.com/wilsonsilva/memoria/actions/workflows/main.yml/badge.svg)\n[![Maintainability](https://api.codeclimate.com/v1/badges/ffa08ae5daf70c87c68f/maintainability)](https://codeclimate.com/github/wilsonsilva/memoria/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/ffa08ae5daf70c87c68f/test_coverage)](https://codeclimate.com/github/wilsonsilva/memoria/test_coverage)\n[![Inline docs](http://inch-ci.org/github/wilsonsilva/memoria.svg?branch=master)](http://inch-ci.org/github/wilsonsilva/memoria)\n\nAsserts the result of a given test by generating a rendered representation of its output. Inspired by Jest and VCR.\n\nThe first time your test is run, a representation of your expected output is saved to a file. The next time you\nrun the same test, a diff runs between a new and the previously stored snapshot. If there are no differences the test\npasses, otherwise the test fails and the resulting diff is displayed.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'memoria'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install memoria\n\n## Usage\n\n### 1. Configure `spec_helper.rb`:\n\n```ruby\nrequire 'memoria/rspec'\n\nMemoria.configure do |config|\n  config.configure_rspec_hooks\n  config.include_rspec_matchers\nend\n```\n\nThe configuration above does two things:\n- Configures RSpec hooks to create snapshots named after the full spec example's description.\n- Includes the matcher `match_snapshot` in your RSpec test suite.\n\n### 2. Add snapshot metadata to your test\n\nAdd `snapshot: true` to any `describe`, `context` or `it` block to generate a snapshot for that test then use the\nprovided matcher `match_snapshot` to verify if the expected output matches a previously recorded snapshot.\n\n```ruby\nRSpec.describe Calendario::Calendar do\n  let(:calendar) { described_class.new }\n\n  describe '#render_january' do\n    it 'renders the month of January', snapshot: true do\n      rendered = calendar.render_january\n      expect(rendered.to_s).to match_snapshot\n    end\n  end\nend\n```\n\n### 3. Generate the snapshot\n\nRun the tests to generate the snapshot:\n\n```\nbundle exec rspec\n\nCalendario::Calendar\n  renders the month of january\n    Generated snapshot: Calendario::Calendar/renders the month of January \u003c--- NOTICE THIS LINE\n\nFinished in 0.02001 seconds (files took 0.22817 seconds to load)\n1 example, 0 failures\n```\n\nThe tests will pass and the snapshot will be stored in a `snap` file:\n`spec/fixtures/snapshots/Calendario_Calendar/_render_january/renders_the_month_of_january.snap`:\n\n```\n      January\nSu Mo Tu We Th Fr Sa\n          1  2  3  4\n 5  6  7  8  9 10 11\n12 13 14 15 16 17 18\n19 20 21 22 23 24 25\n26 27 28 29 30 31\n```\n\n### 4. Compare the output with the snapshot\n\nRun the tests again to compare the output with the snapshot. The tests will pass again:\n\n```\nbundle exec rspec\n\nCalendario::Calendar\n  renders the month of january\n\nFinished in 0.02103 seconds (files took 0.21164 seconds to load)\n1 example, 0 failures\n```\n\n### Configuring the snapshot directory\n\nBy default the snapshots will be stored in `spec/fixtures/snapshots`, but you can change this with the setting\n`snapshot_directory`:\n\n```ruby\nMemoria.configure do |config|\n  config.snapshot_directory = 'spec/snapshots'\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive\nprompt that will allow you to experiment. The health and maintainability of the codebase is ensured through a set of\nRake tasks to test, lint and audit the gem for security vulnerabilities and documentation:\n\n```\nrake bundle:audit          # Checks for vulnerable versions of gems\nrake qa                    # Test, lint and perform security and documentation audits\nrake rubocop               # Lint the codebase with RuboCop\nrake rubocop:auto_correct  # Auto-correct RuboCop offenses\nrake spec                  # Run RSpec code examples\nrake verify_measurements   # Verify that yardstick coverage is at least 100%\nrake yard                  # Generate YARD Documentation\nrake yard:junk             # Check the junk in your YARD Documentation\nrake yardstick_measure     # Measure docs in lib/**/*.rb with yardstick\n```\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the\nversion number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,\npush git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n### Architecture\n\nMartin Fowler defines software architecture as those decisions which are both important and hard to change. Since these\ndecisions are hard to change, we need to be sure that our foundational priorities are well-served by these decisions.\n\nMemoria was designed using a modular plugin architecture. The core part of the gem has a single responsibility:\nmanage snapshots. Every test framework integration is done through a self-contained plugin. Plugins depend on the core,\nbut the core is unaware of the plugins. This allows me to extract the plugins into their own gems later, and\nadd new plugins with ease.\n\n![Class Diagram](https://github.com/wilsonsilva/memoria/blob/main/documentation/class-diagram.svg)\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wilsonsilva/memoria.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilsonsilva%2Fmemoria","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilsonsilva%2Fmemoria","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilsonsilva%2Fmemoria/lists"}