Sha256: 9c8d4b0006d7196e8ef4406878c83ab9692982205979a69bc27706b73eb66d6e

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 KB

Contents

ENV["AWS_LOGS_TEST"] = "1"

# CodeClimate test coverage: https://docs.codeclimate.com/docs/configuring-test-coverage
# require 'simplecov'
# SimpleCov.start

require "pp"
require "byebug"
root = File.expand_path("../", File.dirname(__FILE__))
require "#{root}/lib/aws-logs"

module Helper
  def execute(cmd)
    puts "Running: #{cmd}" if show_command?
    out = `#{cmd}`
    puts out if show_command?
    out
  end

  # Added SHOW_COMMAND because DEBUG is also used by other libraries like
  # bundler and it shows its internal debugging logging also.
  def show_command?
    ENV['DEBUG'] || ENV['SHOW_COMMAND']
  end

  def mock_response(file, next_token: nil)
    data = JSON.load(IO.read(file))
    events = data["events"].map do |e|
      Aws::CloudWatchLogs::Types::FilteredLogEvent.new(
        log_stream_name: e["log_stream_name"],
        timestamp: e["timestamp"],
        message: e["message"],
        event_id: e["event_id"],
      )
    end
    Aws::CloudWatchLogs::Types::FilterLogEventsResponse.new(
      events: events,
      next_token: next_token,
    )
  end
end

RSpec.configure do |c|
  c.include Helper
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
aws-logs-1.0.0 spec/spec_helper.rb
aws-logs-0.5.1 spec/spec_helper.rb
aws-logs-0.5.0 spec/spec_helper.rb
aws-logs-0.4.1 spec/spec_helper.rb
aws-logs-0.4.0 spec/spec_helper.rb
aws-logs-0.3.4 spec/spec_helper.rb
aws-logs-0.3.3 spec/spec_helper.rb
aws-logs-0.3.2 spec/spec_helper.rb
aws-logs-0.3.1 spec/spec_helper.rb
aws-logs-0.3.0 spec/spec_helper.rb
aws-logs-0.2.0 spec/spec_helper.rb
aws-logs-0.1.0 spec/spec_helper.rb