Skip to content

Commit

Permalink
Change the FilterVersions rewriter tests to use the `filter_versions!…
Browse files Browse the repository at this point in the history
…` method
  • Loading branch information
egiurleo committed Feb 21, 2024
1 parent 0ad3556 commit 84561f9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/rbi/rewriters/filter_versions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Buzz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
assert_equal(rbi, tree.string)
end

Expand All @@ -36,7 +36,7 @@ class Buzz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
assert_equal(<<~RBI, tree.string)
# @version < 1.0.0
class Foo; end
Expand All @@ -60,7 +60,7 @@ class Buzz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
assert_equal(<<~RBI, tree.string)
# @version > 0.4.0-prerelease
class Bar; end
Expand All @@ -87,7 +87,7 @@ class Buzz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
assert_equal(<<~RBI, tree.string)
# @version = 0.4.0
class Baz; end
Expand All @@ -111,7 +111,7 @@ class Buzz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
assert_equal(<<~RBI, tree.string)
# @version != 1.0.0
class Foo; end
Expand All @@ -138,7 +138,7 @@ class Baz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("1.1.5"))
tree.filter_versions!(Gem::Version.new("1.1.5"))
assert_equal(<<~RBI, tree.string)
# @version ~> 1.1.0
class Foo; end
Expand All @@ -162,7 +162,7 @@ class Buzz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
assert_equal(<<~RBI, tree.string)
# @version >= 0.4.0-prerelease
class Bar; end
Expand Down Expand Up @@ -192,7 +192,7 @@ class Buzz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
assert_equal(<<~RBI, tree.string)
# @version <= 1.0.0
class Foo; end
Expand All @@ -219,7 +219,7 @@ class Buzz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0-prerelease"))
tree.filter_versions!(Gem::Version.new("0.4.0-prerelease"))
assert_equal(<<~RBI, tree.string)
# @version <= 1.0.0
class Foo; end
Expand All @@ -246,7 +246,7 @@ class Baz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
assert_equal(<<~RBI, tree.string)
# @version > 0.3.0, < 1.0.0
class Foo; end
Expand Down Expand Up @@ -274,7 +274,7 @@ class Baz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
assert_equal(<<~RBI, tree.string)
# @version = 0.4.0
# @version > 0.5.0
Expand All @@ -299,7 +299,7 @@ class Baz; end

tree = Parser.parse_string(rbi)

Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
assert_equal(<<~RBI, tree.string)
# @version > 0.3.0, < 1.0.0
# @version > 1.5.0
Expand All @@ -320,7 +320,7 @@ class Foo; end
tree = Parser.parse_string(rbi)

assert_raises(Gem::Requirement::BadRequirementError) do
Rewriters::FilterVersions.filter(tree, Gem::Version.new("0.4.0"))
tree.filter_versions!(Gem::Version.new("0.4.0"))
end
end
end
Expand Down

0 comments on commit 84561f9

Please sign in to comment.