Sha256: e8947515b0d1f8752e3e5280f9cbaaf1020629d829f4cefeabd0e094e54685a5

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

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

require 'rubygems'
require 'spec_helper'
require 'watcher'
require 'controller'

describe EventMachine::SwinsianWatch do
  before do
    @swinsian = Controller.new
  end

  after do
    @swinsian.pause
  end

  it 'should watch playing with class' do
    watcher = nil

    EM.run {
      watcher = EM.watch_swinsian(Watcher)
      @swinsian.play

      EM::add_timer(3) {
        EM.stop
        watcher.stop
      }
    }

    watcher.user_info['length'].should be_kind_of(Float)
  end

  it 'should watch playing with block' do
    result = nil
    watcher = nil

    EM.run {
      watcher = EM.watch_swinsian {|c|
        (class << c; self; end).send(:define_method, :on_play) {|info|
          result = info
        }
      }

      @swinsian.play

      EM::add_timer(3) {
        EM.stop
        watcher.stop
      }
    }

    result.should_not be_nil
    result['length'].should be_kind_of(Float)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eventmachine-swinsian-0.0.1 spec/eventmachine-swinsian_spec.rb