Slackbox.TestAssertions (Slackbox v0.1.0)

Copy Markdown View Source

Assertions for the Slackbox.Adapters.Test adapter, in the spirit of Swoosh.TestAssertions. import it in your test module:

import Slackbox.TestAssertions

test "notifies #alerts" do
  MyApp.Notifier.on_failure(build)
  assert_message_sent(channel: "#alerts", text: ~r/failed/)
end

Attribute assertions match against the first matching captured message (assertions are non-destructive). A Regex value is matched with =~; any other value with ==. A 1-arity function is called with the %Slackbox.Message{} for custom assertions.

Summary

Functions

Assert a post_ephemeral was sent.

Assert a post_message was sent, matching attrs (keyword) or a predicate fn.

Assert a chat.update was sent.

Assert views.open happened; the predicate receives %{trigger_id:, view:, opts:}.

Refute that any captured post_message matches attrs (default: refute any was sent).

Functions

assert_ephemeral_sent(attrs_or_fun)

Assert a post_ephemeral was sent.

assert_message_sent(attrs_or_fun)

Assert a post_message was sent, matching attrs (keyword) or a predicate fn.

assert_message_updated(attrs_or_fun)

Assert a chat.update was sent.

assert_view_opened(fun)

Assert views.open happened; the predicate receives %{trigger_id:, view:, opts:}.

refute_message_sent(attrs \\ [])

Refute that any captured post_message matches attrs (default: refute any was sent).