If you do serious Rails programming, you may have multiple projects for your application. For example you may have one project for an API and another for a web UI. You might also use some background processing like sidekiq etc. Every time you need to launch these services on a development environment, you have to launch all projects in separate consoles manually.
Fortunately there is a better way to do it. By using a gem ‘subcontractor’ together with ‘foreman’ gem, you can define all the projects and services that you want to launch in the ‘Procfile’, for example:
Then you can launch all the projects and services just by one command:
The solution is to use Xvfb and headless gem:
Headless is the Ruby interface for Xvfb. It allows you to create a headless display straight from Ruby code, hiding some low-level action. It can also capture images and video from the virtual framebuffer.
To run your tests in CI server, do the following steps:
- Install xvfb
$ sudo apt-get install xvfb
- Install firefox
$ sudo apt-get install firefox
- Install headless gem
$ gem install headless
add it to Gemfile
$ bundle install
- create rake task for headless jasmine runner (https://gist.github.com/nevalla/5591233)
- run or add rake task to your build configuration
<link href=”/stylesheets/application.css” media=”screen” rel=”stylesheet” type=”text/css” />
I checked capistrano and server configurations, but nothing were wrong there. Finally I figured out what was causing the problem. I have not required “sprockets/railtie” in the config/application.rb
In the Mongoid documentation especially in ‘Configuration’ section is ‘Getting Rid of Active Record’ subsection which says:
myapp/config/application.rb and near the top, remove the line
require "rails/all" and add the following lines so you end up with this:
# require "sprockets/railtie" # Uncomment this line for Rails 3.1+
In a rush I only saw number 3.1 and thought it is okay to leave it as uncommented. Current Rails version is 3.2.8 so should that line be uncommented as default on Mongoid documentation?