 sinon = require('sinon')
 Q = require('q')
 CommandRunner = require('../../bin/command-runner')
+range_check = require('range_check')
 
 suite('Deploy')
 
 test('POST deploy after commit deploy branch on GitHub', (done) ->
   commitHookPayload = fs.readFileSync("#{process.cwd()}/test/data/github_commit.json", 'UTF8')
+
+  rangeCheckStub = sinon.stub(range_check, 'in_range', -> true)
 
   commandSpawnStub = sinon.stub(CommandRunner, 'spawn', ->
     return {on: ->}

      done(e)
    finally
      commandSpawnStub.restore()

  ).fail( (err) ->
    commandSpawnStub.restore()
    done(err)
  )

    catch e
      done(e)
    finally
      rangeCheckStub.restore()
      commandSpawnStub.restore()

  ).fail( (err) ->
    console.error err
    rangeCheckStub.restore()
    commandSpawnStub.restore()
    done(err)
  )
)

test('POST deploy after commit to GitHub fails if branch is not deploy', (done) ->
  rangeCheckStub = sinon.stub(range_check, 'in_range', -> true)

  commitHookResponse = JSON.parse(
    fs.readFileSync("#{process.cwd()}/test/data/github_commit_master.json", 'UTF8')
  )
