Sha256: ff8f117ddaf6a21b9de785cd5c531fb87152592325495c4a35d75fbde01cd067
Contents?: true
Size: 1.96 KB
Versions: 5
Compression:
Stored size: 1.96 KB
Contents
RSpec.describe TTY::Spinner, "#stop" do let(:output) { StringIO.new("", "w+") } it "doesn't reprint stop message" do spinner = TTY::Spinner.new(output: output) spinner.spin 3.times { spinner.stop } output.rewind expect(output.read).to eq([ "\e[1G|", "\e[0m\e[2K", "\e[1G|\n" ].join) end it "stops after 2 spins" do spinner = TTY::Spinner.new(output: output) 5.times do |n| spinner.spin spinner.stop if n == 1 end output.rewind expect(output.read).to eq([ "\e[1G|", "\e[1G/", "\e[0m\e[2K", "\e[1G/\n" ].join) end it "stops after 2 spins and prints stop message" do spinner = TTY::Spinner.new(output: output) 5.times do |n| spinner.spin spinner.stop("Done!") if n == 1 end output.rewind expect(output.read).to eq([ "\e[1G|", "\e[1G/", "\e[0m\e[2K", "\e[1G/ Done!\n" ].join) expect(spinner.done?).to eq(true) end it "stops after 2 spins with message and prints stop message" do spinner = TTY::Spinner.new("Loading ... :spinner", output: output) 5.times do |n| spinner.spin spinner.stop("Done!") if n == 1 end output.rewind expect(output.read).to eq([ "\e[1GLoading ... |", "\e[1GLoading ... /", "\e[0m\e[2K", "\e[1GLoading ... / Done!\n" ].join) end it "sets a custom mark when done" do spinner = TTY::Spinner.new("[:spinner]", output: output) 2.times { spinner.spin } spinner.stop(mark: "!") output.rewind expect(output.read).to eq([ "\e[1G[|]\e[1G[/]", "\e[0m\e[2K", "\e[1G[!]\n" ].join) end it "sets a custom message and mark when done" do spinner = TTY::Spinner.new("[:spinner]", output: output) 2.times { spinner.spin } spinner.stop("Done", mark: "!") output.rewind expect(output.read).to eq([ "\e[1G[|]\e[1G[/]", "\e[0m\e[2K", "\e[1G[!] Done\n" ].join) end end
Version data entries
5 entries across 5 versions & 1 rubygems