Sha256: 222e8a24bce1e2aa8d04ab24c9e4f1d52a7dfe7a93cfcc198a44f2861cf01616

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

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

  it "hides cursor" do
    spinner = TTY::Spinner.new(output: output, hide_cursor: true)
    4.times { spinner.spin }
    spinner.stop
    output.rewind
    expect(output.read).to eq([
      "\e[?25l\e[1G|",
      "\e[1G/",
      "\e[1G-",
      "\e[1G\\",
      "\e[0m\e[2K",
      "\e[1G\\\n",
      "\e[?25h"
    ].join)
  end

  it "restores cursor on success" do
    spinner = TTY::Spinner.new(output: output, hide_cursor: true)
    4.times { spinner.spin }
    spinner.success("success")
    output.rewind
    expect(output.read).to eq([
      "\e[?25l\e[1G|",
      "\e[1G/",
      "\e[1G-",
      "\e[1G\\",
      "\e[0m\e[2K",
      "\e[1G\u2714 success\n",
      "\e[?25h"
    ].join)
  end

  it "restores cursor on error" do
    spinner = TTY::Spinner.new(output: output, hide_cursor: true)
    4.times { spinner.spin }
    spinner.error("error")
    output.rewind
    expect(output.read).to eq([
      "\e[?25l\e[1G|",
      "\e[1G/",
      "\e[1G-",
      "\e[1G\\",
      "\e[0m\e[2K",
      "\e[1G\u2716 error\n",
      "\e[?25h"
    ].join)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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