代码之家  ›  专栏  ›  技术社区  ›  map7

inotify::通知程序超时

  •  0
  • map7  · 技术社区  · 6 年前

    我使用rb notify来监视Rails项目的Rspec测试中的一个目录。如果找不到文件,则inotify将继续无休止地循环。有没有办法让它在10秒后放弃。

    @notifier = INotify::Notifier.new
    @notifier.watch(DownloadHelpers::PATH.to_s, :create) do |file|
      puts "Check: #{file.name}"
    
      if file.name.eql?(File.basename(@filename.to_s))
        @pdf = PdfReader.new(@filename)
    
        # Check PDF
        expect(@pdf.page_count).to eq(1)
        expect(@pdf.pages[1]).to have_text("CONTRACTORS")
    
        @notifier.stop # Stops the infinite loop watch
      end
    end
    
    visit "/#/contractors_report"
    within "#heading" do
      expect(page).to have_text("Contractors")
    end
    
    click_on("pdf-btn")
    
    @notifier.run # Make sure we finish our thread
    
    0 回复  |  直到 6 年前