Sha256: ef31a0a775cd9a5caf88fe77ff3e87977d246dac69bac90dcf23f9e88fb2267d

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

# This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2009-2010, Sebastian Staudt

require 'test_helper'

class TestThrobber < Test::Unit::TestCase

  context 'A throbber' do

    should 'be a subclass of Thread' do
      assert_equal Thread, Throbber.superclass
    end

    should 'have default throbber strings' do
      assert_equal '-\|/', Throbber::SPINNER
    end

    should 'work correctly' do
      ostream = StringIO.new
      started_at  = Time.now
      finished_at = nil
      thread = Thread.new do
        sleep 1
        finished_at = Time.now
      end
      throbber = Throbber.new(ostream, thread)
      thread.join
      throbber.join

      spinner = Throbber::SPINNER
      check_throbber = ' '
      ((finished_at - started_at) / 0.25).floor.times do |char_index|
        check_throbber << "\b"
        check_throbber << spinner[char_index % 4]
      end
      check_throbber << "\b"
      assert_equal check_throbber, ostream.string
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubikon-0.5.3 test/test_throbber.rb
rubikon-0.5.2 test/test_throbber.rb
rubikon-0.5.1 test/test_throbber.rb
rubikon-0.5.0 test/test_throbber.rb
rubikon-0.4.1 test/test_throbber.rb
rubikon-0.4.0 test/test_throbber.rb