Sha256: 9dd621b901716c6d7259feb70ce8976c99d85215ca5095bdb008995cdcc0cfd0

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

Feature: customise your event loop

  Prepare and check watchers are usually (but not always) used in tandem: prepare watchers
  get invoked before the process blocks and check watchers afterwards.

  Scenario: prepare loop
    Given a file named "prepare_check_example.rb" with:
      """
      require 'uvrb'

      loop = UV::Loop.default

      prepared = false
      checked  = false

      prepare = loop.prepare
      prepare.start do |e|
        puts "preparing"
        abort e.inspect if e
        prepared = true
      end

      check = loop.check
      check.start do |e|
        puts "checking"
        abort e.inspect if e
        abort "not prepared" unless prepared
        checked = true
      end

      timer = loop.timer
      timer.start(0, 200) do |e|
        puts "running cycles"
      end

      stopper = loop.timer
      stopper.start(2000, 0) do |e|
        timer.close {}
        prepare.close {}
        check.close {}
        stopper.close {}
      end

      loop.run

      abort "not checked" unless checked
      """
    When I run `ruby prepare_check_example.rb`
    Then the exit status should be 0

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
uvrb-0.2.0 features/prepare_and_check.feature
uvrb-0.1.4 features/prepare_and_check.feature
uvrb-0.1.3 features/prepare_and_check.feature
uvrb-0.1.2 features/prepare_and_check.feature
uvrb-0.1.1 features/prepare_and_check.feature
uvrb-0.1.0 features/prepare_and_check.feature