mini_portile2 2.8.4 → 2.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,139 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestActivate < TestCase
4
+ attr_reader :recipe
5
+
6
+ def setup
7
+ super
8
+
9
+ @save_env = %w[PATH CPATH LIBRARY_PATH LDFLAGS].inject({}) do |env, var|
10
+ env.update(var => ENV[var])
11
+ end
12
+
13
+ FileUtils.rm_rf(["tmp", "ports"]) # remove any previous test files
14
+
15
+ @recipe = MiniPortile.new("foo", "1.0.0").tap do |recipe|
16
+ recipe.logger = StringIO.new
17
+ end
18
+ end
19
+
20
+ def teardown
21
+ FileUtils.rm_rf(["tmp", "ports"]) # remove any previous test files
22
+
23
+ @save_env.each do |var, val|
24
+ ENV[var] = val
25
+ end
26
+
27
+ super
28
+ end
29
+
30
+ def test_PATH_env_var_when_bin_does_not_exist
31
+ ENV["PATH"] = "foo"
32
+ refute(Dir.exist?(bin_path))
33
+ refute_includes(path_elements('PATH'), bin_path)
34
+
35
+ recipe.activate
36
+
37
+ refute_includes(path_elements('PATH'), bin_path)
38
+ end
39
+
40
+ def test_PATH_env_var_when_bin_exists
41
+ ENV["PATH"] = "foo"
42
+ FileUtils.mkdir_p(bin_path)
43
+ refute_includes(path_elements('PATH'), bin_path)
44
+
45
+ recipe.activate
46
+
47
+ assert_includes(path_elements('PATH'), bin_path)
48
+ assert_equal(path_elements('PATH').first, bin_path)
49
+ end
50
+
51
+ def test_CPATH_env_var_when_include_does_not_exist
52
+ ENV["CPATH"] = "foo"
53
+ refute(Dir.exist?(include_path))
54
+ refute_includes(path_elements('CPATH'), include_path)
55
+
56
+ recipe.activate
57
+
58
+ refute_includes(path_elements('CPATH'), include_path)
59
+ end
60
+
61
+ def test_CPATH_env_var_when_include_exists
62
+ ENV["CPATH"] = "foo"
63
+ FileUtils.mkdir_p(include_path)
64
+ refute_includes(path_elements('CPATH'), include_path)
65
+
66
+ recipe.activate
67
+
68
+ assert_includes(path_elements('CPATH'), include_path)
69
+ assert_equal(path_elements('CPATH').first, include_path)
70
+ end
71
+
72
+ def test_LIBRARY_PATH_env_var_when_lib_does_not_exist
73
+ ENV["LIBRARY_PATH"] = "foo"
74
+ refute(Dir.exist?(lib_path))
75
+ refute_includes(path_elements('LIBRARY_PATH'), lib_path)
76
+
77
+ recipe.activate
78
+
79
+ refute_includes(path_elements('LIBRARY_PATH'), lib_path)
80
+ end
81
+
82
+ def test_LIBRARY_PATH_env_var_when_lib_exists
83
+ ENV["LIBRARY_PATH"] = "foo"
84
+ FileUtils.mkdir_p(lib_path)
85
+ refute_includes(path_elements('LIBRARY_PATH'), lib_path)
86
+
87
+ recipe.activate
88
+
89
+ assert_includes(path_elements('LIBRARY_PATH'), lib_path)
90
+ assert_equal(path_elements('LIBRARY_PATH').first, lib_path)
91
+ end
92
+
93
+ def test_LDFLAGS_env_var_when_not_cross_compiling
94
+ ENV["LDFLAGS"] = "-lfoo"
95
+ FileUtils.mkdir_p(lib_path)
96
+ assert_equal(recipe.host, recipe.original_host) # assert on setup)
97
+
98
+ refute_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
99
+
100
+ recipe.activate
101
+
102
+ refute_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
103
+ end
104
+
105
+ def test_LDFLAGS_env_var_when_cross_compiling
106
+ ENV["LDFLAGS"] = "-lfoo"
107
+ recipe.host = recipe.original_host + "-x" # make them not-equal
108
+ FileUtils.mkdir_p(lib_path)
109
+
110
+ refute_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
111
+
112
+ recipe.activate
113
+
114
+ assert_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
115
+ assert_equal(flag_elements('LDFLAGS').first, "-L#{lib_path}")
116
+ end
117
+
118
+ private
119
+
120
+ def path_elements(varname)
121
+ ENV.fetch(varname, "").split(File::PATH_SEPARATOR)
122
+ end
123
+
124
+ def flag_elements(varname)
125
+ ENV.fetch(varname, "").split
126
+ end
127
+
128
+ def bin_path
129
+ MiniPortile.native_path(File.join(recipe.path, "bin"))
130
+ end
131
+
132
+ def include_path
133
+ MiniPortile.native_path(File.join(recipe.path, "include"))
134
+ end
135
+
136
+ def lib_path
137
+ MiniPortile.native_path(File.join(recipe.path, "lib"))
138
+ end
139
+ end
data/test/test_cmake.rb CHANGED
@@ -14,12 +14,16 @@ class TestCMake < TestCase
14
14
  create_tar(@tar_path, @assets_path, "test-cmake-1.0")
15
15
  start_webrick(File.dirname(@tar_path))
16
16
 
17
+ @logger = StringIO.new # IO to keep recipe logs in case we need to debug
17
18
  @recipe = init_recipe
18
19
 
19
20
  git_dir = File.join(@assets_path, "git")
20
21
  with_custom_git_dir(git_dir) do
21
22
  recipe.cook
22
23
  end
24
+ rescue => e
25
+ puts @logger.string
26
+ raise e
23
27
  end
24
28
 
25
29
  def after_all
@@ -58,6 +62,7 @@ class TestCMake < TestCase
58
62
 
59
63
  def init_recipe
60
64
  MiniPortileCMake.new("test-cmake", "1.0").tap do |recipe|
65
+ recipe.logger = @logger
61
66
  recipe.files << "http://localhost:#{HTTP_PORT}/#{ERB::Util.url_encode(File.basename(@tar_path))}"
62
67
  recipe.patch_files << File.join(@assets_path, "patch 1.diff")
63
68
  end
@@ -83,22 +88,20 @@ class TestCMakeConfig < TestCMake
83
88
  end
84
89
 
85
90
  def test_configure_defaults_with_macos
86
- recipe = init_recipe
87
- recipe.host = 'some-host'
88
-
89
91
  with_env({ "CC" => nil, "CXX" => nil }) do
90
92
  MiniPortile.stub(:darwin?, true) do
91
93
  with_stubbed_target(os: 'darwin22', cpu: 'arm64') do
92
- with_compilers(recipe, host_prefix: true, c_compiler: 'clang', cxx_compiler: 'clang++') do
94
+ with_compilers(c_compiler: 'clang', cxx_compiler: 'clang++') do
93
95
  Open3.stub(:capture2, cmake_help_mock('Unix')) do
94
96
  assert_equal(
95
97
  [
96
98
  "-DCMAKE_SYSTEM_NAME=Darwin",
97
99
  "-DCMAKE_SYSTEM_PROCESSOR=arm64",
98
- "-DCMAKE_C_COMPILER=some-host-clang",
99
- "-DCMAKE_CXX_COMPILER=some-host-clang++"
100
+ "-DCMAKE_C_COMPILER=clang",
101
+ "-DCMAKE_CXX_COMPILER=clang++",
102
+ "-DCMAKE_BUILD_TYPE=Release"
100
103
  ],
101
- recipe.configure_defaults)
104
+ @recipe.configure_defaults)
102
105
  end
103
106
  end
104
107
  end
@@ -106,39 +109,57 @@ class TestCMakeConfig < TestCMake
106
109
  end
107
110
  end
108
111
 
109
- def test_configure_defaults_with_manual_system_name
110
- recipe = init_recipe
111
- recipe.system_name = 'Custom'
112
-
113
- MiniPortile.stub(:darwin?, false) do
114
- with_stubbed_target do
115
- with_compilers(recipe) do
112
+ def test_configure_defaults_with_freebsd
113
+ with_env({ "CC" => nil, "CXX" => nil }) do
114
+ with_stubbed_target(os: 'freebsd14') do
115
+ with_compilers(c_compiler: 'cc', cxx_compiler: 'c++') do
116
116
  Open3.stub(:capture2, cmake_help_mock('Unix')) do
117
117
  assert_equal(
118
118
  [
119
- "-DCMAKE_SYSTEM_NAME=Custom",
119
+ "-DCMAKE_SYSTEM_NAME=FreeBSD",
120
120
  "-DCMAKE_SYSTEM_PROCESSOR=x86_64",
121
- "-DCMAKE_C_COMPILER=gcc",
122
- "-DCMAKE_CXX_COMPILER=g++"
121
+ "-DCMAKE_C_COMPILER=cc",
122
+ "-DCMAKE_CXX_COMPILER=c++",
123
+ "-DCMAKE_BUILD_TYPE=Release"
123
124
  ],
124
- recipe.configure_defaults)
125
+ @recipe.configure_defaults)
125
126
  end
126
127
  end
127
128
  end
128
129
  end
129
130
  end
130
131
 
131
- def test_configure_defaults_with_unix_makefiles
132
- recipe = init_recipe
132
+ def test_configure_defaults_with_manual_system_name
133
+ MiniPortile.stub(:darwin?, false) do
134
+ with_stubbed_target do
135
+ with_compilers do
136
+ Open3.stub(:capture2, cmake_help_mock('Unix')) do
137
+ @recipe.stub(:system_name, 'Custom') do
138
+ assert_equal(
139
+ [
140
+ "-DCMAKE_SYSTEM_NAME=Custom",
141
+ "-DCMAKE_SYSTEM_PROCESSOR=x86_64",
142
+ "-DCMAKE_C_COMPILER=gcc",
143
+ "-DCMAKE_CXX_COMPILER=g++",
144
+ "-DCMAKE_BUILD_TYPE=Release"
145
+ ],
146
+ @recipe.configure_defaults)
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
152
+ end
133
153
 
154
+ def test_configure_defaults_with_unix_makefiles
134
155
  MiniPortile.stub(:linux?, true) do
135
156
  MiniPortile.stub(:darwin?, false) do
136
157
  with_stubbed_target do
137
- with_compilers(recipe) do
158
+ with_compilers do
138
159
  Open3.stub(:capture2, cmake_help_mock('Unix')) do
139
160
  MiniPortile.stub(:mingw?, true) do
140
161
  assert_equal(default_x86_compile_flags,
141
- recipe.configure_defaults)
162
+ @recipe.configure_defaults)
142
163
  end
143
164
  end
144
165
  end
@@ -148,15 +169,13 @@ class TestCMakeConfig < TestCMake
148
169
  end
149
170
 
150
171
  def test_configure_defaults_with_msys_makefiles
151
- recipe = init_recipe
152
-
153
172
  MiniPortile.stub(:linux?, true) do
154
173
  MiniPortile.stub(:darwin?, false) do
155
174
  with_stubbed_target do
156
- with_compilers(recipe) do
175
+ with_compilers do
157
176
  Open3.stub(:capture2, cmake_help_mock('MSYS')) do
158
177
  MiniPortile.stub(:mingw?, true) do
159
- assert_equal(['-G', 'MSYS Makefiles'] + default_x86_compile_flags, recipe.configure_defaults)
178
+ assert_equal(['-G', 'MSYS Makefiles'] + default_x86_compile_flags, @recipe.configure_defaults)
160
179
  end
161
180
  end
162
181
  end
@@ -166,15 +185,13 @@ class TestCMakeConfig < TestCMake
166
185
  end
167
186
 
168
187
  def test_configure_defaults_with_nmake_makefiles
169
- recipe = init_recipe
170
-
171
188
  MiniPortile.stub(:linux?, true) do
172
189
  MiniPortile.stub(:darwin?, false) do
173
190
  with_stubbed_target do
174
- with_compilers(recipe) do
191
+ with_compilers do
175
192
  Open3.stub(:capture2, cmake_help_mock('NMake')) do
176
193
  MiniPortile.stub(:mswin?, true) do
177
- assert_equal(['-G', 'NMake Makefiles'] + default_x86_compile_flags, recipe.configure_defaults)
194
+ assert_equal(['-G', 'NMake Makefiles'] + default_x86_compile_flags, @recipe.configure_defaults)
178
195
  end
179
196
  end
180
197
  end
@@ -194,6 +211,17 @@ class TestCMakeConfig < TestCMake
194
211
  end
195
212
  end
196
213
 
214
+ def test_cmake_build_type_configuration
215
+ without_env("CMAKE_BUILD_TYPE") do
216
+ assert_equal("Release", MiniPortileCMake.new("test", "1.0.0").cmake_build_type)
217
+ assert_equal("xyzzy", MiniPortileCMake.new("test", "1.0.0", cmake_build_type: "xyzzy").cmake_build_type)
218
+ end
219
+ with_env("CMAKE_BUILD_TYPE"=>"Debug") do
220
+ assert_equal("Debug", MiniPortileCMake.new("test", "1.0.0").cmake_build_type)
221
+ assert_equal("Debug", MiniPortileCMake.new("test", "1.0.0", cmake_build_type: "xyzzy").cmake_build_type)
222
+ end
223
+ end
224
+
197
225
  private
198
226
 
199
227
  def with_stubbed_target(os: 'linux', cpu: 'x86_64')
@@ -204,21 +232,11 @@ class TestCMakeConfig < TestCMake
204
232
  end
205
233
  end
206
234
 
207
- def with_compilers(recipe, host_prefix: false, c_compiler: 'gcc', cxx_compiler: 'g++')
208
- mock = MiniTest::Mock.new
209
-
210
- if host_prefix
211
- mock.expect(:call, true, ["#{recipe.host}-#{c_compiler}"])
212
- mock.expect(:call, true, ["#{recipe.host}-#{cxx_compiler}"])
213
- else
214
- mock.expect(:call, false, ["#{recipe.host}-#{c_compiler}"])
215
- mock.expect(:call, true, [c_compiler])
216
- mock.expect(:call, false, ["#{recipe.host}-#{cxx_compiler}"])
217
- mock.expect(:call, true, [cxx_compiler])
218
- end
219
-
220
- recipe.stub(:which, mock) do
221
- yield
235
+ def with_compilers(c_compiler: 'gcc', cxx_compiler: 'g++')
236
+ @recipe.stub(:cc_cmd, c_compiler) do
237
+ @recipe.stub(:cxx_cmd, cxx_compiler) do
238
+ yield
239
+ end
222
240
  end
223
241
  end
224
242
 
@@ -227,7 +245,8 @@ class TestCMakeConfig < TestCMake
227
245
  "-DCMAKE_SYSTEM_NAME=Linux",
228
246
  "-DCMAKE_SYSTEM_PROCESSOR=x86_64",
229
247
  "-DCMAKE_C_COMPILER=gcc",
230
- "-DCMAKE_CXX_COMPILER=g++"
248
+ "-DCMAKE_CXX_COMPILER=g++",
249
+ "-DCMAKE_BUILD_TYPE=Release"
231
250
  ]
232
251
  end
233
252
 
data/test/test_cook.rb CHANGED
@@ -13,7 +13,9 @@ class TestCook < TestCase
13
13
  create_tar(@tar_path, @assets_path, "test mini portile-1.0.0")
14
14
  start_webrick(File.dirname(@tar_path))
15
15
 
16
+ @logger = StringIO.new # IO to keep recipe logs in case we need to debug
16
17
  @recipe = MiniPortile.new("test mini portile", "1.0.0").tap do |recipe|
18
+ recipe.logger = @logger
17
19
  recipe.files << "http://localhost:#{HTTP_PORT}/#{ERB::Util.url_encode(File.basename(@tar_path))}"
18
20
  recipe.patch_files << File.join(@assets_path, "patch 1.diff")
19
21
  recipe.configure_options << "--option=\"path with 'space'\""
@@ -22,6 +24,9 @@ class TestCook < TestCase
22
24
  recipe.cook
23
25
  end
24
26
  end
27
+ rescue => e
28
+ puts @logger.string
29
+ raise e
25
30
  end
26
31
 
27
32
  def after_all
@@ -79,17 +84,37 @@ class TestCookConfiguration < TestCase
79
84
  end
80
85
  end
81
86
 
82
- def test_gcc_command_configuration
87
+ def test_cc_command_configuration
83
88
  without_env("CC") do
84
89
  expected_compiler = RbConfig::CONFIG["CC"] || "gcc"
90
+ assert_equal(expected_compiler, MiniPortile.new("test", "1.0.0").cc_cmd)
85
91
  assert_equal(expected_compiler, MiniPortile.new("test", "1.0.0").gcc_cmd)
92
+ assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", cc_command: "xyzzy").cc_cmd)
93
+ assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").cc_cmd)
94
+ assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", cc_command: "xyzzy").gcc_cmd)
86
95
  assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").gcc_cmd)
87
96
  end
88
97
  with_env("CC"=>"asdf") do
98
+ assert_equal("asdf", MiniPortile.new("test", "1.0.0").cc_cmd)
89
99
  assert_equal("asdf", MiniPortile.new("test", "1.0.0").gcc_cmd)
100
+ assert_equal("asdf", MiniPortile.new("test", "1.0.0", cc_command: "xyzzy").cc_cmd)
101
+ assert_equal("asdf", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").cc_cmd)
102
+ assert_equal("asdf", MiniPortile.new("test", "1.0.0", cc_command: "xyzzy").gcc_cmd)
90
103
  assert_equal("asdf", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").gcc_cmd)
91
104
  end
92
105
  end
106
+
107
+ def test_cxx_command_configuration
108
+ without_env("CXX") do
109
+ expected_compiler = RbConfig::CONFIG["CXX"] || "g++"
110
+ assert_equal(expected_compiler, MiniPortile.new("test", "1.0.0").cxx_cmd)
111
+ assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", cxx_command: "xyzzy").cxx_cmd)
112
+ end
113
+ with_env("CXX"=>"asdf") do
114
+ assert_equal("asdf", MiniPortile.new("test", "1.0.0").cxx_cmd)
115
+ assert_equal("asdf", MiniPortile.new("test", "1.0.0", cxx_command: "xyzzy").cxx_cmd)
116
+ end
117
+ end
93
118
  end
94
119
 
95
120
 
@@ -116,7 +141,9 @@ class TestCookWithBrokenGitDir < TestCase
116
141
 
117
142
  create_tar(@tar_path, @assets_path, "test mini portile-1.0.0")
118
143
 
144
+ @logger = StringIO.new # IO to keep recipe logs in case we need to debug
119
145
  @recipe = MiniPortile.new("test mini portile", "1.0.0").tap do |recipe|
146
+ recipe.logger = @logger
120
147
  recipe.files << "file://#{@tar_path}"
121
148
  recipe.patch_files << File.join(@assets_path, "patch 1.diff")
122
149
  recipe.configure_options << "--option=\"path with 'space'\""
@@ -146,7 +173,9 @@ class TestCookAgainstSourceDirectory < TestCase
146
173
  def setup
147
174
  super
148
175
 
176
+ @logger = StringIO.new # IO to keep recipe logs in case we need to debug
149
177
  @recipe ||= MiniPortile.new("test mini portile", "1.0.0").tap do |recipe|
178
+ recipe.logger = @logger
150
179
  recipe.source_directory = File.expand_path("../assets/test mini portile-1.0.0", __FILE__)
151
180
  end
152
181
  end
data/test/test_digest.rb CHANGED
@@ -24,7 +24,8 @@ class TestDigest < TestCase
24
24
  def setup
25
25
  super
26
26
  FileUtils.rm_rf("ports/archives")
27
- @recipe = MiniPortile.new("test-digest", "1.0.0")
27
+ @logger = StringIO.new # IO to keep recipe logs in case we need to debug
28
+ @recipe = MiniPortile.new("test-digest", "1.0.0", logger: @logger)
28
29
  end
29
30
 
30
31
  def download_with_digest(key, klass)
@@ -68,28 +69,28 @@ class TestDigest < TestCase
68
69
  end
69
70
 
70
71
  def public_key
71
- <<-KEY
72
- -----BEGIN PGP PUBLIC KEY BLOCK-----
73
- Version: GnuPG v1
74
-
75
- mI0EVwUhJQEEAMYxFhgaAdM2Ul5r+XfpqAaI7SOxB14eRjhFjhchy4ylgVxetyLq
76
- di3zeANXBIHsLBl7quYTlnmhJr/+GQRkCnXWiUp0tJsBVzGM3puK7c534gakEUH6
77
- AlDtj5p3IeygzSyn8u7KORv+ainXfhwkvTO04mJmxAb2uT8ngKYFdPa1ABEBAAG0
78
- J1Rlc3QgTWluaXBvcnRpbGUgPHRlc3RAbWluaXBvcnRpbGUub3JnPoi4BBMBAgAi
79
- BQJXBSElAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRBl6D5JZMNwswAK
80
- A/90Cdb+PX21weBR2Q6uR06M/alPexuXXyJL8ZcwbQMJ/pBBgcS5/h1+rQkBI/CN
81
- qpXdDlw2Xys2k0sNwdjIw3hmYRzBrddXlCSW3Sifq/hS+kfPZ1snQmIjCgy1Xky5
82
- QGCcPUxBUx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 QGCcPUxBUxzmra88LakkDO+euKK3hcrfeFIi611lTum1NLiNBFcFISUBBADoyY6z
84
+ 2PwH3RWUbqv0VX1s3/JO3v3xMjCRKPlFwsNwLTBtZoWfR6Ao1ajeCuZKfzNKIQ2I
85
+ rn86Rcqyrq4hTj+7BTWjkIPOBthjiL1YqbEBtX7jcYRkYvdQz/IG2F4zVV6X4AAR
86
+ Twx7qaXNt67ArzbHCe5gLNRUK6e6OArkahMv7QARAQABiJ8EGAECAAkFAlcFISUC
87
+ GwwACgkQZeg+SWTDcLNFiwP/TR33ClqWOz0mpjt0xPEoZ0ORmV6fo4sjjzgQoHH/
88
+ KTdsabJbGp8oLQGW/mx3OxgbsAkyZymb5H5cjaF4HtSd4cxI5t1C9ZS/ytN8pqfR
89
+ e29SBje8DAAJn2l57s2OddXLPQ0DUwCcdNEaqgHwSk/Swxc7K+IpfvjLKHKUZZBP
90
+ 4Ko=
91
+ =SVWi
92
+ -----END PGP PUBLIC KEY BLOCK-----
93
+ KEY
93
94
  end
94
95
 
95
96
  def test_with_valid_gpg_signature
@@ -130,7 +131,7 @@ KEY
130
131
  exception = assert_raises(RuntimeError){
131
132
  @recipe.download
132
133
  }
133
- assert_equal("signature mismatch", exception.message)
134
+ assert_includes(exception.message, "signature mismatch")
134
135
  end
135
136
 
136
137
  def test_with_invalid_key
@@ -144,60 +145,58 @@ KEY
144
145
  }
145
146
  }
146
147
  exception = assert_raises(RuntimeError){ @recipe.download }
147
- assert_equal("invalid gpg key provided", exception.message)
148
+ assert_includes(exception.message, "invalid gpg key provided")
148
149
  end
149
150
 
150
151
  def test_with_different_key_than_one_used_to_sign
151
- puts "################"
152
-
153
- key = <<-KEY
154
- -----BEGIN PGP PUBLIC KEY BLOCK-----
155
- Version: GnuPG v1
156
-
157
- mQENBE7SKu8BCADQo6x4ZQfAcPlJMLmL8zBEBUS6GyKMMMDtrTh3Yaq481HB54oR
158
- 0cpKL05Ff9upjrIzLD5TJUCzYYM9GQOhguDUP8+ZU9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+j
190
- lYMWtb+v98aJa2FODeKPmWCXLa7bliXp1SSeBOEfIgEAmjM6QGlDx5sZhr2Ss2xS
191
- PRdZ8DqD7oiRVzmstX1YoxEzC0yXfaefC7SgM0nMnaTvYEOYJ9CH3wARAQABiQEf
192
- BBgBAgAJBQJO0irvAhsMAAoJEFIKmZOhwFL4844H/jo8icCcS6eOWvnen7lg0FcC
193
- o1fIm4wW3tEmkQdchSHECJDq7pgTloN65pwB5tBoT47cyYNZA9eTfJVgRc74q5ce
194
- xKOYrMC3KuAqWbwqXhkVs0nkWxnOIidTHSXvBZfDFA4Idwte94Thrzf8Pn8UESud
195
- TiqrWoCBXk2UyVsl03gJblSJAeJGYPPeo+Yj6m63OWe2+/S2VTgmbPS/RObn0Aeg
196
- 7yuff0n5+ytEt2KL51gOQE2uIxTCawHr12PsllPkbqPk/PagIttfEJqn9b0CrqPC
197
- 3HREePb2aMJ/Ctw/76COwn0mtXeIXLCTvBmznXfaMKllsqbsy2nCJ2P2uJjOntw=
198
- =4JAR
199
- -----END PGP PUBLIC KEY BLOCK-----
200
- KEY
152
+ key = <<~KEY
153
+ -----BEGIN PGP PUBLIC KEY BLOCK-----
154
+ Version: GnuPG v1
155
+
156
+ mQENBE7SKu8BCADQo6x4ZQfAcPlJMLmL8zBEBUS6GyKMMMDtrTh3Yaq481HB54oR
157
+ 0cpKL05Ff9upjrIzLD5TJUCzYYM9GQOhguDUP8+ZU9JpSz3yO2TvH7WBbUZ8FADf
158
+ hblmmUBLNgOWgLo3W+FYhl3mz1GFS2Fvid6Tfn02L8CBAj7jxbjL1Qj/OA/WmLLc
159
+ m6BMTqI7IBlYW2vyIOIHasISGiAwZfp0ucMeXXvTtt14LGa8qXVcFnJTdwbf03AS
160
+ ljhYrQnKnpl3VpDAoQt8C68YCwjaNJW59hKqWB+XeIJ9CW98+EOAxLAFszSyGanp
161
+ rCqPd0numj9TIddjcRkTA/ZbmCWK+xjpVBGXABEBAAG0IU1heGltIERvdW5pbiA8
162
+ b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q5ce
193
+ xKOYrMC3KuAqWbwqXhkVs0nkWxnOIidTHSXvBZfDFA4Idwte94Thrzf8Pn8UESud
194
+ TiqrWoCBXk2UyVsl03gJblSJAeJGYPPeo+Yj6m63OWe2+/S2VTgmbPS/RObn0Aeg
195
+ 7yuff0n5+ytEt2KL51gOQE2uIxTCawHr12PsllPkbqPk/PagIttfEJqn9b0CrqPC
196
+ 3HREePb2aMJ/Ctw/76COwn0mtXeIXLCTvBmznXfaMKllsqbsy2nCJ2P2uJjOntw=
197
+ =4JAR
198
+ -----END PGP PUBLIC KEY BLOCK-----
199
+ KEY
201
200
 
202
201
  data_file = File.expand_path(File.join(File.dirname(__FILE__), 'assets', 'gpg-fixtures', 'data'))
203
202
 
@@ -209,7 +208,6 @@ KEY
209
208
  }
210
209
  }
211
210
  exception = assert_raises(RuntimeError){ @recipe.download }
212
- assert_equal("signature mismatch", exception.message)
211
+ assert_includes(exception.message, "signature mismatch")
213
212
  end
214
213
  end
215
-
@@ -25,12 +25,13 @@ describe "recipe download" do
25
25
  server.close
26
26
  end
27
27
 
28
- request_count.must_be :>, 0
28
+ assert_operator(request_count, :>, 0)
29
29
  end
30
30
 
31
31
  before do
32
32
  @request_count = 0
33
- @recipe = MiniPortile.new("test-download", "1.1.1")
33
+ @logger = StringIO.new
34
+ @recipe = MiniPortile.new("test-download", "1.1.1", logger: @logger)
34
35
  end
35
36
 
36
37
  describe "urls" do
@@ -62,12 +63,12 @@ describe "recipe download" do
62
63
  @recipe.files << "file://#{path}"
63
64
  @recipe.download
64
65
  assert File.exist?(dest)
65
- Digest::MD5.file(dest).hexdigest.must_equal "ee0e9f44e72213015ef976d5ac23931d"
66
+ assert_equal("ee0e9f44e72213015ef976d5ac23931d", Digest::MD5.file(dest).hexdigest)
66
67
  end
67
68
 
68
69
  it "other" do
69
70
  @recipe.files << "foo://foo"
70
- proc { @recipe.download }.must_raise ArgumentError
71
+ assert_raises(ArgumentError) { @recipe.download }
71
72
  end
72
73
  end
73
74
  end