-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade TTY::Cursor for #save and #restore
- Loading branch information
Showing
6 changed files
with
130 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# encoding: utf-8 | ||
|
||
require 'tty-spinner' | ||
|
||
spinners = TTY::Spinner::Multi.new(message: "[:spinner] Top level spinner") | ||
|
||
sp1 = spinners.register "[:spinner] one" | ||
sp2 = spinners.register "[:spinner] two" | ||
sp3 = spinners.register "[:spinner] three" | ||
|
||
spinners.auto_spin | ||
sp1.auto_spin | ||
sp2.auto_spin | ||
sp3.auto_spin | ||
|
||
sleep(2) | ||
|
||
sp1.success | ||
sleep 1 | ||
sp2.success | ||
|
||
sleep 1 | ||
|
||
sp3.error | ||
|
||
spinners.error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# coding: utf-8 | ||
# | ||
|
||
RSpec.describe TTY::Spinner::Multi, '#line_inset' do | ||
let(:output) { StringIO.new('', 'w+') } | ||
|
||
it "returns the empty string when there's no top level spinner" do | ||
spinners = TTY::Spinner::Multi.new(output: output) | ||
allow_any_instance_of(TTY::Spinner).to receive(:add_multispinner) | ||
|
||
spinner = spinners.register "" | ||
|
||
expect(spinners.line_inset(spinner)).to eq('') | ||
end | ||
|
||
it "returns the empty string for the top level spinner" do | ||
spinners = TTY::Spinner::Multi.new(output: output, message: "Top level spinner") | ||
allow_any_instance_of(TTY::Spinner).to receive(:add_multispinner) | ||
|
||
spinners.register "" | ||
|
||
expect(spinners.line_inset(spinners.top_level_spinner)).to eq('') | ||
end | ||
|
||
it "returns four spaces when there is a top level spinner" do | ||
spinners = TTY::Spinner::Multi.new(output: output, message: "Top level spinner") | ||
allow_any_instance_of(TTY::Spinner).to receive(:add_multispinner) | ||
|
||
spinner = spinners.register "" | ||
|
||
expect(spinners.line_inset(spinner)).to eq(' ') | ||
end | ||
end | ||
|
||
RSpec.describe TTY::Spinner::Multi, '#auto_spin' do | ||
let(:output) { StringIO.new('', 'w+') } | ||
|
||
it "raises and exception when #auto_spin is called without a top level spinner" do | ||
spinners = TTY::Spinner::Multi.new(output: output) | ||
allow_any_instance_of(TTY::Spinner).to receive(:add_multispinner) | ||
|
||
spinners.register "" | ||
|
||
expect { spinners.auto_spin }.to raise_exception | ||
end | ||
|
||
it "doesn't raise exception" do | ||
spinners = TTY::Spinner::Multi.new(output: output, message: "Top level spinner") | ||
allow_any_instance_of(TTY::Spinner).to receive(:add_multispinner) | ||
allow_any_instance_of(TTY::Spinner).to receive(:auto_spin) | ||
|
||
spinners.register "" | ||
|
||
expect { spinners.auto_spin }.not_to raise_exception | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters