-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_advanced_hello.rb
More file actions
33 lines (31 loc) · 1 KB
/
test_advanced_hello.rb
File metadata and controls
33 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Load in standard test frameworks
require 'minitest/spec'
require 'minitest/autorun'
# Try to load processpilot. Tell user to install if they don't have it.
begin
require 'processpilot/processpilot'
rescue LoadError
error_string = <<~EOF
Oh dear .. it didn't work. To run tests you must install ProcessPilot:
#{' '}
gem install ProcessPilot
#{' '}
EOF
puts error_string
exit
end
# The actual test
describe 'advanced_hello' do
it 'works for a random name' do
ProcessPilot.pilot('advanced_hello.rb', force_ruby_process_sync: true, debug: true) do |stdin, stdout|
stdout.readpartial(100) # => "Enter your name: "
stdin.write("daVE\n")
stdout.readpartial(100) # => What is your home town?
stdin.write("vienna\n")
stdout.readpartial(100) # => What country is that in?
stdin.write("austria\n")
output = stdout.gets.chomp # => "Hello Boris the newt"
assert_equal 'Hello Dave! You are from Vienna, AUSTRIA.', output
end
end
end