Skip to content
Extraits de code Groupes Projets
socket_controller_spec.rb 1,12 ko
Newer Older
  • Learn to ignore specific revisions
  • maxwell's avatar
    maxwell a validé
    require File.dirname(__FILE__) + '/../spec_helper'
    
    maxwell's avatar
    maxwell a validé
    describe 'SocketController' do
      render_views  
    
    maxwell's avatar
    maxwell a validé
      before do
    
        @user = Factory.create(:user)
    
    maxwell's avatar
    maxwell a validé
        SocketController.unstub!(:new)
    
    maxwell's avatar
    maxwell a validé
        #EventMachine::WebSocket.stub!(:start)
        @controller = SocketController.new
    
    maxwell's avatar
    maxwell a validé
        stub_socket_controller
    
    maxwell's avatar
    maxwell a validé
      end
    
      it 'should unstub the websocket' do
          WebSocket.initialize_channel
    
    maxwell's avatar
    maxwell a validé
          @controller.class.should == SocketController
    
    maxwell's avatar
    maxwell a validé
      end
      
      it 'should add a new subscriber to the websocket channel' do
          WebSocket.initialize_channel
          @controller.new_subscriber.should == 1
      end
    
      describe 'actionhash' do
        before do
          @message = Factory.create(:status_message, :person => @user)
        end
    
        it 'should actionhash posts' do
    
    maxwell's avatar
    maxwell a validé
          json = @controller.action_hash(@message)
          json.include?(@message.message).should be_true
          json.include?('status_message').should be_true
    
    maxwell's avatar
    maxwell a validé
    
    
        it 'should actionhash retractions' do
          retraction = Retraction.for @message
    
    maxwell's avatar
    maxwell a validé
          json = @controller.action_hash(retraction)
          json.include?('retraction').should be_true
          json.include?("html\":null").should be_true
    
    maxwell's avatar
    maxwell a validé
    end