Sha256: 6a4047418c240e6d74277340f07c215cd88d3d1540bccc5bfee5d4024d72ccaf

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require_relative "../lib/whirly"
require "minitest/autorun"

describe Whirly do
  describe "usage" do
    it "outputs every frame of the spinner" do
      spinner = { "frames" => ["first", "second", "third"], "interval" => 10 }

      assert_output /first.*second.*third/m do
        Whirly.start(spinner: spinner,  non_tty: true)
        sleep 0.1
        Whirly.stop
      end
    end

    it "calls spinner proc instead of frames if proc is given" do
      spinner = { "proc" => ->(){ "frame" }, "interval" => 10 }

      assert_output /frame/ do
        Whirly.start(spinner: spinner, non_tty: true)
        sleep 0.1
        Whirly.stop
      end
    end
  end

  describe ".enabled?" do
    it "returns false if whirly was not started yet" do
      refute_predicate Whirly, :enabled?
    end

    it "returns true if whirly was started, but not yet stopped" do
      Whirly.start
      assert_predicate Whirly, :enabled?
      Whirly.stop
    end

    it "returns false if whirly was stopped" do
      Whirly.start
      Whirly.stop
      refute_predicate Whirly, :enabled?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whirly-0.1.1 spec/whirly_spec.rb