slash v2.0.0-rc.7 Slash.Test View Source
Use this module for testing your plugs built with Slash.Builder
.
Examples
defmodule Bot.SlackRouterTest do
use ExUnit.Case
use Plug.Test
use Slash.Test
alias Bot.SlackRouter
test "should encode response as json", %{conn: conn} do
conn =
:post
|> conn("/", %{})
|> send_command(SlackRouter, "greet")
|> SlackRouter.call([])
assert %Plug.Conn{resp_body: body} = conn
assert %{"text" => "Hello world!"} = Jason.decode!(body)
end
end
Link to this section Summary
Functions
Builds a %Conn{}
body for a specific Slack command payload
Link to this section Functions
Link to this function
send_command(conn, module, command)
View Source
send_command(conn, module, command)
View Source
send_command(Plug.Conn.t(), module :: atom(), command :: String.t()) ::
Plug.Conn.t()
send_command(Plug.Conn.t(), module :: atom(), command :: String.t()) :: Plug.Conn.t()
Builds a %Conn{}
body for a specific Slack command payload.
If a :signer_key
has not been configured for the test module, a key will be generated and
put into the application environment.
NOTE: This is a little awkward right now due to having to send the mock module as an argument.