Sha256: d8cc05cdc0cee8c02fd408ab325fc5676a96c39d95c13a60ad664d409543a33b

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

require_relative '../../../test_helper'
require_relative '../../../../lib/vedeu/support/events'

module Vedeu
  describe Events do
    let(:described_class)    { Events }
    let(:described_instance) { described_class.new }

    describe '#initialize' do
      let(:subject) { described_instance }

      it 'returns an Events instance' do
        subject.must_be_instance_of(Events)
      end

      it 'sets an instance variable' do
        subject.instance_variable_get('@handlers')
          .must_be_instance_of(Hash)
      end
    end

    describe '#on' do
      let(:subject) { described_instance.on(event) { proc { |x, y| x + y } } }
      let(:event)   { :some_event }

      it 'returns an Array' do
        subject.must_be_instance_of(Array)
      end
    end

    describe '#trigger' do
      let(:subject) { described_instance.trigger(event, args) }
      let(:event)   { :some_event }
      let(:args)    { :arg }

      before do
        described_instance.on(:some_event) { proc { |x| x } }
      end

      it 'returns an Array' do
        subject.must_be_instance_of(Array)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.0.30 test/lib/vedeu/support/events_test.rb
vedeu-0.0.29 test/lib/vedeu/support/events_test.rb
vedeu-0.0.28 test/lib/vedeu/support/events_test.rb
vedeu-0.0.27 test/lib/vedeu/support/events_test.rb