Sha256: c6035f0a693c97bf3d501e6f593f1d51983afd96842e18d97a1c09834939eb57

Contents?: true

Size: 608 Bytes

Versions: 5

Compression:

Stored size: 608 Bytes

Contents

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

  it "starts and auto spins" do
    spinner = TTY::Spinner.new(output: output, interval: 100)
    allow(spinner).to receive(:spin)

    spinner.auto_spin
    sleep 0.1
    spinner.stop

    expect(spinner).to have_received(:spin).at_least(5).times
  end

  it "restores cursor when erorr is raised" do
    spinner = TTY::Spinner.new(output: output, hide_cursor: true)

    spinner.auto_spin {
      raise "boom"
    }

    output.rewind
    expect(output.read).to start_with("\e[?25l").and end_with("\e[?25h")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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