• Run Rails tests on Gitlab CI with a Postgres database

    December 13, 2016 - 1 minute read -
    rails rake-test gitlab-ci postgres

    Gitlab CI can be used to run rails tests on every push. It’s pretty straight forward to setup.

    First create a .gitlab-ci.yml file:

    image: ruby:2.3
      - postgres:latest
      POSTGRES_DB: dbname # set database
      POSTGRES_USER: username # set username
      - apt-get update -qy
      - apt-get install -y nodejs
      - bundle install --path /cache
    # run tests
        - cp config/database-gitlab.yml config/database.yml
        - bundle exec rake db:create RAILS_ENV=test
        - bundle exec rake test

    The before_script installs everything we need to run the tests. test job creates the database and executes the tests.

    Next, create a gitlab specific database config config/database-gitlab.yml to connect to the database setup earlier.

    test: adapter: postgresql
    pool: 5
    timeout: 5000
    host: postgres
    database: dbname # set database
    user: username # set username

    Now the tests will be run on each push!

  • Reading passwords from a file with Selenium IDE and SelBlock

    April 14, 2016 - 1 minute read -
    selenium-ide selenium selblocks

    Recently I found the need to have Selenium loop through a bunch of commands for different users, each with their own usernames and passwords.

    Thankfully, it's fairly painless to setup using the SelBlock plugin for Selenium IDE.

    Create a datafile:

    [{ user: "ash", pass: "test1234" }
    ,{ user: "brock", pass: "test1234" }
    ,{ user: "jessie", pass: "test1234" }
    ,{ user: "james", pass: "test1234" }
    ,{ user: "misty", pass: "test1234" }]

    If the file is saved in the same directory as the test script, you can use a relative path.

    Loop through it and log the username:

    forJson varset.json
      getEval LOG.info("user is "${user}")
  • Moving from Heroku to Dokku

    October 3, 2015 - 3 minute read -
    node heroku dokku docker node.js paas digital-ocean ubuntu

    With Heroku's recent changes to their plan offerings, my hosting costs were suddenly about to increase form $0 a month to $42. To run an app 24 hrs a day, you need to be on the hobby tier ($7/month). Not really happy with that, I decided to look elsewhere.

    I had previously explored Amazon's elastic beanstalk PaaS, but this time around I wanted to try hosting my own PaaS. Dokku bills itself as being a "Docker powered mini-Heroku in around 200 lines of Bash". After reading good things about it, I decided to give it a shot on a Digitial Ocean dropet.

    Read more

  • Older posts