class Tapout::Utility
Provides some convenience methods for programs using tapout for testing. Be sure to require this script to use it, e.g. in `test_helper.rb`
require 'tapout/utility'
Public Class Methods
new(output=STDOUT)
click to toggle source
Initialize new Utility
instance.
input - An input I/O, defaults to STDOUT>
# File lib/tapout/utility.rb, line 15 def initialize(output=STDOUT) @output = output end
Public Instance Methods
pause() { || ... }
click to toggle source
Pause tapout processing. This method sends a `16.chr` signal to the output.
If a block is given, the block will be called after the pause. Then the block finishes, processing with be automatically resumed.
taoput.pause do binding.pry end
# File lib/tapout/utility.rb, line 29 def pause @output.puts 16.chr if block_given? yield resume end end
pry(binding)
click to toggle source
When using binding.pry while testing with tapout, it is best to tell tapout to pause processing first. This method provides a shortcut for doing exactly with pry.
Instead of:
binding.pry
use
tapout.pry(binding)
# File lib/tapout/utility.rb, line 55 def pry(binding) pause binding.pry resume end
resume()
click to toggle source
Resume tapout processing. This method sends a `23.chr` signal to the output.
# File lib/tapout/utility.rb, line 39 def resume @output.puts 23.chr end