mguymon
mguymon

Reputation: 9015

Reusing a Gem's rspec helpers

I have a gem, lock_jar, that changes Bundler classes at runtime. This allows Java Jar dependencies to be added to a Gemfile.

What I would love to do is reuse Bundler's rspec helpers. Right now I copied the methods from Bundler's rspec helpers so I could test the integration of LockJar and Bundler. Ideally I would like to just include Bundler's spec helpers into my specs.

Upvotes: 0

Views: 274

Answers (1)

bradx3
bradx3

Reputation: 56

There's got to be a better way to do this, but one was is to get the path to a gem using Gem::Specification.

dir = Gem::Specification.find_by_name("lock_jar").gem_dir
files = Dir.glob(File.join(dir, "spec/support/*.rb"))
files.each { |f| require(f) }

Upvotes: 2

Related Questions