Sha256: d86dd60ed5751cc6463d97725f80cb483ab3cf0f3eb7f1f85c2f43f7694eec93

Contents?: true

Size: 1.07 KB

Versions: 25

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe Infobar::Spinner do
  it 'spins according to count' do
    spinner = described_class.new
    expect(spinner.spin(0).to_s).to eq ?|
    expect(spinner.spin(1).to_s).to eq ?/
    expect(spinner.spin(2).to_s).to eq ?–
    expect(spinner.spin(3).to_s).to eq ?\\
    expect(spinner.spin(4).to_s).to eq ?|
  end

  it 'supports different frames' do
    spinner = described_class.new(%w[ . o O ])
    expect(spinner.spin(0).to_s).to eq ?.
    expect(spinner.spin(1).to_s).to eq ?o
    expect(spinner.spin(2).to_s).to eq ?O
    expect(spinner.spin(3).to_s).to eq ?.
  end

  it 'supports different predefined frames' do
    expect do
      described_class.new(:fuck_it)
    end.to raise_error(KeyError)
    spinner = described_class.new(:cross)
    expect(spinner.spin(0).to_s).to eq ?+
    expect(spinner.spin(1).to_s).to eq ?×
    expect(spinner.spin(2).to_s).to eq ?+
  end

  it 'can spin randomly' do
    srand 1
    spinner = described_class.new(:braille7)
    expect(spinner.spin(:random).to_s).to eq ?⣟
    expect(spinner.spin(:random).to_s).to eq ?⢿
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
infobar-0.9.0 spec/infobar/spinner_spec.rb
infobar-0.8.1 spec/infobar/spinner_spec.rb
infobar-0.8.0 spec/infobar/spinner_spec.rb
infobar-0.7.4 spec/infobar/spinner_spec.rb
infobar-0.7.2 spec/infobar/spinner_spec.rb
infobar-0.7.1 spec/infobar/spinner_spec.rb
infobar-0.7.0 spec/infobar/spinner_spec.rb
infobar-0.6.2 spec/infobar/spinner_spec.rb
infobar-0.6.1 spec/infobar/spinner_spec.rb
infobar-0.6.0 spec/infobar/spinner_spec.rb
infobar-0.5.1 spec/infobar/spinner_spec.rb
infobar-0.5.0 spec/infobar/spinner_spec.rb
infobar-0.4.0 spec/infobar/spinner_spec.rb
infobar-0.3.0 spec/infobar/spinner_spec.rb
infobar-0.2.0 spec/infobar/spinner_spec.rb
infobar-0.1.1 spec/infobar/spinner_spec.rb
infobar-0.1.0 spec/infobar/spinner_spec.rb
infobar-0.0.7 spec/infobar/spinner_spec.rb
infobar-0.0.6 spec/infobar/spinner_spec.rb
infobar-0.0.5 spec/infobar/spinner_spec.rb