/
auto_spin_spec.rb
32 lines (23 loc) · 937 Bytes
/
auto_spin_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
RSpec.describe TTY::Spinner::Multi, "#auto_spin" do
let(:output) { StringIO.new("", "w+") }
it "doesn't auto spin top level spinner" do
spinners = TTY::Spinner::Multi.new("Top level spinner", output: output)
allow(spinners.top_spinner).to receive(:auto_spin)
spinners.auto_spin
expect(spinners.top_spinner).to_not have_received(:auto_spin)
end
it "raises an exception when called without a top spinner" do
spinners = TTY::Spinner::Multi.new(output: output)
expect {
spinners.auto_spin
}.to raise_error(RuntimeError, /No top level spinner/)
end
it "auto spins top level & child spinners with jobs" do
spinners = TTY::Spinner::Multi.new("top", output: output)
jobs = []
spinners.register("one") { |sp| jobs << "one"; sp.success }
spinners.register("two") { |sp| jobs << "two"; sp.success }
spinners.auto_spin
expect(jobs).to match_array(%w[one two])
end
end