Sha256: 0d349f9adf7d23159bf6051e2fc1edd147d11913565dcbbdea6bee7ce29967b4

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

require 'test/test_helper'

class TestWatchr < MiniTest::Unit::TestCase

  def setup
    Watchr.options = nil
  end

  ## options

  test "debug option" do
    assert_equal false, Watchr.options.debug
    Watchr.options.debug = true
    assert_equal true,  Watchr.options.debug
  end

  ## functionality

  test "debug" do
    assert_empty capture_io { Watchr.debug('abc') }.first
    Watchr.options.debug = true
    assert_equal "[watchr debug] abc\n", capture_io { Watchr.debug('abc') }.first
  end

  test "picking handler" do

    if Watchr::HAVE_REV

    Watchr.handler = nil
    ENV['HANDLER'] = 'linux'
    assert_equal Watchr::EventHandler::Unix, Watchr.handler

    Watchr.handler = nil
    ENV['HANDLER'] = 'bsd'
    assert_equal Watchr::EventHandler::Unix, Watchr.handler

    Watchr.handler = nil
    ENV['HANDLER'] = 'darwin'
    assert_equal Watchr::EventHandler::Unix, Watchr.handler

    Watchr.handler = nil
    ENV['HANDLER'] = 'unix'
    assert_equal Watchr::EventHandler::Unix, Watchr.handler

    end

    Watchr.handler = nil
    ENV['HANDLER'] = 'mswin'
    assert_equal Watchr::EventHandler::Portable, Watchr.handler

    Watchr.handler = nil
    ENV['HANDLER'] = 'cygwin'
    assert_equal Watchr::EventHandler::Portable, Watchr.handler

    Watchr.handler = nil
    ENV['HANDLER'] = 'portable'
    assert_equal Watchr::EventHandler::Portable, Watchr.handler

    Watchr.handler = nil
    ENV['HANDLER'] = 'other'
    assert_equal Watchr::EventHandler::Portable, Watchr.handler
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watchr-0.6 test/test_watchr.rb
watchr-0.5.9 test/test_watchr.rb