Sha256: 77c8fc129ddbded50a200a10e11783450ef7a1cc117b51e8ada85bc6fa7a0ac0

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

include Mac::EventMonitor

describe Monitor do
  subject do
    Monitor.new
  end

  it 'should monitor mouse down events' do
    result = 0
    robot = Mac::Robot.new

    monitor = subject
    monitor.add_listener(:mouse_down) do |event|
      result += 1
    end

    result.should be_zero

    EM.run do
      [1, 1.5].each do |t|
        EM.add_timer(t) do
          robot.mouse_press
        end
      end

      EM.add_timer(2) do
        EM.stop
      end

      EM.add_periodic_timer(0.1) do
        monitor.run(0.1)
      end
    end

    result.should be >= 2
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mac-event-monitor-0.0.3 spec/mac-event-monitor/monitor_spec.rb
mac-event-monitor-0.0.2 spec/mac-event-monitor/monitor_spec.rb