Sha256: d069639c13afeb96cce5286181881ce36b95bb1b05a9eb2bc26cd07ac4e32f68
Contents?: true
Size: 1.04 KB
Versions: 8
Compression:
Stored size: 1.04 KB
Contents
module Berkshelf # Because aruba runs in a sub-process, there's no easy way to share mocks and # stubs across a run (See RiotGames/berkshelf#208). As a work-around, we pass # "special" mocks and stubs into the TEST environment variable. This class # parses and then requires the appropriate mocks during the run. # # @author Seth Vargo <sethvargo@gmail.com> class Mocks require 'rspec/mocks/standalone' class << self def env_keys self.instance_methods(false).map { |key| key.to_s.upcase } end end def initialize(keys) keys.each do |key| self.send(key.downcase.to_sym, ENV[key.to_s]) end end # Trick bundler into thinking gems are missing. # # @param [String] gems # a CSV list of gems to be missing def missing_gems(gems) gems.split(',').each do |gem| Gem::Specification.stub(:find_by_name).with(gem).and_raise(Gem::LoadError) end end end end unless (keys = Berkshelf::Mocks.env_keys & ENV.keys).empty? Berkshelf::Mocks.new(keys) end
Version data entries
8 entries across 8 versions & 1 rubygems