Sha256: f02e29d81f92052d40b678686caba3189cc867a927a41b9729f0c1a3718fe8fc

Contents?: true

Size: 1.93 KB

Versions: 13

Compression:

Stored size: 1.93 KB

Contents

require 'vault-test-tools'
require 'vault-tools'
require 'rr'

ENV['RACK_ENV'] = 'test'

module LoggedDataHelper
  def logged_data
    Hash[Scrolls.stream.string.split(/\s+/).map {|p| p.split('=') }]
  end
end

# Overwrite the Rollbar module
module Rollbar
  # A place to store the exceptions
  def self.exceptions
    @exceptions ||= []
  end

  # Store calls to notify in an array instead
  # of calling out to the Rollbar service
  def self.notify(exception, opts = {})
    self.exceptions << [exception, opts]
  end
end

# Clear the stored exceptions in Rollbar
# so each test starts w. a clean slate
module RollbarHelper
  def setup
    super
    Rollbar.exceptions.clear
  end
end

class Vault::TestCase
  include Vault::Test::EnvironmentHelpers
  include RollbarHelper
end

module StubbedS3
  class FakeFile
    def initialize(contents=nil)
      @contents = contents
    end

    def write(contents)
      @contents = contents
    end

    def read
      @contents
    end
  end

  class FakeBucket
    def initialize
      @files = {}
    end

    def [](file_name)
      @files[file_name] ||= FakeFile.new
    end

    def write(file_name, contents)
      @files[file_name].write(contents)
    end

    def objects
      self
    end
  end

  class FakeClient
    def initialize
      @buckets = {}
    end

    def [](bucket_name)
      @buckets[bucket_name] ||= FakeBucket.new
    end

    def buckets
      self
    end
  end

  class << self
    def seed(bucket, file, contents)
      fake_client.buckets[bucket].objects[file].write(contents)
    end

    def fake_client
      @client ||= FakeClient.new
    end

    def enable!(env, opts={})
      AWS.stub!
      expected_aws_args = {
        access_key_id: opts.fetch(:access_key_id, 'FAKE_ID'),
        secret_access_key: opts.fetch(:secret_access_key, 'FAKE_KEY'),
        use_ssl: opts.fetch(:use_ssl, true)
      }
      env.stub(AWS::S3).new(expected_aws_args) { fake_client }
    end
  end
end

Vault.setup

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
vault-tools-1.0.1 test/helper.rb
vault-tools-1.0.0 test/helper.rb
vault-tools-0.7.1 test/helper.rb
vault-tools-0.7.0 test/helper.rb
vault-tools-0.6.5 test/helper.rb
vault-tools-0.6.4 test/helper.rb
vault-tools-0.6.3 test/helper.rb
vault-tools-0.6.2 test/helper.rb
vault-tools-0.6.1 test/helper.rb
vault-tools-0.6.0 test/helper.rb
vault-tools-0.5.22 test/helper.rb
vault-tools-0.5.21 test/helper.rb
vault-tools-0.5.19 test/helper.rb