-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change say, ok, warn and error prompts to use keyword arguments and f…
…ix color overriding
- Loading branch information
1 parent
70ff1c3
commit 6287633
Showing
6 changed files
with
69 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe TTY::Prompt, '.error' do | ||
RSpec.describe TTY::Prompt, "#error" do | ||
subject(:prompt) { TTY::TestPrompt.new } | ||
|
||
it 'displays one message' do | ||
it "displays one message" do | ||
prompt.error "Nothing is fine!" | ||
expect(prompt.output.string).to eql "\e[31mNothing is fine!\e[0m\n" | ||
end | ||
|
||
it 'displays many messages' do | ||
it "displays many messages" do | ||
prompt.error "Nothing is fine!", "All is broken!" | ||
expect(prompt.output.string).to eql "\e[31mNothing is fine!\e[0m\n\e[31mAll is broken!\e[0m\n" | ||
expect(prompt.output.string).to eq( | ||
"\e[31mNothing is fine!\e[0m\n\e[31mAll is broken!\e[0m\n") | ||
end | ||
|
||
it 'displays message with option' do | ||
it "displays message with option" do | ||
prompt.error "Nothing is fine!", newline: false | ||
expect(prompt.output.string).to eql "\e[31mNothing is fine!\e[0m" | ||
end | ||
|
||
it "changes default red color to cyan" do | ||
prompt.error("All is fine", color: :cyan) | ||
expect(prompt.output.string).to eq("\e[36mAll is fine\e[0m\n") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe TTY::Prompt, 'ok' do | ||
RSpec.describe TTY::Prompt, "#ok" do | ||
subject(:prompt) { TTY::TestPrompt.new } | ||
|
||
it 'prints text in green' do | ||
it "prints text in green" do | ||
prompt.ok("All is fine") | ||
expect(prompt.output.string).to eq("\e[32mAll is fine\e[0m\n") | ||
end | ||
|
||
it "prints multiple lines in green" do | ||
prompt.ok("All is fine", "All is good") | ||
expect(prompt.output.string).to eq( | ||
"\e[32mAll is fine\e[0m\n\e[32mAll is good\e[0m\n") | ||
end | ||
|
||
it "changes color to cyan" do | ||
prompt.ok("All is fine", color: :cyan) | ||
expect(prompt.output.string).to eq("\e[36mAll is fine\e[0m\n") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe TTY::Prompt, '#warn' do | ||
|
||
RSpec.describe TTY::Prompt, "#warn" do | ||
subject(:prompt) { TTY::TestPrompt.new } | ||
|
||
it 'displays one message' do | ||
it "displays one message" do | ||
prompt.warn "Careful young apprentice!" | ||
expect(prompt.output.string).to eql "\e[33mCareful young apprentice!\e[0m\n" | ||
end | ||
|
||
it 'displays many messages' do | ||
it "displays many messages" do | ||
prompt.warn "Careful there!", "It's dangerous!" | ||
expect(prompt.output.string).to eql "\e[33mCareful there!\e[0m\n\e[33mIt's dangerous!\e[0m\n" | ||
expect(prompt.output.string).to eq( | ||
"\e[33mCareful there!\e[0m\n\e[33mIt's dangerous!\e[0m\n") | ||
end | ||
|
||
it 'displays message with option' do | ||
it "displays message with option" do | ||
prompt.warn "Careful young apprentice!", newline: false | ||
expect(prompt.output.string).to eql "\e[33mCareful young apprentice!\e[0m" | ||
end | ||
|
||
it "changes default yellow color to cyan" do | ||
prompt.warn("All is fine", color: :cyan) | ||
expect(prompt.output.string).to eq("\e[36mAll is fine\e[0m\n") | ||
end | ||
end |