0

I'd like to see all the gems that are loaded for the test environment, with versions and dependencies. Is such a thing possible?

Geo
  • 93,257
  • 117
  • 344
  • 520

2 Answers2

3

You could roll your own:

require 'bundler/setup'

group = :development

deps = Bundler.load.dependencies.select do |dep|
  dep.groups.include?(group) or dep.groups.include?(:default)
end

puts "Gems included by the bundle in group #{group}:"
deps.each do |dep|
  spec = dep.to_spec
  puts "* #{spec.name} (#{spec.version})"
end

Example Gemfile:

source 'https://rubygems.org'


gem 'sinatra'
gem 'thor'

group :test do
  gem 'rspec'
end

group :development do
  gem 'rspec'
  gem 'pry'
end

Example output:

Gems included by the bundle in group development:
* sinatra (1.4.1)
* thor (0.17.0)
* rspec (2.13.0)
* pry (0.9.12)
slhck
  • 36,575
  • 28
  • 148
  • 201
Patrick Oscity
  • 53,604
  • 17
  • 144
  • 168
1

It should already the there in your Gemfile

Anything in a block that specifies test will be part of your test environment, anything outside of the test block but not in another block would also be loaded.

All of the dependencies should be listed in the Gemfile.lock

EDIT

OK, based on your feedback, this should do what you want.

Rails c test

to open a console in the test environment

pp Gem.loaded_specs.sort

This will prettyprint all of the specs in alphabetical order

muttonlamb
  • 6,341
  • 3
  • 26
  • 35