File: at_spec.rb

package info (click to toggle)
ruby-slack-messenger 2.3.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208 kB
  • sloc: ruby: 1,156; makefile: 7
file content (25 lines) | stat: -rw-r--r-- 830 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

RSpec.describe Slack::Messenger::PayloadMiddleware::At do
  it "can handle array at" do
    subject = described_class.new(:messenger)
    payload = { text: "hello", at: %i[john ken here] }

    expect(subject.call(payload)).to eq text: "<@john> <@ken> <!here> hello"
  end

  it "can handle single at option" do
    subject = described_class.new(:messenger)
    payload = { text: "hello", at: :alice }

    expect(subject.call(payload)).to eq text: "<@alice> hello"
  end

  it "generates :text in payload if given :at & no :text" do
    subject = described_class.new(:messenger)
    input_payload  = { at: [:here], attachments: [{ text: "hello" }] }
    output_payload = { text: "<!here> ", attachments: [{ text: "hello" }] }

    expect(subject.call(input_payload)).to eq output_payload
  end
end