Sha256: b0833ad54e9d916d0d1a4e8f3698490623b14289a477a2981411fc216d2ea876

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

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

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

    expect(spinner.success?).to eq(true)
  end

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

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

  it "changes success spinner marker" do
    spinner = TTY::Spinner.new(success_mark: "*", output: output)
    spinner.success("(successful)")
    output.rewind
    expect(output.read).to eq("\e[0m\e[2K\e[1G* (successful)\n")

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

  it "changes success spinner marker per method call" do
    spinner = TTY::Spinner.new(success_mark: "*", output: output)
    spinner.success("(success)", mark: "V")
    output.rewind
    expect(output.read).to eq("\e[0m\e[2K\e[1GV (success)\n")

    expect(spinner.success?).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/success_spec.rb
planter-cli-3.0.5 lib/tty-spinner/spec/unit/success_spec.rb
planter-cli-3.0.4 lib/tty-spinner/spec/unit/success_spec.rb
planter-cli-3.0.3 lib/tty-spinner/spec/unit/success_spec.rb
planter-cli-3.0.2 lib/tty-spinner/spec/unit/success_spec.rb