Sha256: 575d4b18f117043fc539b6a9cd4003da55228ad2e779711ccaa39e0a76033245

Contents?: true

Size: 1.29 KB

Versions: 23

Compression:

Stored size: 1.29 KB

Contents

$LOAD_PATH << "."

require "minitest/autorun"

require 'rubytext'

at_exit { RubyText.stop }

class MyTest < Minitest::Test

  def show_lines(text)
    lines = text.split("\n")
    str = "#{lines.size} lines\n"
    lines.each {|line| str << "  #{line.inspect}\n" }
    str
  end

  def test_001_start_no_params
    RubyText.start
    curr = RubyText.flags
    RubyText.stop
    assert curr == [:cbreak, :echo, :keypad, :cursor, :_raw]
  end

  def test_002_start_bad_param
    assert_raises(RTError) { RubyText.start(:foobar); RubyText.stop }
  end

  def test_003_start_bad_color
    assert_raises(RTError) { RubyText.start(fg: :chartreuse); RubyText.stop }
  end

  def test_004_set_reset
    RubyText.start
    orig = [:cbreak, :echo, :keypad, :cursor, :_raw]
    assert RubyText.flags == orig

    used = [:raw, :_cursor, :_echo]
    RubyText.set(*used)
    curr = RubyText.flags
    assert used.all? {|x| curr.include? x }

    RubyText.reset
    assert RubyText.flags == orig

    RubyText.stop
  end

  def test_005_set_block
    RubyText.start
    orig = RubyText.flags
    used = [:raw, :_cursor, :_echo]
    RubyText.set(*used) do 
      curr = RubyText.flags
      assert used.all? {|x| curr.include? x }
    end
    # outside block again...
    assert RubyText.flags == orig

    RubyText.stop
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rubytext-0.0.70 test/auto.rb
rubytext-0.0.69 test/auto.rb
rubytext-0.0.68 test/auto.rb
rubytext-0.0.67 test/auto.rb
rubytext-0.0.66 test/auto.rb
rubytext-0.0.65 test/auto.rb
rubytext-0.0.64 test/auto.rb
rubytext-0.0.63 test/auto.rb
rubytext-0.0.62 test/auto.rb
rubytext-0.0.61 test/auto.rb
rubytext-0.0.60 test/auto.rb
rubytext-0.0.59 test/auto.rb
rubytext-0.0.58 test/auto.rb
rubytext-0.0.57 test/auto.rb
rubytext-0.0.56 test/auto.rb
rubytext-0.0.55 test/auto.rb
rubytext-0.0.54 test/auto.rb
rubytext-0.0.53 test/auto.rb
rubytext-0.0.52 test/auto.rb
rubytext-0.0.51 test/auto.rb