language: node_js

services:
  - couchdb

node_js:
  - "0.10"
script: npm run $COMMAND
before_script:
  - "export DISPLAY=:99.0"
  - "sh -e /etc/init.d/xvfb start"
  - "sleep 5"

    # Workaround for Selenium #3280 issue
  - "sudo sed -i 's/^127\\.0\\.0\\.1.*$/127.0.0.1 localhost/' /etc/hosts"

    # Lets know what CouchDB we are playing with
    # and make sure its logging debug
  - "curl -X GET http://127.0.0.1:5984/"
  - "curl -X PUT http://127.0.0.1:5984/_config/log/level -d '\"debug\"'"

after_failure:
  - "curl -X GET http://127.0.0.1:5984/_log?bytes=1000000"

env:
  matrix:
  - COMMAND=test
  - CLIENT=selenium:firefox COMMAND=test
  - CLIENT=selenium:phantomjs COMMAND=test
  - COMMAND=coverage

branches:
  only:
  - master
  - /^pull*$/
