Sha256: ccbf1c1c082dfb9be3b8bb815eff14245cb82f9fd88515b116cf87518cd6ad97

Contents?: true

Size: 929 Bytes

Versions: 1

Compression:

Stored size: 929 Bytes

Contents

require 'rake'
require 'rake/tasklib'

module CukeForker
  class RakeTask < Rake::TaskLib
    attr_accessor :name
    attr_accessor :verbose
    attr_accessor :features
    attr_accessor :opts

    def initialize(*args, &task_block)
      setup_ivars(args)

      desc 'Run CukeForker' unless ::Rake.application.last_comment

      task(name, *args) do |_, task_args|
        RakeFileUtils.send(:verbose, verbose) do
          if task_block
            task_block.call(*[self, task_args].slice(0, task_block.arity))
          end

          run_cukeforker
        end
      end
    end

    def setup_ivars(args)
      @name = args.shift || :cukeforker

      split = args.index("--")
      if split
        @opts = args[0..(split-1)]
        @features = args[(split+1)..-1]
      end
    end

    def run_cukeforker
      unless CukeForker::Runner.run(@features, @opts)
        raise 'Test failures'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cukeforker-2.1.1 lib/cukeforker/rake_task.rb