Skip to content

Instantly share code, notes, and snippets.

@maicher
Last active November 23, 2016 10:01
Show Gist options
  • Save maicher/405a10faebfe31f9f2225805d15dc3f7 to your computer and use it in GitHub Desktop.
Save maicher/405a10faebfe31f9f2225805d15dc3f7 to your computer and use it in GitHub Desktop.
require 'cli_spinnable'
module Cli
extend CliSpinnable
end
puts 'HAPPY RUN (should succeed):'
Cli.with_spinner do |cli|
cli.print 'Downloading something'
sleep 1
cli.print '...downloaded 1MB'
cli.tick
cli.print 'Processing data'
sleep 1
cli.tick
end
puts 'SAD RUN (should fail):'
Cli.with_spinner do |cli|
cli.print 'Downloading something'
sleep 1
cli.print '...downloaded 1MB'
cli.tick
cli.print 'Processing data'
sleep 1
1 / 0 # produces exception
cli.tick # this will not be reached
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment