Simulates Highline input for use in tests.
Creates a simulator with an array of Strings as a script
# File lib/highline/simulate.rb, line 17 17: def initialize(strings) 18: @strings = strings 19: end
A wrapper method that temporarily replaces the Highline instance in $terminal with an instance of this object for the duration of the block
# File lib/highline/simulate.rb, line 42 42: def self.with(*strings) 43: @input = $terminal.instance_variable_get :@input 44: $terminal.instance_variable_set :@input, new(strings) 45: yield 46: ensure 47: $terminal.instance_variable_set :@input, @input 48: end
The simulator handles its own EOF
# File lib/highline/simulate.rb, line 37 37: def eof? 38: false 39: end
Simulate StringIO#getbyte by shifting a single character off of the next line of the script
# File lib/highline/simulate.rb, line 27 27: def getbyte 28: line = gets 29: if line.length > 0 30: char = line.slice! 0 31: @strings.unshift line 32: char 33: end 34: end
Simulate StringIO#gets by shifting a string off of the script
# File lib/highline/simulate.rb, line 22 22: def gets 23: @strings.shift 24: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.