Search code examples
ruby-on-railscucumberbamboocapybara-webkit

Bamboo + Cucumber + Webkit driver


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!


Solution

  • 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)