Class: TC_testTerminal
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TC_testTerminal
- Defined in:
- lib/bbcloud/vendor/gli/test/tc_terminal.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_command_exists ⇒ Object
- #test_shared_instance_is_same ⇒ Object
- #test_size_based_on_columns ⇒ Object
- #test_size_using_default ⇒ Object
- #test_size_using_default_when_exception ⇒ Object
- #test_size_using_stty ⇒ Object
- #test_size_using_tput ⇒ Object
Instance Method Details
#setup ⇒ Object
10 11 12 13 |
# File 'lib/bbcloud/vendor/gli/test/tc_terminal.rb', line 10 def setup @old_columns = ENV['COLUMNS'] @old_lines = ENV['LINES'] end |
#teardown ⇒ Object
15 16 17 18 19 |
# File 'lib/bbcloud/vendor/gli/test/tc_terminal.rb', line 15 def teardown ENV['COLUMNS'] = @old_columns ENV['LINES'] = @old_lines Terminal.default_size = [80,24] end |
#test_command_exists ⇒ Object
5 6 7 8 |
# File 'lib/bbcloud/vendor/gli/test/tc_terminal.rb', line 5 def test_command_exists assert Terminal.instance.command_exists?('ls') assert !Terminal.instance.command_exists?('asdfasfasdf') end |
#test_shared_instance_is_same ⇒ Object
21 22 23 |
# File 'lib/bbcloud/vendor/gli/test/tc_terminal.rb', line 21 def test_shared_instance_is_same assert_equal Terminal.instance,Terminal.instance end |
#test_size_based_on_columns ⇒ Object
25 26 27 28 29 |
# File 'lib/bbcloud/vendor/gli/test/tc_terminal.rb', line 25 def test_size_based_on_columns ENV['COLUMNS'] = '666' ENV['LINES'] = '777' assert_equal [666,777],Terminal.instance.size end |
#test_size_using_default ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bbcloud/vendor/gli/test/tc_terminal.rb', line 69 def test_size_using_default terminal = Terminal.new terminal.make_unsafe! terminal.instance_eval do def command_exists?(command); false; end def jruby?; false; end end ENV['COLUMNS'] = 'foo' assert_equal [80,24],terminal.size # While we have this set up, lets make sure the default change falls through Terminal.default_size = [90,45] assert_equal [90,45],terminal.size end |
#test_size_using_default_when_exception ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/bbcloud/vendor/gli/test/tc_terminal.rb', line 83 def test_size_using_default_when_exception terminal = Terminal.new terminal.instance_eval do def jruby?; raise "Problem"; end end ENV['COLUMNS'] = 'foo' assert_equal [80,24],terminal.size end |
#test_size_using_stty ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/bbcloud/vendor/gli/test/tc_terminal.rb', line 51 def test_size_using_stty terminal = Terminal.new terminal.make_unsafe! terminal.instance_eval do def run_command(command) if command == 'stty size' return '1234 5678' else raise "Unexpected command called: #{command}" end end def command_exists?(command); true; end def jruby?; false; end end ENV['COLUMNS'] = 'foo' assert_equal [5678,1234],terminal.size end |
#test_size_using_tput ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bbcloud/vendor/gli/test/tc_terminal.rb', line 31 def test_size_using_tput terminal = Terminal.new terminal.make_unsafe! terminal.instance_eval do def run_command(command) if command == 'tput cols' return '888' elsif command == 'tput lines' return '999' else raise "Unexpected command called: #{command}" end end def command_exists?(command); true; end def jruby?; true; end end ENV['COLUMNS'] = 'foo' assert_equal [888,999],terminal.size end |