Skip to content

Commit

Permalink
Merge pull request #1024 from romanstrazanec/fix-version-check-for-ma…
Browse files Browse the repository at this point in the history
…x-major-version

Fix version check when major version is less than the max version
  • Loading branch information
bblimke authored Aug 19, 2023
2 parents dd084eb + 38ea121 commit 0771fbc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/webmock/util/version_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def compare_version
when @major < @min_major then :too_low
when @max_major && @major > @max_major then :too_high
when @major > @min_major then :ok
when @max_major && @major < @max_major then :ok
when @minor < @min_minor then :too_low
when @max_minor && @minor > @max_minor then :too_high
when @minor > @min_minor then :ok
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/util/version_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,11 @@ module WebMock
expect(Kernel).to receive(:warn).with(%r{You are using foo 2.0.0. WebMock does not support this version. WebMock supports versions >= 1.0.0, < 3.1, except versions 2.0.0.})
checker.check_version!
end

it "does not raise an error or print a warning when the max_minor_version is 1.0 and the version is 0.9" do
checker = VersionChecker.new('foo', '0.9.0', '0.8.0', '1.0')
expect(Kernel).not_to receive(:warn)#.with(%r{You are using foo 0.9.0. WebMock does not support this version. WebMock supports versions >= 0.8.0, < 1.0.})
checker.check_version!
end
end
end

0 comments on commit 0771fbc

Please sign in to comment.