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
|