Sha256: e9387677e0e3fb1e3cda7ef959285a350e3391be686c493d33ff494059ca2226

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

require File.expand_path('../../helper', __FILE__)

describe('Zen::Event') do
  after do
    Zen::Event::REGISTERED.delete(:test)
  end

  it('Register an event') do
    Zen::Event.listen(:test) {}

    Zen::Event::REGISTERED.key?(:test).should == true
  end

  it('Run a single event') do
    data = 0

    Zen::Event.listen(:test) do |number|
      data = number
    end

    Zen::Event.call(:test, 10)
    data.should == 10

    Zen::Event.call(:test, 12)
    data.should == 12
  end

  it('Run multiple events') do
    data = 0

    Zen::Event.listen(:test) do |number|
      data += number
    end

    Zen::Event.listen(:test) do |number|
      data += (number * 2)
    end

    Zen::Event.call(:test, 10)
    Zen::Event.call(:test, 20)

    data.should == 90
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zen-0.3 spec/zen/event.rb
zen-0.3b1 spec/zen/event.rb
zen-0.3b spec/zen/event.rb