Module: Treebis::Test::TestTaskMisc

Included in:
TestCase
Defined in:
lib/treebis.rb

Instance Method Summary collapse

Instance Method Details

#assert_notice_outcomeObject



1392
1393
1394
1395
1396
# File 'lib/treebis.rb', line 1392

def assert_notice_outcome
  @out, @err, @res = capture3{ @task.on(nil).run }
  assert_equal ['', 'foo'], [@out, @res]
  assert_match(/hello.*HI/, @err)
end

#setup_notice_taskObject



1389
1390
1391
# File 'lib/treebis.rb', line 1389

def setup_notice_task
  @task = task.new{notice("hello","HI"); 'foo'}
end

#test_notice_colorObject



1397
1398
1399
1400
1401
# File 'lib/treebis.rb', line 1397

def test_notice_color
  setup_notice_task
  assert_notice_outcome
  assert @err.index("\e[")
end

#test_notice_no_colorObject



1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
# File 'lib/treebis.rb', line 1402

def test_notice_no_color
  cfg = Treebis::Config
  prev = cfg.color?
  cfg.no_color!
  begin
    setup_notice_task
    assert_notice_outcome
    assert @err.index('hello HI')
  ensure
    prev ? cfg.color! : cfg.no_color!
  end
end