Sha256: 5dca6b1bd99122da2df1f88ccb6519148de7a0e69ac8c719f95ac1ff5785c195

Contents?: true

Size: 962 Bytes

Versions: 1

Compression:

Stored size: 962 Bytes

Contents

module LookOut
  module RSpec
    class LookOutFormatter < ::RSpec::Core::Formatters::JsonFormatter
      ::RSpec::Core::Formatters.register self, :close

      def close(_notification)
        output_hash[:examples].each do |example|
          %i(description full_description pending_message).each do |key|
            example.delete(key)
          end
        end

        response = LookOut::Cast.create(
          api_key: LookOut.config.api_key,
          user: LookOut.config.user,
          data: output_hash,
          repo: LookOut.config.repo,
          sha: sha,
          env: env
        )

        STDERR.puts "\n[look-out] Cast rejected, check api key.\n" if response.code == 401
      end

      private

      def sha
        ENV['GIT_COMMIT_SHA'] || `git log -1 --format=%H`.chomp
      end

      def env
        if ENV['JENKINS'] || ENV['CI']
          :integration
        else
          :development
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
look_out-0.1.4 lib/look_out/rspec/look_out_formatter.rb