Sha256: dc9574a0b0232797fccdfa00374ded18cbd6e987d6c5e2be3218485be6883c6a

Contents?: true

Size: 853 Bytes

Versions: 5

Compression:

Stored size: 853 Bytes

Contents

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

  it "runs animation while executing block" do
    spinner = TTY::Spinner.new(output: output, interval: 100)
    allow(spinner).to receive(:spin)
    spinner.run("done") { sleep(0.1) }
    expect(spinner).to have_received(:spin).at_least(5).times
  end

  it "runs animation and executes block within context" do
    context = spy("context")
    spinner = TTY::Spinner.new(":title", output: output)

    spinner.run("done") do
      context.call
      spinner.update(title: "executing")
    end

    expect(context).to have_received(:call).once
  end

  it "yields spinner instance when block argument is provided" do
    spinner = TTY::Spinner.new(":title", output: output)

    expect { |job|
      spinner.run("done", &job)
    }.to yield_with_args(spinner)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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