Sha256: d6be3a45f752de7ede5174adfc751b4797280bed73274567328dfb95765a1dbc

Contents?: true

Size: 1.21 KB

Versions: 142

Compression:

Stored size: 1.21 KB

Contents

#!/usr/local/bin/ruby -w

# 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

142 entries across 138 versions & 15 rubygems

Version Path
radiant-0.9.0.rc2 vendor/highline/test/tc_import.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/highline-1.5.1/test/tc_import.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/highline-1.5.1/test/tc_import.rb
highline-1.5.2 test/tc_import.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/highline-1.5.1/test/tc_import.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/highline-1.5.1/test/tc_import.rb
ginst-2009.12.8 vendor/gems/highline-1.5.0/test/tc_import.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/highline-1.5.1/test/tc_import.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/highline-1.5.1/test/tc_import.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/highline-1.5.1/test/tc_import.rb
ginst-2009.11.24 vendor/gems/highline-1.5.0/test/tc_import.rb
ginst-2009.11.23 vendor/gems/highline-1.5.0/test/tc_import.rb
middleman-0.10.17 vendor/gems/gems/highline-1.5.1/test/tc_import.rb
middleman-0.10.16 vendor/gems/gems/highline-1.5.1/test/tc_import.rb
middleman-0.10.15 vendor/gems/gems/highline-1.5.1/test/tc_import.rb
middleman-0.10.14 vendor/gems/gems/highline-1.5.1/test/tc_import.rb
ginst-2.0.1 vendor/gems/highline-1.5.0/test/tc_import.rb
ginst-2.0.0 vendor/gems/highline-1.5.0/test/tc_import.rb
radiant-rc-0.9.0 vendor/highline/test/tc_import.rb
radiant-0.8.1 vendor/highline/test/tc_import.rb