Sha256: a1c819c865820e493a13c56fe8a1e1f4c042ece49432248c5f3e63fba6f558f4

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

RSpec.describe TTY::Spinner, "#error" do
  let(:output) { StringIO.new("", "w+") }

  it "marks spinner as error" do
    spinner = TTY::Spinner.new(output: output)
    3.times { spinner.spin }
    spinner.error
    output.rewind
    expect(output.read).to eq([
      "\e[1G|",
      "\e[1G/",
      "\e[1G-",
      "\e[0m\e[2K",
      "\e[1G#{TTY::Spinner::CROSS}\n"
    ].join)

    expect(spinner.error?).to be(true)
  end

  it "marks spinner as error with message" do
    spinner = TTY::Spinner.new(output: output)
    3.times { spinner.spin }
    spinner.error("Error")
    output.rewind
    expect(output.read).to eq([
      "\e[1G|",
      "\e[1G/",
      "\e[1G-",
      "\e[0m\e[2K",
      "\e[1G#{TTY::Spinner::CROSS} Error\n"
    ].join)

    expect(spinner.error?).to be(true)
  end

  it "changes error spinner marker" do
    spinner = TTY::Spinner.new(error_mark: "x", output: output)
    spinner.error("(error)")
    output.rewind
    expect(output.read).to eq("\e[0m\e[2K\e[1Gx (error)\n")

    expect(spinner.error?).to be(true)
  end

  it "changes error spinner marker per method call" do
    spinner = TTY::Spinner.new(error_mark: "x", output: output)
    spinner.error("(error)", mark: "!")
    output.rewind
    expect(output.read).to eq("\e[0m\e[2K\e[1G! (error)\n")

    expect(spinner.error?).to be(true)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
planter-cli-3.0.7 lib/tty-spinner/spec/unit/error_spec.rb
planter-cli-3.0.5 lib/tty-spinner/spec/unit/error_spec.rb
planter-cli-3.0.4 lib/tty-spinner/spec/unit/error_spec.rb
planter-cli-3.0.3 lib/tty-spinner/spec/unit/error_spec.rb
planter-cli-3.0.2 lib/tty-spinner/spec/unit/error_spec.rb