-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Upgrade TTY::Cursor and add top level spinner option #15
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,26 @@ | ||
# encoding: utf-8 | ||
|
||
require 'tty-spinner' | ||
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. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# coding: utf-8 | ||
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. Missing magic comment # frozen_string_literal: true. |
||
# | ||
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. Add an empty line after magic comments. |
||
|
||
RSpec.describe TTY::Spinner::Multi, '#line_inset' do | ||
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. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
let(:output) { StringIO.new('', 'w+') } | ||
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. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
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('') | ||
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. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
|
||
it "returns the empty string for the top level spinner" do | ||
spinners = TTY::Spinner::Multi.new(output: output, message: "Top level spinner") | ||
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. Line is too long. [84/80] |
||
allow_any_instance_of(TTY::Spinner).to receive(:add_multispinner) | ||
|
||
spinners.register "" | ||
|
||
expect(spinners.line_inset(spinners.top_level_spinner)).to eq('') | ||
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. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
|
||
it "returns four spaces when there is a top level spinner" do | ||
spinners = TTY::Spinner::Multi.new(output: output, message: "Top level spinner") | ||
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. Line is too long. [84/80] |
||
allow_any_instance_of(TTY::Spinner).to receive(:add_multispinner) | ||
|
||
spinner = spinners.register "" | ||
|
||
expect(spinners.line_inset(spinner)).to eq(' ') | ||
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. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
end | ||
|
||
RSpec.describe TTY::Spinner::Multi, '#auto_spin' do | ||
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. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
let(:output) { StringIO.new('', 'w+') } | ||
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. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
it "raises and exception when #auto_spin is called without a top level spinner" do | ||
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. Line is too long. [84/80] |
||
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") | ||
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. Line is too long. [84/80] |
||
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 | ||
|
||
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. Extra empty line detected at block body 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.
Missing magic comment # frozen_string_literal: true.