mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
48 lines
796 B
Ruby
48 lines
796 B
Ruby
|
require 'bundler'
|
||
|
require 'appraisal'
|
||
|
|
||
|
module Tests
|
||
|
class CurrentBundle
|
||
|
AppraisalNotSpecified = Class.new(ArgumentError)
|
||
|
|
||
|
include Singleton
|
||
|
|
||
|
def assert_appraisal!
|
||
|
unless appraisal?
|
||
|
message = <<EOT
|
||
|
|
||
|
|
||
|
Please run tests starting with `appraisal <appraisal_name>`.
|
||
|
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
|