forked from alphagov/seal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseal_spec.rb
55 lines (46 loc) · 1.28 KB
/
seal_spec.rb
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "spec_helper"
require_relative "../lib/seal"
require_relative "../lib/team"
RSpec.describe Seal do
subject(:seal) { described_class.new(teams) }
let(:lions) {
Team.new(
slack_channel: "#lions",
quotes: ["go lions!"],
)
}
let(:tigers) {
Team.new(
slack_channel: "#tigers",
)
}
let(:teams) do
[
lions,
tigers,
]
end
let(:slack_poster) { instance_double(SlackPoster, send_request: nil) }
let(:message_builder) { instance_double(MessageBuilder, build: message) }
let(:message) { instance_double(Message, mood: "", text: "") }
describe ".bark(mode: nil)" do
before do
allow(SlackPoster).to receive(:new).and_return(slack_poster)
end
it "barks at all teams" do
teams.each do |team|
expect(MessageBuilder).to receive(:new).with(team).and_return(message_builder)
expect(SlackPoster).to receive(:new).with(team.channel, anything)
end
subject.bark
end
context "when in quotes mode" do
let(:teams) { [lions] }
it "barks at all teams" do
expect(Message).to receive(:new).with("go lions!").and_return(message)
expect(SlackPoster).to receive(:new).with(lions.channel, anything)
subject.bark(mode: "quotes")
end
end
end
end