Stub Server

Introduction

For development purposes there is a mock server in the "api" subdirectory of the application source tree. This is useful for making any modifications to the application source. It may also be useful in double-checking what data a server is expected to return when developing a real server. The stub server uses the Ruby Sinatra library.

Prerequisites

To run the server Ruby and ImageMagick must first be installed. On a Debian GNU/Linux environment you can install Ruby with the command:

sudo apt-get install ruby

For OSX the command is:

brew install ruby

Further details on installing Ruby can be found on the Ruby site. On this page is a link to the installer for Windows.

Installing ImageMagick is also fairly easy on Linux or OSX. On a Debian-based environment the command is:

sudo apt-get install imagemagick

On OSX the command is:

brew install imagemagick  

Installing ImageMagick and getting it to work with Ruby is a real pain on Windows. Here are some links that may be useful:

Installing Gems

Once Ruby and ImageMagick are installed the bundler and sinatra Ruby gems need to be installed using the Ruby tool "gem". On Linux or OSX the commands are:

sudo gem install bundler
sudo gem install sinatra

On Windows omit the "sudo" at the front of the above commands

Running the Stub Server

The simplest way to run the stub server is by running the command below in the api sub-directory:

RACK_ENV=production bundle exec ruby api.rb

Runnning the server in production mode forces sinatra to bind the server to the external network interface rather than 127.0.0.1. This is necessary to make it visible from a remote computer if, for example, you want to test it with the application running on a phone.

Once the stub server is running it will be available on port 4567. In a web browser navigate to http://computer_address:4567. You should now see a web page that displays the QR Code necessary to log in to the stub server using the QR Code application. It also includes QR Codes for a number of dummy tickets as well as the manual log in details. These can be scanned in the QR Code application and it will communicate with the stub server to check in these tickets. The server will then check in ticket and prevent it from being checked in again. By refreshing the page you can see which tickets have been checked in or not.