       send self, :hello
       refute_received :bye
 
-  """
-  defmacro refute_received(not_expected, message \\ nil) do
-    do_refute_receive(not_expected, 0, message)
-  end
-
-  defp do_refute_receive(not_expected, timeout, message) do
-    receive_clause = refute_receive_clause(not_expected, message)
+      send self, :hello
+      refute_received :hello, "Oh No!"
+      ** (ExUnit.AssertionError) Oh No!
+      Process mailbox:
+        :bye
+
+  """
+  defmacro refute_received(pattern, failure_message \\ nil) do
+    do_refute_receive(pattern, 0, failure_message)
+  end
+
+  defp do_refute_receive(pattern, timeout, failure_message) do
+    receive_clause = refute_receive_clause(pattern, failure_message)
 
     quote do
       receive do

      assert_receive {:count, ^x}

  """
  defmacro assert_receive(expected,
                          timeout \\ Application.fetch_env!(:ex_unit, :assert_receive_timeout),
                          message \\ nil) do
    do_assert_receive(expected, timeout, message, __CALLER__)
  end

  @doc """
  Asserts a message was received and is in the current process' mailbox.
  Timeout is set to 0, so there is no waiting time.

  The `expected` argument is a pattern.

  ## Examples

      send self, :hello
      assert_received :hello

  You can also match against specific patterns:

      send self, {:hello, "world"}
      assert_received {:hello, _}

  """
  defmacro assert_received(expected, message \\ nil) do
    do_assert_receive(expected, 0, message, __CALLER__)
  end

  defp do_assert_receive(expected, timeout, message, caller) do
    binary = Macro.to_string(expected)

    # Expand before extracting metadata
    expected = Macro.expand(expected, caller)
    vars = collect_vars_from_pattern(expected)
    pins = collect_pins_from_pattern(expected)

    pattern =
      case expected do
        {:when, meta, [left, right]} ->
          {:when, meta, [quote(do: unquote(left) = received), right]}
        left ->

  end

  @doc """
  Asserts that a message matching `pattern` was or is going to be received.

  Unlike `assert_received`, it has a default timeout
  of 100 milliseconds.

  The `pattern` argument must be a match pattern. Flunks with `failure_message`
  if a message matching `pattern` is not received.

  ## Examples

