Sha256: 1a61223b8407f4ede9c0f65446b4ed8dc722cf3fee737debeaf4fb9ae7cbc62e

Contents?: true

Size: 1.51 KB

Versions: 4

Compression:

Stored size: 1.51 KB

Contents

require "helper"
require "spring/test/watcher_test"
require "spring/watcher/listen"

class ListenWatcherTest < Spring::Test::WatcherTest
  def watcher_class
    Spring::Watcher::Listen
  end

  setup do
    Celluloid.boot if defined?(Celluloid)
  end

  teardown { Listen.stop }

  test "root directories" do
    begin
      other_dir_1 = File.realpath(Dir.mktmpdir)
      other_dir_2 = File.realpath(Dir.mktmpdir)
      File.write("#{other_dir_1}/foo", "foo")
      File.write("#{dir}/foo", "foo")

      watcher.add "#{other_dir_1}/foo"
      watcher.add other_dir_2
      watcher.add "#{dir}/foo"

      dirs = [dir, other_dir_1, other_dir_2].sort.map { |path| Pathname.new(path) }
      assert_equal dirs, watcher.base_directories.sort
    ensure
      FileUtils.rmdir other_dir_1
      FileUtils.rmdir other_dir_2
    end
  end

  test "root directories with a root subpath directory" do
    begin
      other_dir_1 = "#{dir}_other"
      other_dir_2 = "#{dir}_core"
      # same subpath as dir but with _other or _core appended
      FileUtils::mkdir_p(other_dir_1)
      FileUtils::mkdir_p(other_dir_2)
      File.write("#{other_dir_1}/foo", "foo")
      File.write("#{other_dir_2}/foo", "foo")
      File.write("#{dir}/foo", "foo")

      watcher.add "#{other_dir_1}/foo"
      watcher.add other_dir_2

      dirs = [dir, other_dir_1, other_dir_2].sort.map { |path| Pathname.new(path) }
      assert_equal dirs, watcher.base_directories.sort
    ensure
      FileUtils.rmdir other_dir_1
      FileUtils.rmdir other_dir_2
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/spring-watcher-listen-2.0.1/test/unit_test.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/spring-watcher-listen-2.0.1/test/unit_test.rb
spring-watcher-listen-2.0.1 test/unit_test.rb
spring-watcher-listen-2.0.0 test/unit_test.rb