From a17f4d6605adf86883ab02316a4579aea79e4f75 Mon Sep 17 00:00:00 2001 From: Louis Antonopoulos Date: Fri, 25 Oct 2024 17:31:17 -0400 Subject: [PATCH] Add test of parsing numeric value from PrerequisitesGenerator#node_version Co-authored-by: Steve Polito --- .../suspenders/prerequisites_generator_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/generators/suspenders/prerequisites_generator_test.rb b/test/generators/suspenders/prerequisites_generator_test.rb index 9958581b..8760641e 100644 --- a/test/generators/suspenders/prerequisites_generator_test.rb +++ b/test/generators/suspenders/prerequisites_generator_test.rb @@ -21,6 +21,15 @@ class PrerequisitesGeneratorTest < Rails::Generators::TestCase end end + test "#node_version parses out the version number from an alphanumeric value" do + ClimateControl.modify NODE_VERSION: nil do + Object.any_instance.stubs(:`).returns("v1.7.4\n") + actual = Suspenders::Generators::PrerequisitesGenerator.new.node_version + + assert_match(/^1\.7\.4$/, actual) + end + end + test "generates .node-version file (from system)" do Generators::PrerequisitesGenerator.any_instance.stubs(:node_version).returns("20.0.0")