     """
   end
 
-  @doc false
-  def flunk_attributes_match(params_given, params_received) do
+  defp flunk_attributes_match(params_given, params_received) do
     """
     The parameters given match.
 

      Bamboo.Email.new_email(subject: "something") |> MyApp.Mailer.deliver()
      refute_email_delivered_with([subject: "something else"], timeout: 100)
  """
  defmacro refute_email_delivered_with(email_params, opts \\ []) do
    quote bind_quoted: [email_params: email_params, opts: opts] do
      import ExUnit.Assertions

      received_email_params =
        receive do
          {:delivered_email, email} -> Map.from_struct(email)
        after
          Bamboo.Test.refute_timeout(opts) -> []
        end

      if is_nil(received_email_params) do
        refute false
      else
        refute Enum.any?(email_params, fn {k, v} -> do_match(received_email_params[k], v, k) end),
               Bamboo.Test.flunk_attributes_match(email_params, received_email_params)
      end
    end
  end

  @doc false
  def do_match(value1, value2 = %Regex{}, _type) do
    Regex.match?(value2, value1)
  end

  @doc false
  def do_match(value1, value2, type) do
    value1 == value2 || value1 == format(value2, type)
  end

  @doc false
  defp format(record, type) do
    Bamboo.Formatter.format_email_address(record, %{type: type})
  end

  @doc false
  def flunk_with_email_list(email) do
    if Enum.empty?(delivered_emails()) do
      flunk_no_emails_received()
    else

      assert_email_delivered_with(text_body: ~r/love/) # Will pass
      assert_email_delivered_with(text_body: ~r/like/) # Will fail
  """
  def assert_email_delivered_with(email_params, opts \\ []) do
    timeout = get_timeout(opts)
    assert_receive({:delivered_email, email}, timeout, flunk_no_emails_received())

    received_email_params = email |> Map.from_struct()

    assert Enum.all?(email_params, fn {k, v} -> do_match(received_email_params[k], v, k) end),
           flunk_attributes_do_not_match(email_params, received_email_params)
  end

  @doc """
