Popularity
5.8
Declining
Activity
0.0
Stable
74
3
6

Monthly Downloads: 94
Programming language: Elixir
License: MIT License
Tags: Miscellaneous    

pact alternatives and similar packages

Based on the "Miscellaneous" category.
Alternatively, view pact alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of pact or a related project?

Add another 'Miscellaneous' Package

README

Pact

Pact is a dependency registry for Elixir to make testing dependencies easier.

Why?

Because testing Elixir dependencies could be a lot better. Why clutter up your code injecting dependencies when a process can handle it for you?

  • You can declare your modules instead of passing them around like state.
  • You can replace dependencies in a block context for easy testing.
  • It makes your code cleaner.

Usage

In your application code:

defmodule MyApp.Pact do
  use Pact

  register "http", HTTPoison
end

MyApp.Pact.start_link

defmodule MyApp.Users do
  def all do
    MyApp.Pact.get("http").get!("http://foobar.com/api/users")
  end
end

In your tests:

defmodule MyApp.UserTest do
  use ExUnit.Case
  require MyApp.Pact

  test "requests the corrent endpoint" do
    fakeHTTP = MyApp.Pact.generate :http do
      def get!(url) do
        send self(), {:called, url}
      end
    end

    MyApp.Pact.replace "http", fakeHTTP do
      MyApp.Users.all
    end

    assert_receive {:called, "http://foobar.com/api/users"}
  end
end

You can find more information in the documentation.

Disclaimer

Pact is very much an experiment at this point to see if it's viable. If you use Pact please get in touch with me to let me know how it worked out for you or how you think it could improve. If you have ideas feel free to open an issue or create a pull request.