Sha256: c6013eeb71a48d4f01cc63c4bb72074acee1ece14b92191a67cd7fd048f383a4

Contents?: true

Size: 1.3 KB

Versions: 35

Compression:

Stored size: 1.3 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], "Got #{curr.inspect}"
  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]
    assert RubyText.flags == orig

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

    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

35 entries across 35 versions & 1 rubygems

Version Path
rubytext-0.1.11 test/auto.rb
rubytext-0.1.10 test/auto.rb
rubytext-0.1.8 test/auto.rb
rubytext-0.1.7 test/auto.rb
rubytext-0.1.6 test/auto.rb
rubytext-0.1.5 test/auto.rb
rubytext-0.1.4 test/auto.rb
rubytext-0.1.3 test/auto.rb
rubytext-0.1.2 test/auto.rb
rubytext-0.1.1 test/auto.rb
rubytext-0.1.0 test/auto.rb
rubytext-0.0.99 test/auto.rb
rubytext-0.0.98 test/auto.rb
rubytext-0.0.97 test/auto.rb
rubytext-0.0.96 test/auto.rb
rubytext-0.0.95 test/auto.rb
rubytext-0.0.94 test/auto.rb
rubytext-0.0.93 test/auto.rb
rubytext-0.0.92 test/auto.rb
rubytext-0.0.91 test/auto.rb