{"id":13509207,"url":"https://github.com/campezzi/ignorant","last_synced_at":"2025-10-21T18:54:21.246Z","repository":{"id":57506355,"uuid":"66361082","full_name":"campezzi/ignorant","owner":"campezzi","description":"Simplify comparison of Elixir data structures by ensuring fields are present but ignoring their values.","archived":false,"fork":false,"pushed_at":"2016-08-25T00:48:13.000Z","size":11,"stargazers_count":14,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T18:54:04.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/campezzi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-23T11:28:20.000Z","updated_at":"2023-09-01T10:51:55.000Z","dependencies_parsed_at":"2022-08-29T20:31:52.426Z","dependency_job_id":null,"html_url":"https://github.com/campezzi/ignorant","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/campezzi/ignorant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campezzi%2Fignorant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campezzi%2Fignorant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campezzi%2Fignorant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campezzi%2Fignorant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/campezzi","download_url":"https://codeload.github.com/campezzi/ignorant/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campezzi%2Fignorant/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280317282,"owners_count":26309997,"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-21T02:00:06.614Z","response_time":58,"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-08-01T02:01:04.576Z","updated_at":"2025-10-21T18:54:21.200Z","avatar_url":"https://github.com/campezzi.png","language":"Elixir","funding_links":[],"categories":["Testing"],"sub_categories":[],"readme":"# Ignorant\n\nBecause sometimes ignorance is bliss.\n\nIgnorant defines a protocol for data structures that may selectively ignore specific values they\ncontain, usually to simplify partial comparison in tests.\n\n## Motivation\nSometimes it's useful to compare data structures in tests while ignoring pieces of data that are not\ndeterministic - auto-generated primary keys, calculated timestamps, and so on. Ignoring certain bits\nensures the _shape_ of the data is correct when it's not possible to enforce its values.\n\n## Example\n\nAn implementation for `Map` is provided with that package for the purpose described above. Suppose\nyou have an API endpoint that fetches a record from the database and returns JSON data which\ntranslates to this `response` map:\n\n```elixir\n%{\n  id: 37,\n  name: \"Jim\"\n}\n```\n\nNow let's say you want to write a test to ensure that it returns the right data. Problem is, the\n`id` field is auto-generated and therefore has no deterministic value between test runs. You could\nuse pattern matching...\n\n```elixir%{a}\nassert %{id: _, name: \"Jim\"} = response\n```\n\n...but you can't assign the value on the left side to a variable (or module attribute) and reuse it,\nand if the match fails you don't get a nice diff message. That's where `Ignorant` comes in:\n\n```elixir\nassert %{id: :ignored, name: \"Jim\"} == Ignorant.ignore(response, [:id])\n```\n\nThe left side is now a proper value that can be put in a variable or attribute and reused. Also note\nthe `==` (equality) assertion instead of `=` (match) assertion. That gives us a pretty diff that\nhighlights exactly what doesn't look the same on both sides, and is also stricter (which is a good\nidea in tests).\n\nIt quickly becomes annoying and error-prone to tag things as `:ignored` in one side of the\ncomparison and include the corresponding field on the second parameter in the call to `ignore/2` on\nthe other side, so we can clean that up by using `merge_ignored/2`:\n\n```elixir\nexpected = %{id: :ignored, name: \"Jim\"}\nassert expected == Ignorant.merge_ignored(response, expected)\n```\n\n`merge_ignored/2` will walk through the `expected` map extracting all fields tagged as `:ignored`, and\nthen apply those to `response` while keeping all other values intact. The resulting map should be\nequal to `expected`. If not, you'll get a pretty diff explaining what's different.\n\n\n## Installation\n\n1. Add `ignorant` to your list of dependencies in `mix.exs`:\n\n  ```elixir\n  def deps do\n    [{:ignorant, \"~\u003e 0.1.0\"}]\n  end\n  ```\n\n2. Ensure `ignorant` is started before your application:\n\n  ```elixir\n  def application do\n    [applications: [:ignorant]]\n  end\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcampezzi%2Fignorant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcampezzi%2Fignorant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcampezzi%2Fignorant/lists"}