Sha256: d849896102672cec1434db59acbbe9a245ba360f3e7a7dacb3c8c55b451bea60

Contents?: true

Size: 1.74 KB

Versions: 2

Compression:

Stored size: 1.74 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'] = 'unix'
    assert_equal Watchr::EventHandler::Unix, Watchr.handler

    end

    if Watchr::HAVE_FSE

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

    Watchr.handler = nil
    ENV['HANDLER'] = 'osx'
    assert_equal Watchr::EventHandler::Darwin, Watchr.handler

    Watchr.handler = nil
    ENV['HANDLER'] = 'fsevent'
    assert_equal Watchr::EventHandler::Darwin, 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 & 2 rubygems

Version Path
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/watchr-0.7/test/test_watchr.rb
watchr-0.7 test/test_watchr.rb