kjs3
kjs3

Reputation: 6178

Bundler how to require gems separately in Gemfile just in one file?

I have a conflict between rspec and mocha (rspec is not using mocha but other minitest tests are).

If I put mocha in my gemfile (even with require: false) it gets loaded by activesupport/test_case.rb:15

silence_warnings { require 'mocha/setup' }

which then causes rspec to barf.

So, I'd like to just require it in my test_setup file from my system gems but I can't figure out how to load a gem outside of bundler.

Other ideas on how to get these gems to play nice are welcome.

Upvotes: 3

Views: 541

Answers (2)

Uri Agassi
Uri Agassi

Reputation: 37419

You can use groups in your Gemfile: http://bundler.io/v1.3/groups.html

Require the gems in particular groups, noting that gems outside of a named group are in the :default group

Bundler.require(:default, :development)  

Require the default gems, plus the gems in a group named the same as the current Rails environment

Bundler.require(:default, Rails.env)  

Restrict the groups of gems that you want to add to the load path. Only gems in these groups will be require'able

require 'rubygems'
require 'bundler'
Bundler.setup(:default, :ci)
require 'nokogiri'

Upvotes: 1

Nerdman
Nerdman

Reputation: 55

Could you just install gem and require it?

$ gem install my_gem

and in testfile:

require 'full/path/to/my_gem.rb'

Upvotes: 0

Related Questions