Skip to content

Instantly share code, notes, and snippets.

@apeiros
Created March 11, 2010 09:20
Show Gist options
  • Save apeiros/328985 to your computer and use it in GitHub Desktop.
Save apeiros/328985 to your computer and use it in GitHub Desktop.
module Cucumber
module Rake
class Task
class BundledCucumberRunner #:nodoc:
attr_reader :args
def initialize(executable, cucumber_opts, feature_files)
@args = (
[`which bundle`.chomp, 'exec', executable]+
cucumber_opts +
feature_files
).flatten.compact
end
def run
ENV.delete('RUBYOPT')
ENV.delete('BUNDLE_GEMFILE')
ruby(*args)
end
end
end
class Task
attr_accessor :bundle
def initialize(task_name = "cucumber", desc = "Run Cucumber features")
@task_name, @desc = task_name, desc
@fork = true
@bundle = ENV.key?('BUNDLE_GEMFILE')
@libs = ['lib']
@rcov_opts = %w{--rails --exclude osx\/objc,gems\/}
yield self if block_given?
@executable = @binary
@binary = @binary ? File.expand_path(@binary) : Cucumber::BINARY
@libs.insert(0, LIB) if binary == Cucumber::BINARY
define_task
end
def runner(task_args = nil) #:nodoc:
cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile]
if(@rcov)
RCovCucumberRunner.new(libs, binary, cucumber_opts, feature_files, rcov_opts)
elsif(@bundle)
BundledCucumberRunner.new(@executable, cucumber_opts, feature_files)
elsif(@fork)
ForkedCucumberRunner.new(libs, binary, cucumber_opts, feature_files)
else
InProcessCucumberRunner.new(libs, cucumber_opts, feature_files)
end
end
end
end
end
require 'cucumber/rake/task'
require 'bundledcucumberrunner'
namespace :cucumber do
Cucumber::Rake::Task.new({:default => ["...yourprerequisitetasks..."]}, 'Run with default profile') do |t|
t.binary = 'binary'
t.bundle = true
t.profile = 'default'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment