@@ -48,21 +48,19 @@ class Importmap::NpmTest < ActiveSupport::TestCase
48
48
49
49
test "warns (and ignores) vendored packages without version" do
50
50
Dir . mktmpdir do |vendor_path |
51
- with_vendored_package ( vendor_path , "foo.js" ) do |foo_path |
52
- with_vendored_package ( vendor_path , "baz.js" ) do |baz_path |
53
- npm = Importmap ::Npm . new ( file_fixture ( "import_map_without_cdn_and_versions.rb" ) , vendor_path : vendor_path )
54
-
55
- outdated_packages = [ ]
56
- stdout , _stderr = capture_io { outdated_packages = npm . outdated_packages }
57
-
58
- expected = [
59
- "Ignoring foo (#{ foo_path } ) since no version is specified in the importmap\n " ,
60
- "Ignoring @bar/baz (#{ baz_path } ) since no version is specified in the importmap\n "
61
- ]
62
- assert_equal ( expected , stdout . lines )
63
- assert_equal ( 0 , outdated_packages . size )
64
- end
65
- end
51
+ foo_path = create_vendored_file ( vendor_path , "foo.js" )
52
+ baz_path = create_vendored_file ( vendor_path , "baz.js" )
53
+
54
+ npm = Importmap ::Npm . new ( file_fixture ( "import_map_without_cdn_and_versions.rb" ) , vendor_path : vendor_path )
55
+
56
+ outdated_packages = [ ]
57
+ stdout , _stderr = capture_io { outdated_packages = npm . outdated_packages }
58
+
59
+ assert_equal ( <<~OUTPUT , stdout )
60
+ Ignoring foo (#{ foo_path } ) since no version is specified in the importmap
61
+ Ignoring @bar/baz (#{ baz_path } ) since no version is specified in the importmap
62
+ OUTPUT
63
+ assert_equal ( 0 , outdated_packages . size )
66
64
end
67
65
end
68
66
@@ -142,11 +140,9 @@ def code() "200" end
142
140
end
143
141
end
144
142
145
- def with_vendored_package ( dir , name )
143
+ def create_vendored_file ( dir , name )
146
144
path = File . join ( dir , name )
147
145
File . write ( path , "console.log(123)" )
148
- yield path
149
- ensure
150
- File . delete ( path )
146
+ path
151
147
end
152
148
end
0 commit comments