Sha256: f50e37e80046bd4837382312731c95d2054564f21d7e4f09fd1b4b5a2b4c10b1
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
RSpec.describe TTY::Spinner::Multi, "#register" do let(:output) { StringIO.new("", "w+") } it "registers a TTY::Spinner instance from a pattern" do spinners = TTY::Spinner::Multi.new(output: output, interval: 100) allow_any_instance_of(TTY::Spinner).to receive(:attach_to) expect_any_instance_of(TTY::Spinner).to receive(:attach_to) spinner = spinners.register "" expect(spinner).to be_instance_of(TTY::Spinner) expect(spinners.length).to eq(1) end it "registers a TTY::Spinner instance from a spinner instance" do spinners = TTY::Spinner::Multi.new(output: output, interval: 100) spinner_to_register = ::TTY::Spinner.new spinner = spinners.register spinner_to_register expect(spinner).to eq(spinner_to_register) expect(spinners.length).to eq(1) end it "raises an erro when given neither a string or spinner instance" do spinners = TTY::Spinner::Multi.new(output: output, interval: 100) expect { spinners.register [] } .to raise_error( ArgumentError, "Expected a pattern or spinner, got: Array" ) end it "uses global options to register instance" do spinners = TTY::Spinner::Multi.new(output: output, interval: 100) spinner = double(:spinner, attach_to: nil) allow(spinner).to receive(:on).and_return(spinner) allow(TTY::Spinner).to receive(:new).and_return(spinner) spinners.register "[:spinner]" expect(TTY::Spinner).to have_received(:new) .with("[:spinner]", {interval: 100, output: output}) end end
Version data entries
5 entries across 5 versions & 1 rubygems