File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33class RequirementChecker < Proc
4- def self . against ( present )
4+ def self . against ( present , major_only : false )
5+ present = present . split ( "." ) [ 0 ] if major_only
56 provided = Gem ::Version . new ( present )
67
78 new do |required |
8- !Gem ::Requirement . new ( required ) . satisfied_by? ( provided )
9+ requirement = Gem ::Requirement . new ( required )
10+
11+ if major_only && !requirement . requirements . map ( &:last ) . all? { |version | version . segments . one? }
12+ raise "this filter only supports major versions, but #{ required } was given"
13+ end
14+
15+ !requirement . satisfied_by? ( provided )
916 end . tap do |checker |
1017 checker . provided = provided
1118 end
@@ -21,7 +28,7 @@ def inspect
2128RSpec . configure do |config |
2229 config . filter_run_excluding realworld : true
2330
24- config . filter_run_excluding bundler : RequirementChecker . against ( Bundler ::VERSION . split ( "." ) [ 0 ] )
31+ config . filter_run_excluding bundler : RequirementChecker . against ( Bundler ::VERSION , major_only : true )
2532 config . filter_run_excluding rubygems : RequirementChecker . against ( Gem ::VERSION )
2633 config . filter_run_excluding ruby_repo : !ENV [ "GEM_COMMAND" ] . nil?
2734 config . filter_run_excluding no_color_tty : Gem . win_platform? || !ENV [ "GITHUB_ACTION" ] . nil?
You can’t perform that action at this time.
0 commit comments