Skip to content

Commit 44c4306

Browse files
committed
Do not stub Ruby version
1 parent ebf4425 commit 44c4306

1 file changed

Lines changed: 2 additions & 20 deletions

File tree

test/prism/api/parse_test.rb

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,8 @@ def test_version_current
148148
end
149149

150150
version = RUBY_VERSION.split(".").tap { |segments| segments[0] = segments[0].succ }.join(".")
151-
stub_ruby_version(version) do
152-
error = assert_raise(CurrentVersionError) { Prism.parse("1 + 1", version: "current") }
153-
assert_includes error.message, "unknown"
154-
end
155-
156-
stub_ruby_version("2.7.0") do
157-
error = assert_raise(CurrentVersionError) { Prism.parse("1 + 1", version: "current") }
158-
assert_includes error.message, "minimum"
159-
end
151+
assert_includes CurrentVersionError.new(version).message, "unknown"
152+
assert_includes CurrentVersionError.new("2.7").message, "minimum"
160153
end
161154

162155
def test_scopes
@@ -186,16 +179,5 @@ def find_source_file_node(program)
186179
queue.concat(node.compact_child_nodes)
187180
end
188181
end
189-
190-
def stub_ruby_version(version)
191-
old_version = RUBY_VERSION
192-
193-
Object.send(:remove_const, :RUBY_VERSION)
194-
Object.const_set(:RUBY_VERSION, version)
195-
yield
196-
ensure
197-
Object.send(:remove_const, :RUBY_VERSION)
198-
Object.const_set(:RUBY_VERSION, old_version)
199-
end
200182
end
201183
end

0 commit comments

Comments
 (0)