test/spinner_test.rb in collimator-0.0.2 vs test/spinner_test.rb in collimator-0.0.3
- old
+ new
@@ -1,34 +1,36 @@
-require 'test_helper'
+require_relative 'test_helper'
-class TestProgressBar < Test::Unit::TestCase
- include Collimator
+class TestSpinner < Minitest::Test
- def teardown
- $stdout = STDOUT
- end
-
def test_spinner
- spin_time = 1
+ icons = %w(- \\ | /)
+
+ spin_time = 0.5
out = capture_output do
Spinner.spin
sleep spin_time
Spinner.stop
end
- length_should_be = (spin_time / 0.1) * 2
s = out.string.clone
- assert_equal length_should_be, s.length
+ ss = s.split("\b")
+ assert_equal icons[0].strip, ss[0].strip
+ assert_equal icons[1].strip, ss[1].strip
+ assert_equal icons[2].strip, ss[2].strip
+ assert_equal icons[3].strip, ss[3].strip
+
spin_time = 0.2
out = capture_output do
Spinner.spin
sleep spin_time
Spinner.stop
end
- length_should_be = (spin_time / 0.1) * 2
s = out.string.clone
- assert_equal length_should_be, s.length
+ ss = s.split("\b")
+ assert_equal icons[0], ss[0]
+
end
end
\ No newline at end of file