reapack-index 1.0 → 1.1beta1

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_git.rb CHANGED
@@ -142,4 +142,14 @@ class TestGit < MiniTest::Test
142
142
 
143
143
  assert_equal content, @git.last_commit.each_diff.first.new_content
144
144
  end
145
+
146
+ def test_path_encoding
147
+ path = mkpath 'еуые'
148
+ Dir.mkdir path
149
+ path.encode! Encoding::Windows_1251
150
+ path.freeze
151
+
152
+ git = ReaPack::Index::Git.new path # should not throw
153
+ assert_equal @git.path, git.path
154
+ end
145
155
  end
data/test/test_index.rb CHANGED
@@ -9,34 +9,44 @@ class TestIndex < MiniTest::Test
9
9
  end
10
10
 
11
11
  def test_type_of
12
- assert_equal [nil, nil, nil, :script, :script, :extension, :effect, :data],
13
- [
14
- 'src/main.cpp', 'src/noext', 'in_root',
15
- 'Cat/test.lua', 'Cat/test.eel',
16
- 'Cat/test.ext',
17
- 'Cat/test.jsfx',
18
- 'Cat/test.data',
19
- ].map {|fn| ReaPack::Index.type_of fn }
12
+ {
13
+ 'src/main.cpp' => nil,
14
+ 'src/noext' => nil,
15
+ 'in_root' => nil,
16
+ 'Cat/test.lua' => :script,
17
+ 'Cat/test.eel' => :script,
18
+ 'Cat/test.py' => :script,
19
+ 'Cat/test.ext' => :extension,
20
+ 'Cat/test.jsfx' => :effect,
21
+ 'Cat/test.data' => :data,
22
+ 'Cat/test.theme' => :theme,
23
+ }.each {|fn, type|
24
+ actual = ReaPack::Index.type_of fn
25
+ assert_equal type, actual,
26
+ "%s was not of type %s, got %s instead" %
27
+ [fn.inspect, type.inspect, actual.inspect]
28
+ }
20
29
  end
21
30
 
22
31
  def test_resolve_type
23
- expected = [
24
- nil,
25
- :script, :script, :script,
26
- :effect, :effect, :effect,
27
- :extension, :extension,
28
- :data,
29
- ]
30
-
31
- actual = [
32
- 'hello',
33
- :script, 'lua', 'eel',
34
- 'effect', :jsfx, 'jsfx',
35
- 'extension', 'ext',
36
- 'data',
37
- ].map {|fn| ReaPack::Index.resolve_type fn }
38
-
39
- assert_equal expected, actual
32
+ {
33
+ 'hello' => nil,
34
+ :script => :script,
35
+ 'lua' => :script,
36
+ 'eel' => :script,
37
+ 'effect' => :effect,
38
+ :jsfx => :effect,
39
+ 'jsfx' => :effect,
40
+ 'extension' => :extension,
41
+ 'ext' => :extension,
42
+ 'data' => :data,
43
+ 'theme' => :theme,
44
+ }.each {|input, type|
45
+ actual = ReaPack::Index.resolve_type input
46
+ assert_equal type, actual,
47
+ "%s was not of type %s, got %s instead" %
48
+ [input.inspect, type.inspect, actual.inspect]
49
+ }
40
50
  end
41
51
 
42
52
  def test_url_template
@@ -14,11 +14,13 @@ class TestMetadata < MiniTest::Test
14
14
  XML
15
15
 
16
16
  md = ReaPack::Index::Metadata.new before
17
+ assert_equal false, md.modified?
17
18
  assert_empty md.links(:website)
18
19
 
19
20
  link = md.push_link :website, 'http://cfillion.tk'
20
21
  assert_equal true, link.is_new?
21
22
  assert_equal true, link.modified?
23
+ assert_equal true, md.modified?
22
24
 
23
25
  links = md.links :website
24
26
  assert_equal 1, links.size
@@ -56,6 +58,29 @@ class TestMetadata < MiniTest::Test
56
58
  assert_equal after.chomp, before.to_s
57
59
  end
58
60
 
61
+ def test_screenshot_link
62
+ before = make_node '<index/>'
63
+ after = <<-XML
64
+ <index>
65
+ <metadata>
66
+ <link rel="screenshot">http://cfillion.tk</link>
67
+ </metadata>
68
+ </index>
69
+ XML
70
+
71
+ md = ReaPack::Index::Metadata.new before
72
+ assert_empty md.links(:donation)
73
+
74
+ md.push_link :screenshot, 'http://cfillion.tk'
75
+
76
+ links = md.links :screenshot
77
+ assert_equal 1, links.size
78
+ assert_equal links.first.url, links.first.name
79
+ assert_equal 'http://cfillion.tk', links.first.url
80
+
81
+ assert_equal after.chomp, before.to_s
82
+ end
83
+
59
84
  def test_invalid_type
60
85
  md = ReaPack::Index::Metadata.new make_node('<index/>')
61
86
 
@@ -65,6 +90,7 @@ class TestMetadata < MiniTest::Test
65
90
 
66
91
  assert_raises ArgumentError do
67
92
  md.push_link :hello, 'world'
93
+ assert_equal false, md.modified?
68
94
  end
69
95
 
70
96
  assert_raises ArgumentError do
@@ -122,6 +148,17 @@ class TestMetadata < MiniTest::Test
122
148
  assert_equal links[3].name, links[3].url
123
149
  end
124
150
 
151
+ def test_split_link
152
+ assert_equal ['http://perdu.com'],
153
+ ReaPack::Index::Link.split('http://perdu.com')
154
+
155
+ assert_equal ['Hello World', 'http://perdu.com/a=b'],
156
+ ReaPack::Index::Link.split('Hello World=http://perdu.com/a=b')
157
+
158
+ assert_equal ['Hello World', 'http://perdu.com/a=b'],
159
+ ReaPack::Index::Link.split('Hello World http://perdu.com/a=b')
160
+ end
161
+
125
162
  def test_invalid_link
126
163
  after = '<index/>'
127
164
  before = make_node after
@@ -151,9 +188,11 @@ class TestMetadata < MiniTest::Test
151
188
 
152
189
  md = ReaPack::Index::Metadata.new before
153
190
  assert_equal 2, md.links(:website).size
191
+ assert_equal false, md.modified?
154
192
 
155
193
  md.remove_link :website, 'http://cfillion.tk'
156
194
  assert_equal 1, md.links(:website).size
195
+ assert_equal true, md.modified?
157
196
 
158
197
  md.remove_link :website, 'Search'
159
198
  assert_equal 0, md.links(:website).size
@@ -241,7 +280,41 @@ class TestMetadata < MiniTest::Test
241
280
  assert_equal after.chomp, before.to_s
242
281
  end
243
282
 
244
- def test_read_description
283
+ def test_replace_links
284
+ before = make_node <<-XML
285
+ <index>
286
+ <metadata>
287
+ <link rel="website" href="http://cfillion.tk">A</link>
288
+ <link rel="donation">http://google.com</link>
289
+ </metadata>
290
+ </index>
291
+ XML
292
+
293
+ after = <<-XML
294
+ <index>
295
+ <metadata>
296
+ <link rel="donation">http://google.com</link>
297
+ </metadata>
298
+ </index>
299
+ XML
300
+
301
+ md = ReaPack::Index::Metadata.new before
302
+ assert_equal false, md.modified?
303
+
304
+ md.replace_links :website do
305
+ link1 = md.push_link :website, 'A', 'http://cfillion.tk'
306
+ end
307
+
308
+ assert_equal false, md.modified?
309
+
310
+ md.replace_links :website do
311
+ end
312
+
313
+ assert_equal true, md.modified?
314
+ assert_equal after.chomp, before.to_s
315
+ end
316
+
317
+ def test_read_about
245
318
  md = ReaPack::Index::Metadata.new make_node <<-XML
246
319
  <index>
247
320
  <metadata>
@@ -250,20 +323,20 @@ class TestMetadata < MiniTest::Test
250
323
  </index>
251
324
  XML
252
325
 
253
- assert_equal 'Hello World', md.description
326
+ assert_equal 'Hello World', md.about
254
327
  end
255
328
 
256
- def test_read_description_empty
329
+ def test_read_about_empty
257
330
  md = ReaPack::Index::Metadata.new make_node <<-XML
258
331
  <index>
259
332
  <metadata/>
260
333
  </index>
261
334
  XML
262
335
 
263
- assert_empty md.description
336
+ assert_empty md.about
264
337
  end
265
338
 
266
- def test_write_description
339
+ def test_write_about
267
340
  rtf = <<-RTF
268
341
  {\\rtf1\\ansi\\deff0{\\fonttbl{\\f0 \\fswiss Helvetica;}{\\f1 Courier;}}
269
342
  {\\colortbl;\\red255\\green0\\blue0;\\red0\\green0\\blue255;}
@@ -283,15 +356,17 @@ class TestMetadata < MiniTest::Test
283
356
  XML
284
357
 
285
358
  md = ReaPack::Index::Metadata.new before
286
- assert_empty md.description
359
+ assert_empty md.about
360
+ assert_equal false, md.modified?
287
361
 
288
- md.description = 'Hello World'
289
- assert_equal rtf, md.description
362
+ md.about = 'Hello World'
363
+ assert_equal true, md.modified?
364
+ assert_equal rtf, md.about
290
365
 
291
366
  assert_equal after.chomp, before.to_s
292
367
  end
293
368
 
294
- def test_write_description_rtf
369
+ def test_write_about_rtf
295
370
  rtf = <<-RTF
296
371
  {\\rtf1\\ansi\\deff0{\\fonttbl{\\f0 \\fswiss Helvetica;}{\\f1 Courier;}}
297
372
  {\\colortbl;\\red255\\green0\\blue0;\\red0\\green0\\blue255;}
@@ -311,15 +386,15 @@ class TestMetadata < MiniTest::Test
311
386
  XML
312
387
 
313
388
  md = ReaPack::Index::Metadata.new before
314
- assert_empty md.description
389
+ assert_empty md.about
315
390
 
316
- md.description = rtf
317
- assert_equal rtf, md.description
391
+ md.about = rtf
392
+ assert_equal rtf, md.about
318
393
 
319
394
  assert_equal after.chomp, before.to_s
320
395
  end
321
396
 
322
- def test_replace_description
397
+ def test_replace_about
323
398
  before = make_node <<-XML
324
399
  <index>
325
400
  <metadata>
@@ -349,12 +424,12 @@ class TestMetadata < MiniTest::Test
349
424
  XML
350
425
 
351
426
  md = ReaPack::Index::Metadata.new before
352
- md.description = 'Chunky Bacon'
427
+ md.about = 'Chunky Bacon'
353
428
 
354
429
  assert_equal after.chomp, before.to_s
355
430
  end
356
431
 
357
- def test_remove_description
432
+ def test_remove_about
358
433
  rtf = <<-RTF
359
434
  {\\rtf1\\ansi\\deff0{\\fonttbl{\\f0 \\fswiss Helvetica;}{\\f1 Courier;}}
360
435
  {\\colortbl;\\red255\\green0\\blue0;\\red0\\green0\\blue255;}
@@ -375,14 +450,35 @@ class TestMetadata < MiniTest::Test
375
450
  after = '<index/>'
376
451
 
377
452
  md = ReaPack::Index::Metadata.new before
378
- refute_empty md.description
453
+ refute_empty md.about
379
454
 
380
- md.description = String.new
381
- assert_empty md.description
455
+ md.about = String.new
456
+ assert_empty md.about
457
+ assert_equal true, md.modified?
382
458
 
383
459
  assert_equal after, before.to_s
384
460
  end
385
461
 
462
+ def test_set_same_about
463
+ before = make_node <<-XML
464
+ <index>
465
+ <metadata>
466
+ <description><![CDATA[{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0 \\fswiss Helvetica;}{\\f1 Courier;}}
467
+ {\\colortbl;\\red255\\green0\\blue0;\\red0\\green0\\blue255;}
468
+ \\widowctrl\\hyphauto
469
+
470
+ {\\pard \\ql \\f0 \\sa180 \\li0 \\fi0 Hello World\\par}
471
+ }
472
+ ]]></description>
473
+ </metadata>
474
+ </index>
475
+ XML
476
+
477
+ md = ReaPack::Index::Metadata.new before
478
+ md.about = 'Hello World'
479
+ assert_equal false, md.modified?
480
+ end
481
+
386
482
  def test_pandoc_not_found
387
483
  old_path = ENV['PATH']
388
484
  ENV['PATH'] = String.new
@@ -390,7 +486,7 @@ class TestMetadata < MiniTest::Test
390
486
  md = ReaPack::Index::Metadata.new make_node('<index/>')
391
487
 
392
488
  error = assert_raises ReaPack::Index::Error do
393
- md.description = 'test'
489
+ md.about = 'test'
394
490
  end
395
491
 
396
492
  assert_match /pandoc executable cannot be found in your PATH/i, error.message
data/test/test_package.rb CHANGED
@@ -4,8 +4,8 @@ class TestPackage < MiniTest::Test
4
4
  include XMLHelper
5
5
 
6
6
  def test_change_type
7
- before = make_node '<reapack name="1.0"/>'
8
- after = '<reapack name="1.0" type="script"/>'
7
+ before = make_node '<reapack name="pkg"/>'
8
+ after = '<reapack name="pkg" type="script"/>'
9
9
 
10
10
  pkg = ReaPack::Index::Package.new before
11
11
  assert_nil pkg.type
@@ -18,7 +18,7 @@ class TestPackage < MiniTest::Test
18
18
  end
19
19
 
20
20
  def test_set_same_type
21
- before = make_node '<reapack name="1.0" type="script"/>'
21
+ before = make_node '<reapack name="pkg" type="script"/>'
22
22
 
23
23
  pkg = ReaPack::Index::Package.new before
24
24
 
@@ -28,9 +28,59 @@ class TestPackage < MiniTest::Test
28
28
  refute pkg.modified?, 'package is modified'
29
29
  end
30
30
 
31
+ def test_set_description
32
+ before = make_node '<reapack name="pkg"/>'
33
+ after = '<reapack name="pkg" desc="hello world"/>'
34
+
35
+ pkg = ReaPack::Index::Package.new before
36
+ assert_empty pkg.description
37
+
38
+ pkg.description = 'hello world'
39
+ assert pkg.modified?, 'package is not modified'
40
+ assert_equal 'hello world', pkg.description
41
+
42
+ assert_equal after, before.to_s
43
+ end
44
+
45
+ def test_set_same_description
46
+ before = make_node '<reapack name="pkg" desc="hello world"/>'
47
+
48
+ pkg = ReaPack::Index::Package.new before
49
+
50
+ assert_equal 'hello world', pkg.description
51
+ pkg.description = pkg.description
52
+
53
+ refute pkg.modified?, 'package is modified'
54
+ end
55
+
56
+ def test_remove_description
57
+ before = make_node '<reapack name="pkg" desc="hello world"/>'
58
+ after = '<reapack name="pkg"/>'
59
+
60
+ pkg = ReaPack::Index::Package.new before
61
+ assert_equal 'hello world', pkg.description
62
+
63
+ pkg.description = nil
64
+ assert pkg.modified?, 'package is not modified'
65
+
66
+ assert_equal after, before.to_s
67
+ end
68
+
69
+ def test_set_metadata
70
+ before = make_node '<reapack name="pkg"/>'
71
+
72
+ pkg = ReaPack::Index::Package.new before
73
+ refute pkg.modified?, 'package is modified'
74
+
75
+ pkg.metadata.about = 'hello world'
76
+ assert pkg.modified?, 'package is not modified'
77
+
78
+ assert_match /<metadata>.+<description>/m, before.to_s
79
+ end
80
+
31
81
  def test_versions
32
82
  before = make_node <<-XML
33
- <reapack name="1.0" type="script">
83
+ <reapack name="pkg" type="script">
34
84
  <version name="1.0" />
35
85
  </reapack>
36
86
  XML
@@ -47,7 +97,7 @@ class TestPackage < MiniTest::Test
47
97
 
48
98
  def test_get_or_create_version
49
99
  before = make_node <<-XML
50
- <reapack name="1.0" type="script">
100
+ <reapack name="pkg" type="script">
51
101
  <version name="1.0" />
52
102
  </reapack>
53
103
  XML
data/test/test_scanner.rb CHANGED
@@ -1,194 +1,167 @@
1
1
  require File.expand_path '../helper', __FILE__
2
2
 
3
3
  class TestScanner < MiniTest::Test
4
- class TestMakeUrl < MiniTest::Test
5
- def setup
6
- @cat = MiniTest::Mock.new
4
+ include XMLHelper
7
5
 
8
- @pkg = MiniTest::Mock.new
9
- @pkg.expect :path, 'Hello/World.lua'
10
- @pkg.expect :path, 'Hello/World.lua'
6
+ def setup
7
+ @mock = MiniTest::Mock.new
11
8
 
12
- @ver = MiniTest::Mock.new
13
- @ver.expect :name, '1.0'
9
+ @mh = MetaHeader.new String.new
10
+ @mh[:version] = '1.0'
14
11
 
15
- @mh = MiniTest::Mock.new
16
- @mh.expect :[], true, [:metapackage]
12
+ @doc = Nokogiri::XML <<-XML
13
+ <category name="Hello">
14
+ <reapack type="script" name="World.lua"/>
15
+ </category>
16
+ XML
17
17
 
18
- @cdetector = MiniTest::Mock.new
19
- @cdetector.expect :[], nil, ['Hello/World.lua']
18
+ @pkg = ReaPack::Index::Package.new @doc.css('reapack').first
20
19
 
21
- @index = MiniTest::Mock.new
22
- @index.expect :cdetector, @cdetector
20
+ @index = MiniTest::Mock.new
21
+ @index.expect :cdetector, ReaPack::Index::ConflictDetector.new
22
+ @index.expect :url_template, 'https://google.com/$path'
23
+ @index.expect :files, ['Hello/World.lua']
24
+ @index.expect :commit, 'master'
25
+ 2.times { @index.expect :time, Time.at(42) }
23
26
 
24
- @scanner = ReaPack::Index::Scanner.new @cat, @pkg, @mh, @index
25
- @scanner.instance_variable_set :@ver, @ver
26
- end
27
-
28
- def teardown
29
- [@cat, @pkg, @ver, @mh, @index, @cdetector].each {|mock| mock.verify }
30
- end
31
-
32
- def test_path
33
- @index.expect :files, ['Category/script.lua']
34
- @index.expect :url_template, '$path'
35
- @index.expect :commit, 'C0FF33'
27
+ @scanner = ReaPack::Index::Scanner.new nil, @pkg, @mh, @index
28
+ end
36
29
 
37
- assert_equal 'Category/script.lua', @scanner.make_url('Category/script.lua')
38
- end
30
+ def teardown
31
+ @mock.verify
32
+ end
39
33
 
40
- def test_commit
41
- @index.expect :files, ['Hello/World.lua']
42
- @index.expect :url_template, '$commit'
43
- @index.expect :commit, 'C0FF33'
34
+ def test_author
35
+ @mh[:author] = 'cfillion'
36
+ @mock.expect :author=, nil, ['cfillion']
44
37
 
45
- assert_equal 'C0FF33', @scanner.make_url('Hello/World.lua')
38
+ @pkg.version('1.0').stub :author=, -> (arg) { @mock.author= arg } do
39
+ @scanner.run
46
40
  end
41
+ end
47
42
 
48
- def test_defaut_branch
49
- @index.expect :commit, nil
43
+ def test_version_time
44
+ @mock.expect :time=, nil, [Time.at(42)]
50
45
 
51
- assert_match 'master', @scanner.make_url('Category/script.lua', '$commit')
46
+ @pkg.version('1.0').stub :time=, -> (arg) { @mock.time= arg } do
47
+ @scanner.run
52
48
  end
49
+ end
53
50
 
54
- def test_version
55
- @index.expect :files, ['Category/script.lua']
56
- @index.expect :url_template, '$version'
57
- @index.expect :commit, 'C0FF33'
51
+ def test_edit_version_amend_off
52
+ ver = make_node '<version name="1.0"/>'
53
+ ver.parent = @pkg.node
58
54
 
59
- assert_equal '1.0', @scanner.make_url('Category/script.lua')
55
+ @index.expect :amend, false
56
+ @pkg.version('1.0').stub :replace_sources, -> (*) { fail 'version was altered' } do
57
+ @scanner.run
60
58
  end
59
+ end
61
60
 
62
- def test_package
63
- @index.expect :files, ['Category/script.lua']
64
- @index.expect :url_template, '$package'
65
- @index.expect :commit, 'C0FF33'
61
+ def test_edit_version_amend_on
62
+ ver = make_node '<version name="1.0"/>'
63
+ ver.parent = @pkg.node
66
64
 
67
- assert_equal 'Hello/World.lua', @scanner.make_url('Category/script.lua')
65
+ @index.expect :amend, true
66
+ @mock.expect :replace_sources, nil
67
+ @pkg.version('1.0').stub :replace_sources, -> (*) { @mock.replace_sources } do
68
+ @scanner.run
68
69
  end
70
+ end
69
71
 
70
- def test_without_template
71
- @index.expect :commit, nil
72
- @scanner.make_url 'script.lua', 'ok if explicit template'
73
-
74
- @index.expect :url_template, nil
75
- error = assert_raises ReaPack::Index::Error do
76
- @scanner.make_url 'script.lua'
77
- end
72
+ def test_metapackage_on
73
+ @mh[:metapackage] = true
78
74
 
79
- assert_match /url template/i, error.message
75
+ error = assert_raises ReaPack::Index::Error do
76
+ @scanner.run
80
77
  end
81
78
 
82
- def test_unlisted
83
- @index.expect :commit, nil
84
- @index.expect :files, []
85
- @index.expect :url_template, 'http://implicit/url/template'
79
+ assert_equal 'no files provided', error.message
80
+ end
86
81
 
87
- @scanner.make_url 'unlisted.lua', 'ok with explicit url template'
82
+ def test_metapackage_off
83
+ @mh[:metapackage] = false
84
+ @pkg.type = ReaPack::Index::Scanner::META_TYPES.first
85
+ @scanner.run
86
+ end
88
87
 
89
- error = assert_raises ReaPack::Index::Error do
90
- @scanner.make_url 'unlisted.lua'
91
- end
88
+ def test_description
89
+ @mh[:description] = 'From the New World'
90
+ @mock.expect :description=, nil, ['From the New World']
92
91
 
93
- assert_equal "file not found 'unlisted.lua'", error.message
92
+ @pkg.stub :description=, -> (arg) { @mock.description= arg } do
93
+ @scanner.run
94
94
  end
95
+ end
95
96
 
96
- def test_repeat
97
- @index.expect :files, ['Category/script.lua']
98
- @index.expect :url_template, '$path $path'
99
- @index.expect :commit, 'C0FF33'
97
+ def test_description_alias_rescript_name
98
+ @mh[:reascript_name] = 'Right'
99
+ @mh[:description] = 'Wrong'
100
+ @mock.expect :description=, nil, ['Right']
100
101
 
101
- assert_equal 'Category/script.lua Category/script.lua',
102
- @scanner.make_url('Category/script.lua')
102
+ @pkg.stub :description=, -> (arg) { @mock.description= arg } do
103
+ @scanner.run
103
104
  end
104
105
  end
105
106
 
106
- class TestValidation < MiniTest::Test
107
- def setup
108
- @pkg = MiniTest::Mock.new
109
- @pkg.expect :type, :script
110
- @pkg.expect :path, 'cat/test'
107
+ def test_description_alias_desc
108
+ @mh[:desc] = 'Right'
109
+ @mh[:description] = 'Wrong'
110
+ @mock.expect :description=, nil, ['Right']
111
111
 
112
- @mh = MetaHeader.new String.new
113
- @mh[:version] = '1.0'
114
-
115
- @index = MiniTest::Mock.new
116
- @index.expect :cdetector, ReaPack::Index::ConflictDetector.new
117
-
118
- @scanner = ReaPack::Index::Scanner.new nil, @pkg, @mh, @index
112
+ @pkg.stub :description=, -> (arg) { @mock.description= arg } do
113
+ @scanner.run
119
114
  end
115
+ end
120
116
 
121
- def test_validation
122
- mh_mock = MiniTest::Mock.new
123
- mh_mock.expect :validate, ['first', 'second'], [Hash]
124
-
125
- @scanner.instance_variable_set :@mh, mh_mock
126
-
127
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
117
+ def test_about
118
+ @mh[:about] = '# Hello World'
119
+ @mock.expect :about=, nil, ['# Hello World']
128
120
 
129
- assert_equal "first\nsecond", error.message
130
- mh_mock.verify
121
+ @pkg.metadata.stub :about=, -> (arg) { @mock.about= arg } do
122
+ @scanner.run
131
123
  end
124
+ end
132
125
 
133
- def test_version
134
- @mh.delete :version
135
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
136
- assert_equal "missing tag 'version'", error.message
137
-
138
- @mh[:version] = 'no.numbers'
139
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
140
- assert_equal "invalid value for tag 'version'", error.message
141
-
142
- @mh[:version] = 'v1.0'
143
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
144
- assert_equal "invalid value for tag 'version'", error.message
126
+ def test_website_links
127
+ @mh[:website] = [
128
+ 'http://cfillion.tk',
129
+ 'Label http://cfillion.tk',
130
+ ].join "\n"
145
131
 
146
- @mh[:version] = true
147
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
148
- assert_equal "missing value for tag 'version'", error.message
132
+ @mock.expect :push_link, nil, [:website, 'http://cfillion.tk']
133
+ @mock.expect :push_link, nil, [:website, 'Label', 'http://cfillion.tk']
149
134
 
150
- @mh[:version] = "hello\nworld"
151
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
152
- assert_equal "tag 'version' must be singleline", error.message
135
+ @pkg.metadata.stub :push_link, -> (*arg) { @mock.push_link *arg } do
136
+ @scanner.run
153
137
  end
138
+ end
154
139
 
155
- def test_author
156
- @mh[:author] = true
157
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
158
- assert_equal "missing value for tag 'author'", error.message
140
+ def test_screenshot_links
141
+ @mh[:screenshot] = [
142
+ 'http://i.imgur.com/1.png',
143
+ 'Label http://i.imgur.com/2.png',
144
+ ].join "\n"
159
145
 
160
- @mh[:author] = "hello\nworld"
161
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
162
- assert_equal "tag 'author' must be singleline", error.message
163
- end
146
+ @mock.expect :push_link, nil, [:screenshot, 'http://i.imgur.com/1.png']
147
+ @mock.expect :push_link, nil, [:screenshot, 'Label', 'http://i.imgur.com/2.png']
164
148
 
165
- def test_changelog
166
- @mh[:changelog] = true
167
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
168
- assert_equal "missing value for tag 'changelog'", error.message
149
+ @pkg.metadata.stub :push_link, -> (*arg) { @mock.push_link *arg } do
150
+ @scanner.run
169
151
  end
152
+ end
170
153
 
171
- def test_provides
172
- @mh[:provides] = true
173
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
174
- assert_equal "missing value for tag 'provides'", error.message
175
-
176
- @mh[:provides] = '[hello] world'
177
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
178
- assert_equal "invalid value for tag 'provides': unknown option 'hello'",
179
- error.message
180
- end
154
+ def test_donation_links
155
+ @mh[:donation] = [
156
+ 'https://www.paypal.me/cfillion',
157
+ 'Label https://www.paypal.me/cfillion',
158
+ ].join "\n"
181
159
 
182
- def test_index
183
- @mh[:noindex] = 'value'
184
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
185
- assert_equal "tag 'noindex' cannot have a value", error.message
186
- end
160
+ @mock.expect :push_link, nil, [:donation, 'https://www.paypal.me/cfillion']
161
+ @mock.expect :push_link, nil, [:donation, 'Label', 'https://www.paypal.me/cfillion']
187
162
 
188
- def test_metapackage
189
- @mh[:metapackage] = 'value'
190
- error = assert_raises(ReaPack::Index::Error) { @scanner.run }
191
- assert_equal "tag 'metapackage' cannot have a value", error.message
163
+ @pkg.metadata.stub :push_link, -> (*arg) { @mock.push_link *arg } do
164
+ @scanner.run
192
165
  end
193
166
  end
194
167
  end