add an option to bundler_setup! to handle testing environment where development dependencies should not be excluded in order to run proper tests

as a request during review, I made the signature of bundler_setup use the same as invoke_bundler

remove empty line in bundler_setup

ammend last commit

Fixes #2726
This commit is contained in:
Pere Urbon-Bayes 2015-03-02 14:21:08 +01:00 committed by Jordan Sissel
parent 4319119e60
commit d44b58bcdc
2 changed files with 6 additions and 5 deletions

View file

@ -90,7 +90,9 @@ module LogStash
env.downcase == "test" env.downcase == "test"
end end
def bundler_setup! def bundler_setup!(options = {})
options = {:without => [:development]}.merge(options)
options[:without] = Array(options[:without])
# make sure we use our own nicely installed bundler and not a rogue, bad, mean, ugly, stupid other bundler. bad bundler, bad bad bundler go away. # make sure we use our own nicely installed bundler and not a rogue, bad, mean, ugly, stupid other bundler. bad bundler, bad bad bundler go away.
Gem.clear_paths Gem.clear_paths
Gem.paths = ENV['GEM_HOME'] = ENV['GEM_PATH'] = logstash_gem_home Gem.paths = ENV['GEM_HOME'] = ENV['GEM_PATH'] = logstash_gem_home
@ -101,9 +103,8 @@ module LogStash
require "bundler" require "bundler"
require "logstash/bundler" require "logstash/bundler"
::Bundler.settings[:path] = LogStash::Environment::BUNDLE_DIR ::Bundler.settings[:path] = LogStash::Environment::BUNDLE_DIR
::Bundler.settings[:without] = "development" ::Bundler.settings[:without] = options[:without].join(":")
# in the context of Bundler.setup it looks like this is useless here because Gemfile path can only be specified using # in the context of Bundler.setup it looks like this is useless here because Gemfile path can only be specified using
# the ENV, see https://github.com/bundler/bundler/blob/v1.8.3/lib/bundler/shared_helpers.rb#L103 # the ENV, see https://github.com/bundler/bundler/blob/v1.8.3/lib/bundler/shared_helpers.rb#L103
::Bundler.settings[:gemfile] = LogStash::Environment::GEMFILE_PATH ::Bundler.settings[:gemfile] = LogStash::Environment::GEMFILE_PATH

View file

@ -1,7 +1,7 @@
namespace "test" do namespace "test" do
def run_rspec(*args) def run_rspec(*args)
require "logstash/environment" require "logstash/environment"
LogStash::Environment.bundler_setup! LogStash::Environment.bundler_setup!({:without => []})
require "rspec/core/runner" require "rspec/core/runner"
require "rspec" require "rspec"
RSpec::Core::Runner.run([*args]) RSpec::Core::Runner.run([*args])