Sha256: 5ea97d0c8267acfd69171048bd7a95e102585e68ac8a33d07e524ae7bfd07310

Contents?: true

Size: 1.09 KB

Versions: 14

Compression:

Stored size: 1.09 KB

Contents

#!/usr/bin/env ruby
# Unit test for interface.user

require 'test/unit'
require 'rubygems'; require 'require_relative'
require_relative '../../interface/user'

# Tests Trepan::UserInterface
class TestInterfaceUser < Test::Unit::TestCase

  # Test UserInterface.confirm()
  def test_confirm
    
    user_intf = Trepan::UserInterface.new(nil, nil, {:history_save => false})
    def user_intf.readline(prompt)
      $response_answer
    end

    ['y', 'Y', 'Yes', '  YES  '].each do |s|
      $response_answer = s
      ans = user_intf.confirm('Testing', true)
      assert_equal(true, ans)
    end
    
    ['n', 'N', 'No', '  NO  '].each do |s|
      $response_answer = s
      ans = user_intf.confirm('Testing', true)
      assert_equal(false, ans)
    end

    def user_intf.readline(prompt)
      raise EOFError
    end

    [true, false].each do |tf|
      assert_equal(tf, user_intf.confirm('default testing', tf))
    end

    # Ok, we'll throw in one test of EOFError
    assert_raises EOFError do 
      user_intf.readline('')
    end

  end
  # FIXME: more thorough testing of other routines in user.
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
rbx-trepanning-0.2.1-universal-rubinius-2.0 test/unit/test-intf-user.rb
rbx-trepanning-0.2.1-universal-rubinius-1.2 test/unit/test-intf-user.rb
rbx-trepanning-0.2.0-universal-rubinius-2.0 test/unit/test-intf-user.rb
rb8-trepanning-0.1.6 test/unit/test-intf-user.rb
rb8-trepanning-0.1.5 test/unit/test-intf-user.rb
rbx-trepanning-0.1.0-universal-rubinius-1.2 test/unit/test-intf-user.rb
rb8-trepanning-0.1.4 test/unit/test-intf-user.rb
rb8-trepanning-0.1.3 test/unit/test-intf-user.rb
rb8-trepanning-0.1.3-universal-ruby-1.9.2 test/unit/test-intf-user.rb
rb8-trepanning-0.1.3-universal-ruby-1.8.7 test/unit/test-intf-user.rb
rbx-trepanning-0.0.8-universal-rubinius-1.2 test/unit/test-intf-user.rb
rbx-trepanning-0.0.7-universal-rubinius-1.2 test/unit/test-intf-user.rb
rbx-trepanning-0.0.6-universal-rubinius-1.2 test/unit/test-intf-user.rb
rbx-trepanning-0.0.5-universal-rubinius-1.2.1 test/unit/test-intf-user.rb