Sha256: 665c993278038dcc3fb32a4e4cc1ac6e2da3954410d2a831aebbcab9ccd42579

Contents?: true

Size: 1.19 KB

Versions: 80

Compression:

Stored size: 1.19 KB

Contents

# tc_import.rb
#
#  Created by James Edward Gray II on 2005-04-26.
#  Copyright 2005 Gray Productions. All rights reserved.
#
#  This is Free Software.  See LICENSE and COPYING for details.

require "test/unit"

require "highline/import"
require "stringio"

class TestImport < Test::Unit::TestCase
  def test_import
    assert_respond_to(self, :agree)
    assert_respond_to(self, :ask)
    assert_respond_to(self, :choose)
    assert_respond_to(self, :say)
  end
  
  def test_or_ask
    old_terminal = $terminal
    
    input     = StringIO.new
    output    = StringIO.new
    $terminal = HighLine.new(input, output)  
    
    input << "10\n"
    input.rewind

    assert_equal(10, nil.or_ask("How much?  ", Integer))

    input.rewind

    assert_equal(20, "20".or_ask("How much?  ", Integer))
    assert_equal(20, 20.or_ask("How much?  ", Integer))
    
    assert_equal(10, 20.or_ask("How much?  ", Integer) { |q| q.in = 1..10 })
  ensure
    $terminal = old_terminal
  end
  
  def test_redirection
    old_terminal = $terminal
    
    $terminal = HighLine.new(nil, (output = StringIO.new))
    say("Testing...")
    assert_equal("Testing...\n", output.string)
  ensure
    $terminal = old_terminal
  end
end

Version data entries

80 entries across 70 versions & 12 rubygems

Version Path
brakeman-4.3.1 bundle/ruby/2.5.0/gems/highline-1.7.10/test/tc_import.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/highline-1.7.10/test/tc_import.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/highline-1.7.10/test/tc_import.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/highline-1.7.10/test/tc_import.rb
brakeman-4.1.1 bundle/ruby/2.3.0/gems/highline-1.7.10/test/tc_import.rb
brakeman-4.1.0 bundle/ruby/2.3.0/gems/highline-1.7.10/test/tc_import.rb
highline-1.7.10 test/tc_import.rb
brakeman-4.0.1 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-4.0.1.pre1 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-4.0.0 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-3.7.2 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-3.7.1 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-3.7.0 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-3.6.2 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-3.6.1 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-3.6.0 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-3.5.0 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-3.4.1 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-3.4.0 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb
brakeman-3.3.5 bundle/ruby/2.3.0/gems/highline-1.7.8/test/tc_import.rb