strongqa/howitzer

View on GitHub
generators/cucumber/templates/cucumber.rake

Summary

Maintainability
Test Coverage
require 'cucumber'
require 'cucumber/rake/task'

opts = lambda do |task_name|
  [
    '-r features',
    '-v',
    '-x',
    "-f html -o ./#{Howitzer.log_dir}/#{Howitzer.driver}_#{task_name}_#{Howitzer.html_log}",
    "-f junit -o ./#{Howitzer.log_dir}",
    '-f pretty'
  ].join(' ').freeze
end

Cucumber::Rake::Task.new(:cucumber, 'Run all cucumber scenarios') do |t|
  Howitzer.current_rake_task = t.instance_variable_get :@task_name
  t.cucumber_opts = opts.call(t.instance_variable_get(:@task_name))
end

Cucumber::Rake::Task.new(:features, 'Run all workable scenarios (without @wip and @bug tags)') do |t|
  Howitzer.current_rake_task = t.instance_variable_get :@task_name
  t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags 'not @wip and not @bug'"
end

namespace :features do
  Cucumber::Rake::Task.new(:wip, 'Run scenarios in progress (with @wip tag)') do |t|
    Howitzer.current_rake_task = t.instance_variable_get :@task_name
    t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags @wip"
  end

  Cucumber::Rake::Task.new(:bug, 'Run scenarios with known bugs (with @bug tag)') do |t|
    Howitzer.current_rake_task = t.instance_variable_get :@task_name
    t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags @bug"
  end

  Cucumber::Rake::Task.new(:smoke, 'Run workable smoke scenarios (with @smoke tag)') do |t|
    Howitzer.current_rake_task = t.instance_variable_get :@task_name
    t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags '@smoke and not @wip and not @bug'"
  end

  Cucumber::Rake::Task.new(:bvt, 'Run workable build verification test scenarios') do |t|
    Howitzer.current_rake_task = t.instance_variable_get :@task_name
    t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))}
    --tags 'not @wip and not @bug and not @smoke and not @p1 and not @p2'"
  end

  Cucumber::Rake::Task.new(:p1, 'Run workable scenarios with normal priority (with @p1 tag)') do |t|
    Howitzer.current_rake_task = t.instance_variable_get :@task_name
    t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags 'not @wip and not @bug and @p1'"
  end

  Cucumber::Rake::Task.new(:p2, 'Run workable scenarios with low priority (with @p2 tag)') do |t|
    Howitzer.current_rake_task = t.instance_variable_get :@task_name
    t.cucumber_opts = "#{opts.call(t.instance_variable_get(:@task_name))} --tags 'not @wip and not @bug and @p2'"
  end
end

task default: :features