     Use IO.write/2 to write to the opened `filename`.
     """
     test "writes to resource" do
-      assert capture_io(fn -> RPNCalculator.Output.write(@resource, @filename, @equation) end) ==
+      resource = __MODULE__
+      filename = "filename"
+      equation = "1 1 +"
+
+      assert capture_io(fn -> RPNCalculator.Output.write(resource, filename, equation) end) ==
                "1 1 +",
              @use_write_error_message
     end

    E.g.) resource.close(filename)
    """
    test "closes resource" do
      RPNCalculator.Output.write(__MODULE__, @filename, @equation)
      assert_received :close, @use_close_error_message
    end

    @tag :pending
    test "rescues and returns error tuple from raised error" do
      assert {:error, "Unable to write to resource"} ==
               RPNCalculator.Output.write(@resource, @bad_filename, @equation)
    end

    @tag :pending
    test "closes resource even when rescuing from raised error" do
      RPNCalculator.Output.write(@resource, @bad_filename, @equation)
      assert_received :close, "write/3 should close the `resource` even if an error is raised"
    end
  end


  import ExUnit.CaptureIO

  def open(filename \\ "<nil>") do
    send(self(), {:open, filename})

    case filename do
      "filename" -> {:ok, :stdio}
      "bad_filename" -> {:ok, spawn(fn -> nil end)}
    end
  end

