You have two options for working Behave Pro, Cucumber and Ruby: 

  1. The command line client
  2. Rake build scripts Both require the Behave gem to be installed

Installing the Behave gem

The gem is hosted on RubyGems at https://rubygems.org/gems/behave and is available direct from the website or using RubyGems. Assuming you have Ruby and RubyGems installed on your system, run:

$ gem install behave

and you will have installed the behave ruby client and its dependencies. Depending on your system, you may have to prefix the command with “sudo”.

Using the command line

Installing the gem will have placed a binary on your path named “behave”. The output of “behave –help” is as follows:

Usage: behave [options]

Specific options:
    -h, --host HOST                  Host URI for JIRA installation - This should be https://behave.pro OR JIRA Server URL
    -u, --user USER                  userId OR JIRA username
    -p, --pass PASS                  API key OR JIRA Password
    -k, --key KEY                    Project ID from the JIRA Project Admin Page
    -d, --directory [DIR]            Specify output directory (default 'features')
    -m, --manual                     Include manual tagged scenarios in download
        --proxy PROXY_URL            Pass requests through a PROXY_URL
        --bypass-ssl                 Bypass SSL certificate checking
        --help                       Show this message
        --version                    Show version

An example call could look like this:

$ behave --host https://behave.pro \
  --user "userId OR JIRA Server Username" \
  --pass "API key OR JIRA Server Password" \
  --key 10100 \
  --directory features \
  --manual

Note: The host for Cloud should be as above, but for JIRA Server, enter your full JIRA Server instance URL.

This would download all .feature files from the 10100 project to the features directory (relative to the directory behave was run from), including all scenarios tagged as manual.

Rake

You are more than likely to be using Rake in your Ruby project for scripting your builds. Cucumber comes with its own Rake task ready for you to use and looks like this:

require 'cucumber/rake/task'

Cucumber::Rake::Task.new(:features) do |t|
  t.cucumber_opts = "--format pretty"
end

This cucumber task can be executed using the following command;

$ rake features

As our Features and Scenarios are stored within JIRA/Behave Pro we will need to download them. To do this we will add a new Rake task that will download them using the “Behave” Ruby gem.

require 'behave'

desc "Download features"
task :download do
  Behave::FeatureDownloader.new({
    'host'   => 'https://behave.pro for Cloud OR JIRA Server URL',
    'user'   => 'Cloud userId OR JIRA Server Username',
    'pass'   => 'Cloud API key OR JIRA Server Password',
    'key'    => 10100,
    'dir'    => 'features',
    'manual' => true
  })
end

This task can be executed using the following command:

$ rake download

We can now download our Features and Scenarios from JIRA/Behave Pro but we will always have to remember to run “rake download” before “rake features”. To avoid this we can configure the Cucumber “features” task to depend on the Behave “download” task and execute it before running Cucumber. This just requires one additional line in your rake file.

task :features => :download

The full Rakefile can be found in the example project on Bitbucket.

Proxy

If you need to specify a proxy to pass requests through, use the –proxy flag from the command line or pass 'proxy’ => 'MY_PROXY’ argument into FeatureDownloader i.e.

$ behave --host https://behave.pro \
  --proxy https://some.proxy.url

or

task :download do
  Behave::FeatureDownloader.new({
    ...
    'proxy' => 'http://some.proxy.url'
    ...
  })
end

Bypassing SSL

If you experience problems with your SSL certificate, you can bypass SSL checking in behave by using the –bypass-ssl command line flag, or the 'bypass_ssl’ => true FeatureDownloader argument.

Did this answer your question?