{"id":13508660,"url":"https://github.com/BlakeWilliams/pact","last_synced_at":"2025-03-30T11:32:31.528Z","repository":{"id":25408035,"uuid":"28836987","full_name":"BlakeWilliams/pact","owner":"BlakeWilliams","description":"Better dependency injection in Elixir","archived":false,"fork":false,"pushed_at":"2018-09-10T17:04:42.000Z","size":15,"stargazers_count":77,"open_issues_count":3,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-17T03:47:36.569Z","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":"IBM/GameOn-Java-Microservices-on-Kubernetes","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BlakeWilliams.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":"2015-01-05T23:28:09.000Z","updated_at":"2025-02-13T00:33:57.000Z","dependencies_parsed_at":"2022-08-23T20:00:57.777Z","dependency_job_id":null,"html_url":"https://github.com/BlakeWilliams/pact","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/BlakeWilliams%2Fpact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fpact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fpact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fpact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlakeWilliams","download_url":"https://codeload.github.com/BlakeWilliams/pact/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246314011,"owners_count":20757450,"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-01T02:00:56.405Z","updated_at":"2025-03-30T11:32:31.226Z","avatar_url":"https://github.com/BlakeWilliams.png","language":"Elixir","funding_links":[],"categories":["Miscellaneous","Elixir"],"sub_categories":[],"readme":"# Pact\n\nPact is a dependency registry for Elixir to make testing dependencies easier.\n## Why?\n\nBecause testing Elixir dependencies could be a lot better. Why clutter up your\ncode injecting dependencies when a process can handle it for you?\n\n* You can declare your modules instead of passing them around like state.\n* You can replace dependencies in a block context for easy testing.\n* It makes your code cleaner.\n\n## Usage\n\nIn your application code:\n\n```elixir\ndefmodule MyApp.Pact do\n  use Pact\n\n  register \"http\", HTTPoison\nend\n\nMyApp.Pact.start_link\n\ndefmodule MyApp.Users do\n  def all do\n    MyApp.Pact.get(\"http\").get!(\"http://foobar.com/api/users\")\n  end\nend\n\n```\n\nIn your tests:\n\n```elixir\ndefmodule MyApp.UserTest do\n  use ExUnit.Case\n  require MyApp.Pact\n\n  test \"requests the corrent endpoint\" do\n    fakeHTTP = MyApp.Pact.generate :http do\n      def get!(url) do\n        send self(), {:called, url}\n      end\n    end\n\n    MyApp.Pact.replace \"http\", fakeHTTP do\n      MyApp.Users.all\n    end\n\n    assert_receive {:called, \"http://foobar.com/api/users\"}\n  end\nend\n```\n\nYou can find more information in the [documentation].\n\n[documentation]: http://hexdocs.pm/pact\n\n## Disclaimer\n\nPact is very much an experiment at this point to see if it's viable. If you use\nPact please get in touch with me to let me know how it worked out for you or how\nyou think it could improve. If you have ideas feel free to open an issue or\ncreate a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBlakeWilliams%2Fpact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBlakeWilliams%2Fpact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBlakeWilliams%2Fpact/lists"}