Sha256: 3d97988a224629dfa454af9d01b7df569f46037c5c5e3b5105bb9f9ec67688e6

Contents?: true

Size: 1.43 KB

Versions: 20

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

module WebsocketRails

  describe SpecHelperEvent do

    before do
      @dispatcher = double(:dispatcher)
      Dispatcher.stub(:new).and_return @dispatcher
      @event = SpecHelperEvent.new('my_event', data: 'my_data')
    end

    describe 'initialize' do

      it 'should initialize the name and namespace of the event' do
        @event.namespace.should == [:global]
        @event.name.should == :my_event
      end

      it 'should initialize the data of the event' do
        @event.data.should == 'my_data'
      end

      it 'should set the event to not triggered' do
        @event.should_not be_triggered
      end

    end

    describe 'trigger' do

      it 'should set the triggered variable to true' do
        @event.trigger
        @event.should be_triggered
      end

    end

    describe 'dispatch' do

      it 'should invoke dispatch on the dispatcher object' do
        @dispatcher.should_receive(:dispatch).with(@event)
        @event.dispatch
      end

      it 'should return itself to be able to chain matchers' do
        @dispatcher.stub(:dispatch)
        @event.dispatch.should == @event
      end

    end

  end

end

describe 'create_event' do

  it 'should create a SpecHelperEvent with the correct parameters' do
    event = create_event('my_event','my_data')
    event.should be_a WebsocketRails::SpecHelperEvent
    event.name.should == :my_event
    event.data.should == 'my_data'
  end

end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
hkroger-websocket-rails-0.7.1 spec/spec_helpers/spec_helper_event_spec.rb
wwl-websocket-rails-0.7.3 spec/spec_helpers/spec_helper_event_spec.rb
wwl-websocket-rails-0.7.2 spec/spec_helpers/spec_helper_event_spec.rb
wwl-websocket-rails-0.7.1 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.7.0 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.6.2 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.6.1 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.6.0 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.5.0 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.4.9 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.4.8 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.4.7 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.4.6 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.4.5 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.4.4 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.4.3 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.4.2 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.4.1 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.4.0 spec/spec_helpers/spec_helper_event_spec.rb
websocket-rails-0.3.0 spec/spec_helpers/spec_helper_event_spec.rb