Sha256: faf3de82c1d8c5c72d8ea4a546d46ef2d95c95b194285b89926478a954d4caee

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

require 'simplecov'
SimpleCov.start

require 'rspec'
require 'bundler/audit/database'

module Fixtures
  ROOT = File.expand_path('../fixtures',__FILE__)

  TMP_DIR = File.expand_path('../tmp',__FILE__)

  module Database
    PATH = File.join(ROOT,'database')

    COMMIT = '89cdde9a725bb6f8a483bca97c5da344e060ac61'

    def self.clone
      system 'git', 'clone', '--quiet', Bundler::Audit::Database::URL, PATH
    end

    def self.reset!(commit=COMMIT)
      Dir.chdir(PATH) do
        system 'git', 'reset', '--hard', commit
      end
    end
  end

  def self.join(*paths)
    File.join(ROOT,*paths)
  end
end

module Helpers
  def sh(command, options={})
    result = `#{command} 2>&1`
    raise "FAILED #{command}\n#{result}" if $?.success? == !!options[:fail]
    result
  end

  def decolorize(string)
    string.gsub(/\e\[\d+m/, "")
  end
end

include Bundler::Audit

RSpec.configure do |config|
  include Helpers

  config.before(:suite) do
    unless File.directory?(Fixtures::Database::PATH)
      Fixtures::Database.clone
    end

    Fixtures::Database.reset!

    FileUtils.mkdir_p(Fixtures::TMP_DIR)
  end

  config.before(:each) do
    stub_const("Bundler::Audit::Database::DEFAULT_PATH",Fixtures::Database::PATH)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bundler-audit-0.8.0 spec/spec_helper.rb
bundler-audit-0.8.0.rc2 spec/spec_helper.rb
bundler-audit-0.8.0.rc1 spec/spec_helper.rb