Sha256: 8bb2477dffbff4d213b876cc780c821be998cbcbfecead6fffec81c8f49c15ca

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require 'fileutils'
require 'rake/tasklib'

module ProbeDockRSpec

  class Tasks < ::Rake::TaskLib

    def initialize

      namespace :spec do

        namespace 'probedock' do

          desc "Generate a test run UID to group test results in ProbeDock (stored in an environment variable)"
          task :uid do
            trace do
              uid = uid_manager.generate_uid_to_env
              puts Paint["ProbeDock - Generated UID for test run: #{uid}", :cyan]
            end
          end

          namespace :uid do

            desc "Generate a test run UID to group test results in ProbeDock (stored in a file)"
            task :file do
              trace do
                uid = uid_manager.generate_uid_to_file
                puts Paint["ProbeDock - Generated UID for test run: #{uid}", :cyan]
              end
            end

            desc "Clean the test run UID (file and environment variable)"
            task :clean do
              trace do
                uid_manager.clean_uid
                puts Paint["ProbeDock - Cleaned test run UID", :cyan]
              end
            end
          end
        end
      end
    end

    private

    def trace &block
      if Rake.application.options.trace
        block.call
      else
        begin
          block.call
        rescue UID::Error => e
          warn Paint["ProbeDock - #{e.message}", :red]
        end
      end
    end

    def uid_manager
      UID.new ProbeDockRSpec.config.client_options
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
probedock-rspec-0.5.3 lib/probe_dock_rspec/tasks.rb