0

I'm having a lot of trouble running my cuke test cases that use capybara-webkit driver. Because this is a headless server, I'm trying to run xvfb-run to run the tests, but keep running into roadblocks.

If I try to run

xvfb-run rake cucumber:all

then I'm getting errors from my server that rake doesn't exist. (Even though it does)

If I try to run it via bundle exec

xvfb-run bundle exec rake cucumber:all

then I get an error telling me bundle doesn't exist!

Both commands DO work from the ssh into the server, but its only when coming from Bamboo that they don't. I've tried both the Rake task, and just doing up a script to run the bundle exec, but nada.

I'm wondering if anyone else has this set up, and if they could walk me through how they have it setup within bamboo... This is a pretty typical rails project, and this is my LAST stage before I can get my CI up and running.

Thanks!

Dave Sanders
  • 3,135
  • 4
  • 33
  • 43

2 Answers2

0

I think I have figured it out based on this page I found here, which was in regard to using Jenkins. http://sermoa.wordpress.com/2011/07/02/cucumber-running-headless-selenium-with-jenkins-the-easy-way/

The basic idea is to use the "headless" gem and then put this section in your env.rb for cucumber:

if ENV['HEADLESS'] == 'true'
  require 'headless'

  headless = Headless.new
  headless.start

  at_exit do
    headless.destroy
  end
end

Then run your normal rake task in bamboo with the environment variable "HEADLESS=true".

You have to have xvfb installed on the server too. (sudo apt-get install xvfb)

Dave Sanders
  • 3,135
  • 4
  • 33
  • 43
0

Here is a working updated version that will setup capybara-webkit and headless for cucumber using before/after hooks. Just include this in your support/env.rb or another support file (I used support/javascript.rb because there are a few related things I do):

Capybara.javascript_driver = :webkit

Before do
  # run capybara-webkit headless if not on mac and this test is selenium based.
  if Capybara.current_driver == :selenium
    require 'headless'
    @headless = Headless.new
    @headless.start
  end
end

After do
  @headless.destroy
end

EDIT: Here's a gist with some taggable goodness where you can use :chrome in local dev mode if you want while making sure the CI environment remains headless:

https://gist.github.com/rosskevin/5937888

kross
  • 3,627
  • 2
  • 32
  • 60