Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to quiet output from ask prompt
- Loading branch information
1 parent
fa02a81
commit fbfbb1c
Showing
4 changed files
with
80 additions
and
19 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
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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe TTY::Prompt::Question, "#default" do | ||
|
||
subject(:prompt) { TTY::TestPrompt.new(quiet: true) } | ||
|
||
it "sets quiet mode" do | ||
name = "Anonymous" | ||
prompt.input << "\n" | ||
prompt.input.rewind | ||
|
||
answer = prompt.ask("What is your name?", default: name) | ||
expect(answer).to eq(name) | ||
|
||
expect(prompt.output.string).to eq([ | ||
"What is your name? \e[90m(Anonymous)\e[0m ", | ||
"\e[2K\e[1GWhat is your name? \e[90m(Anonymous)\e[0m \n", | ||
"\e[1A\e[2K\e[1G", | ||
].join) | ||
end | ||
end |