File: error_spec.rb

package info (click to toggle)
ruby-tty-prompt 0.23.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,452 kB
  • sloc: ruby: 8,847; makefile: 4
file content (26 lines) | stat: -rw-r--r-- 800 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

RSpec.describe TTY::Prompt, "#error" do
  subject(:prompt) { TTY::Prompt::Test.new }

  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
    prompt.error "Nothing is fine!", "All is broken!"
    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
    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