OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/lib/tasks/cucumber.rake

102 lines
3.6 KiB

#-- copyright
# OpenProject is a project management system.
#
# Copyright (C) 2012-2013 the OpenProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
begin
require 'shellwords'
require 'cucumber'
require 'cucumber/rake/task'
namespace :cucumber do
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
t.fork = true # You may get faster startup if you set this to false
end
task :statsetup do
require 'rails/code_statistics'
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
end
def get_plugin_features(prefix = '')
features = []
Rails.application.config.plugins_to_test_paths.each do |dir|
feature_dir = Shellwords.escape(File.join(dir, 'features'))
features += [prefix, feature_dir] if File.directory?(feature_dir)
end
features
end
def define_cucumber_task(name, description, arguments=[])
desc description
task name, arguments => 'db:test:prepare' do |t, args|
if name == :custom
if not args[:features]
raise 'Please provide :features argument, e.g. rake cucumber:custom[features/my_feature.feature]'
end
features = args[:features].split(/\s+/)
else
features = get_plugin_features
if name == :all
features += [File.join(Rails.root, 'features')]
end
end
Cucumber::Rake::Task.new({:cucumber_run => 'db:test:prepare'}, 'Run features that should pass') do |t|
opts = (ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : [])
ENV.delete('CUCUMBER_OPTS')
opts += args[:options].split(/\s+/) if args[:options]
# load feature support files from Rails root
support_files = ['-r', Shellwords.escape(File.join(Rails.root, 'features'))]
support_files += get_plugin_features(prefix='-r')
t.cucumber_opts = opts + support_files + features
# If we are not in the test environment, the test gems are not loaded
# by Bundler.require in application.rb, so we need to fork.
t.fork = Rails.env != 'test'
end
Rake::Task['cucumber_run'].invoke
end
end
define_cucumber_task(:plugins, 'Run plugin features', [:options])
define_cucumber_task(:all, 'Run core and plugin features', [:options])
define_cucumber_task(:custom, 'Run features selected via features argument', [:features])
end
desc 'Alias for cucumber:ok'
task :cucumber => 'cucumber:ok'
task :default => :cucumber
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
task 'db:test:prepare' do
end
task :stats => 'cucumber:statsetup'
rescue LoadError
desc 'cucumber rake task not available (cucumber not installed)'
task :cucumber do
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
end
end
end