-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add manual_stop option #53
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../../lib/tty-spinner" | ||
|
||
spinners = TTY::Spinner::Multi.new("[:spinner] Top level spinner", | ||
manual_stop: true) | ||
|
||
sp1 = spinners.register "[:spinner] one" | ||
sp1.auto_spin | ||
|
||
sleep(2) | ||
sp1.success | ||
|
||
sp2 = spinners.register "[:spinner] two" | ||
sp3 = spinners.register "[:spinner] three" | ||
|
||
sp2.auto_spin | ||
sp3.auto_spin | ||
|
||
sleep(1) | ||
sp2.error | ||
sleep(1) | ||
sp3.success | ||
|
||
spinners.error # requires manual stop |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,27 @@ | |
spinners.auto_spin | ||
|
||
expect(jobs).to match_array(%w[one two]) | ||
expect(spinners.top_spinner.done?).to be(true) | ||
end | ||
|
||
context "when manual_stop option is set" do | ||
it "keeps the top level spinner spinning" do | ||
spinners = TTY::Spinner::Multi.new("top", output: output, manual_stop: true) | ||
jobs = [] | ||
|
||
spinners.register("one") { |sp| jobs << "one"; sp.success } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/Semicolon: Do not use semicolons to terminate expressions. |
||
spinners.register("two") { |sp| jobs << "two"; sp.success } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/Semicolon: Do not use semicolons to terminate expressions. |
||
|
||
spinners.auto_spin | ||
|
||
spinner = spinners.register("three") { |sp| jobs << "three"; sp.success } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/Semicolon: Do not use semicolons to terminate expressions. |
||
spinner.run | ||
|
||
expect(jobs).to match_array(%w[one two three]) | ||
|
||
expect(spinners.top_spinner.done?).to be(false) | ||
spinners.success | ||
expect(spinners.top_spinner.done?).to be(true) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [82/80]