docbrown/spec/services/slack/announcer_spec.rb
rhymes d03c751c65
Rubocop fixes (#6904)
* Run rubocop -a

* Regenerate rubocop todo

* Fix Lint/UselessAssignment

* Fix RSpec/RepeatedDescription

* Fix Style/GuardClause

* Fix Style/NumericPredicate

* Regenerate rubocop todo
2020-03-27 15:30:59 +01:00

34 lines
805 B
Ruby

require "rails_helper"
RSpec.describe Slack::Announcer, type: :service do
it "does not call the client if any of the params is blank" do
allow(SlackClient).to receive(:ping)
params = {
message: "something",
channel: nil,
username: "",
icon_emoji: ":o:"
}
expect(described_class.call(params)).to be_nil
expect(SlackClient).not_to have_received(:ping)
end
it "calls the client if all params are given" do
allow(SlackClient).to receive(:ping)
message = "hello there"
params = {
message: message,
channel: "#help",
username: "bob",
icon_emoji: ":o:"
}
described_class.call(params)
expect(SlackClient).to have_received(:ping).
with(message, params.reject { |k| k == :message }).
once
end
end