class RoxClient::RSpec::Tasks

Public Class Methods

new() click to toggle source
# File lib/rox-client-rspec/tasks.rb, line 8
def initialize

  namespace :spec do

    namespace :rox do

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

      namespace :uid do

        desc "Generate a test run UID to group test results in ROX Center (stored in a file)"
        task :file do
          trace do
            uid = uid_manager.generate_uid_to_file
            puts Paint["ROX - 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["ROX - Cleaned test run UID", :cyan]
          end
        end
      end
    end
  end
end

Private Instance Methods

trace(&block) click to toggle source
# File lib/rox-client-rspec/tasks.rb, line 46
def trace &block
  if Rake.application.options.trace
    block.call
  else
    begin
      block.call
    rescue UID::Error => e
      warn Paint["ROX - #{e.message}", :red]
    end
  end
end
uid_manager() click to toggle source
# File lib/rox-client-rspec/tasks.rb, line 58
def uid_manager
  UID.new RoxClient::RSpec.config.client_options
end