danielberkompas / ex_twilio

Twilio API client for Elixir
MIT License
334 stars 146 forks source link

Add :enabled option to config #138

Closed lstrzebinczyk closed 3 years ago

lstrzebinczyk commented 4 years ago

Hi. Thank you for working on this!

I have a module like this in my code:

defmodule TextMessage do
  def send(phone_number, body) do
    case Application.get_env(:our_app, :env) do
      :test ->
        nil

      _ ->
        ExTwilio.Message.create(%{
          body: body,
          to: phone_number,
          from: our_phone_number
        })
    end
  end
end

Many libraries have :enabled option, so that I could set it to false in test environment, and just use the code without this additional setup. Would it be possible to add here as well?

danielberkompas commented 3 years ago

I think this would be an excellent place to make use of mocking in your code. Check out this library from the Elixir creators: https://github.com/dashbitco/mox