Skip to content

Instantly share code, notes, and snippets.

@ritxi
Created May 13, 2016 09:04
Show Gist options
  • Save ritxi/0280a652cdafbc7c06c70b661b3f1ada to your computer and use it in GitHub Desktop.
Save ritxi/0280a652cdafbc7c06c70b661b3f1ada to your computer and use it in GitHub Desktop.
Custom Gemfile dependencies injection
--color
--require spec_helper
--require ~/.unbundled_require
--format Fuubar
def unbundled_require(gem, options = {})
if defined?(::Bundler)
spec_path = Dir.glob("#{Gem.dir}/specifications/#{gem}-*.gemspec").last
if spec_path.nil?
warn "Couldn't find #{gem}"
return
end
spec = Gem::Specification.load spec_path
spec.activate
end
begin
require options[:require] || gem
yield if block_given?
rescue Exception => err
warn "Couldn't load #{gem}: #{err}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment