mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
3ee734bb7e
This is an effort to vastly decrease the time it takes to run a single unit test file and therefore increase productivity and happiness for people working on this project. If you want to run a unit test file, now you can use `zeus rspec` instead of `rspec` -- assuming you run `zeus start` first -- and it will run a LOT faster. Because test files tend to have long file paths, you can even use a shorter version of those paths. So instead of saying: zeus rspec spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb you can say: zeus rspec active_record/validate_uniqueness_of_matcher_spec.rb
61 lines
1.1 KiB
Ruby
61 lines
1.1 KiB
Ruby
require 'bundler'
|
|
require 'appraisal'
|
|
|
|
module Tests
|
|
class CurrentBundle
|
|
AppraisalNotSpecified = Class.new(ArgumentError)
|
|
|
|
include Singleton
|
|
|
|
def assert_appraisal!
|
|
unless appraisal_in_use?
|
|
message = <<EOT
|
|
|
|
|
|
Please run tests starting with `appraisal <appraisal_name>`.
|
|
Possible appraisals are: #{available_appraisals}
|
|
|
|
EOT
|
|
raise AppraisalNotSpecified, message
|
|
end
|
|
end
|
|
|
|
def appraisal_in_use?
|
|
path.dirname == root.join('gemfiles')
|
|
end
|
|
|
|
def current_or_latest_appraisal
|
|
current_appraisal || latest_appraisal
|
|
end
|
|
|
|
def latest_appraisal
|
|
available_appraisals.sort.last
|
|
end
|
|
|
|
private
|
|
|
|
def available_appraisals
|
|
appraisals = []
|
|
|
|
Appraisal::File.each do |appraisal|
|
|
appraisals << appraisal.name
|
|
end
|
|
|
|
appraisals
|
|
end
|
|
|
|
def current_appraisal
|
|
if appraisal_in_use?
|
|
File.basename(path, ".gemfile")
|
|
end
|
|
end
|
|
|
|
def path
|
|
Bundler.default_gemfile
|
|
end
|
|
|
|
def root
|
|
Pathname.new('../../../..').expand_path(__FILE__)
|
|
end
|
|
end
|
|
end
|