diff --git a/spec/acceptance_spec_helper.rb b/spec/acceptance_spec_helper.rb index f9150bfe..b0730b9b 100644 --- a/spec/acceptance_spec_helper.rb +++ b/spec/acceptance_spec_helper.rb @@ -1,3 +1,9 @@ +require_relative 'support/tests/current_bundle' + +Tests::CurrentBundle.instance.assert_appraisal! + +#--- + require 'rspec/core' Dir[ File.join(File.expand_path('../support/acceptance/**/*.rb', __FILE__)) ].sort.each do |file| diff --git a/spec/support/tests/current_bundle.rb b/spec/support/tests/current_bundle.rb new file mode 100644 index 00000000..d5039a44 --- /dev/null +++ b/spec/support/tests/current_bundle.rb @@ -0,0 +1,47 @@ +require 'bundler' +require 'appraisal' + +module Tests + class CurrentBundle + AppraisalNotSpecified = Class.new(ArgumentError) + + include Singleton + + def assert_appraisal! + unless appraisal? + message = <`. +Possible appraisals are: #{possible_appraisals} + +EOT + raise AppraisalNotSpecified, message + end + end + + private + + def possible_appraisals + appraisals = [] + + Appraisal::File.each do |appraisal| + appraisals << appraisal.name + end + + appraisals + end + + def path + Bundler.default_gemfile + end + + def appraisal? + path.dirname == root.join('gemfiles') + end + + def root + Pathname.new('../../../..').expand_path(__FILE__) + end + end +end diff --git a/spec/unit_spec_helper.rb b/spec/unit_spec_helper.rb index 5806eb3f..fd000746 100644 --- a/spec/unit_spec_helper.rb +++ b/spec/unit_spec_helper.rb @@ -1,3 +1,9 @@ +require_relative 'support/tests/current_bundle' + +Tests::CurrentBundle.instance.assert_appraisal! + +#--- + require File.expand_path('../support/unit/rails_application', __FILE__) def monkey_patch_minitest_to_do_nothing