Sha256: 9959b581b798fad75e8fa99a7cd22b5812b0ab48e4b394b8878c9a456e4f5125

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 Bytes

Contents

require 'spec_helper'

# Example
class MyCommand
  include Wisper

  def execute(be_successful)
    if be_successful
      broadcast('success', 'hello')
    else
      broadcast('failure', 'world')
    end
  end
end

describe Wisper do

  it 'subscribes object to all published events' do
    listener = double('listener')
    listener.should_receive(:success).with('hello')

    command = MyCommand.new

    command.add_listener(listener)

    command.execute(true)
  end

  it 'subscribes block to all published events' do
    insider = double('Insider')
    insider.should_receive(:render).with('hello')

    command = MyCommand.new

    command.add_block_listener do |message|
      insider.render(message)
    end

    command.execute(true)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wisper-0.0.2 spec/lib/integration_spec.rb
wisper-0.0.1 spec/lib/integration_spec.rb