Skip to content

Commit

Permalink
Merge pull request #269 from Shopify/emily/filter-versions-test
Browse files Browse the repository at this point in the history
Change the `FilterVersions` rewriter tests to use the `filter_versions!` method
  • Loading branch information
egiurleo authored Feb 23, 2024
2 parents 0ad3556 + 55cdd73 commit fd05e9b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/rbi/rewriters/filter_versions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 fd05e9b

Please sign in to comment.