Sha256: 00f717add72533620cfedc035f1135f0ebf332606c26e59daa34b398d984759c

Contents?: true

Size: 826 Bytes

Versions: 18

Compression:

Stored size: 826 Bytes

Contents

require 'spec_helper'

class MySubscriber < Reactor::Subscriber
  attr_accessor :was_called

  on_fire do
    self.was_called = true
  end
end

describe Reactor::Subscriber do

  describe 'fire' do
    subject { MySubscriber.create(event: :you_name_it).fire some: 'random', event: 'data' }

    its(:message) { should be_a Reactor::Event }
    its('message.some') { should == 'random' }

    it 'executes block given' do
      subject.was_called.should be_true
    end
  end

  describe '.subscribes_to class helper' do
  end

  describe 'matcher' do
    it 'can be set to star to bind to all events' do
      MySubscriber.create!(event: '*')
      MySubscriber.any_instance.should_receive(:fire).with({'random' => 'data', 'event' => :this_event})
      Reactor::Event.publish(:this_event, {random: 'data'})
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
reactor-0.3.2 spec/models/subscriber_spec.rb
reactor-0.3.1 spec/models/subscriber_spec.rb
reactor-0.3.0 spec/models/subscriber_spec.rb
reactor-0.2.10 spec/models/subscriber_spec.rb
reactor-0.2.9 spec/models/subscriber_spec.rb
reactor-0.2.8 spec/models/subscriber_spec.rb
reactor-0.2.7 spec/models/subscriber_spec.rb
reactor-0.2.6 spec/models/subscriber_spec.rb
reactor-0.2.5 spec/models/subscriber_spec.rb
reactor-0.2.4 spec/models/subscriber_spec.rb
reactor-0.2.3 spec/models/subscriber_spec.rb
reactor-0.2.2 spec/models/subscriber_spec.rb
reactor-0.2.1 spec/models/subscriber_spec.rb
reactor-0.2.0 spec/models/subscriber_spec.rb
reactor-0.1.4 spec/models/subscriber_spec.rb
reactor-0.1.3 spec/models/subscriber_spec.rb
reactor-0.1.2 spec/models/subscriber_spec.rb
reactor-0.1.1 spec/models/subscriber_spec.rb