File: ok_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 (21 lines) | stat: -rw-r--r-- 590 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
# frozen_string_literal: true

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

  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