 
     it 'does not respond to non-giphy command with args', ->
       testHubot @robot.respond, 'notgiphy test'
+      @giphy.respond.should.not.have.been.called
+
+    it 'does not respond to giphy command with a leading space', ->
+      testHubot @robot.respond, ' giphy test'
       @giphy.respond.should.not.have.been.called
 
     it 'matches giphy command args', ->

      it 'handles the response callback', ->
        state = { msg: 'msg', args: 'testing' }
        @fakes.stub @giphy.api, 'search', (options, callback) -> callback 'error', sampleCollectionResult
        @fakes.stub @giphy, 'handleResponse'
        @giphy.getSearchUri state
        @giphy.handleResponse.should.have.been.called.once
        @giphy.handleResponse.should.have.been.calledWith state, 'error', sinon.match.func

      it 'calls getRandomUri for empty args', ->
        @fakes.stub @giphy, 'getRandomUri'

        @giphy.getHelp.should.have.been.called.once
        @giphy.getHelp.should.have.been.calledWith state

    describe '.handleResponse', ->
      it 'sends a response when there is no error', ->
        state = { }
        uriCreator = @fakes.stub().returns sampleUri
        @fakes.stub @giphy, 'sendResponse'
        @giphy.handleResponse state, null, uriCreator
        uriCreator.should.have.been.called.once
        @giphy.sendResponse.should.have.been.called.once
        @giphy.sendResponse.should.have.been.calledWith { uri: sampleUri }
        should.exist state.uri
        state.uri.should.eql sampleUri

      it 'sends an error when the state is missing a valid uri', ->
        state = { msg: @msg }
        uriCreator = @fakes.stub().returns sampleUri
        @fakes.stub @giphy, 'error'
        @giphy.handleResponse state, 'error', uriCreator
        uriCreator.should.not.have.been.called
        @giphy.error.should.have.been.called.once
        @giphy.error.should.have.been.calledWith state.msg, 'error'
        should.not.exist state.uri

    describe '.sendResponse', ->
      beforeEach ->
        @fakes.stub @giphy, 'sendMessage'
