signore 0.6.0 → 1.0.0

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.
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'pathname'
4
2
  require 'stringio'
5
3
  require 'tempfile'
@@ -25,25 +23,26 @@ module Signore
25
23
  let(:path) { Pathname.new('test/fixtures/signatures.yml') }
26
24
 
27
25
  it 'prints a signature tagged with the provided tags' do
28
- args = %w(prego tech programming)
26
+ args = %w[prego tech programming]
29
27
  out = capture_io { CLI.new(args, repo: repo).run }.first
30
- sig = "// sometimes I believe compiler ignores all my comments\n"
28
+ sig = "// sometimes I believe compiler\n// ignores all my comments\n"
31
29
  _(out).must_equal sig
32
30
  end
33
31
 
34
32
  it 'prints a signature based on allowed and forbidden tags' do
35
- args = %w(prego ~programming tech ~security)
33
+ args = %w[prego ~programming tech ~security]
36
34
  out = capture_io { CLI.new(args, repo: repo).run }.first
37
- _(out).must_equal <<-end.dedent
38
- You do have to be mad to work here, but it doesn’t help.
39
- [Gary Barnes, asr]
35
+ _(out).must_equal <<~end
36
+ You do have to be mad to work
37
+ here, but it doesn’t help.
38
+ [Gary Barnes, asr]
40
39
  end
41
40
  end
42
41
 
43
42
  it 'tells the user if no signatures are found' do
44
43
  path = Pathname.new('test/fixtures/nosignatures.yml')
45
44
  repo = Repo.new(path: path)
46
- args = %w(prego)
45
+ args = %w[prego]
47
46
  out = capture_io { CLI.new(args, repo: repo).run }.first
48
47
  _(out).must_include 'No signatures found.'
49
48
  end
@@ -51,24 +50,25 @@ module Signore
51
50
  it 'tells the user if no signatures with selected tag are found' do
52
51
  path = Pathname.new('test/fixtures/signatures.yml')
53
52
  repo = Repo.new(path: path)
54
- args = %w(prego esse ~percipi)
53
+ args = %w[prego esse ~percipi]
55
54
  out = capture_io { CLI.new(args, repo: repo).run }.first
56
55
  _(out).must_include 'Sadly no signatures are tagged esse ~percipi.'
57
56
  end
58
57
  end
59
58
 
60
59
  describe 'pronto' do
61
- let(:repo) { Repo.new(path: Pathname.new(Tempfile.new('').path)) }
60
+ let(:repo) { Repo.new(path: Pathname.new(Tempfile.new.path)) }
62
61
 
63
62
  it 'asks about signature parts and saves resulting signature' do
64
- input = StringIO.new <<-end.dedent
63
+ input = StringIO.new <<~end
65
64
  The Wikipedia page on ADHD is like 20 pages long. That’s just cruel.
66
65
 
67
66
  Mark Pilgrim\n\n\n
68
67
  end
69
- args = %w(pronto Wikipedia ADHD)
68
+ args = %w[pronto Wikipedia ADHD]
70
69
  out = capture_io { CLI.new(args, repo: repo).run input: input }.first
71
- _(out).must_equal <<-end.dedent
70
+ _(out).must_equal <<~end
71
+
72
72
  text?
73
73
 
74
74
  author?
@@ -76,26 +76,29 @@ module Signore
76
76
  subject?
77
77
 
78
78
  source?
79
- The Wikipedia page on ADHD is like 20 pages long. That’s just cruel.
80
- [Mark Pilgrim]
79
+ The Wikipedia page on ADHD is like
80
+ 20 pages long. That’s just cruel.
81
+ [Mark Pilgrim]
81
82
  end
82
- args = %w(prego Wikipedia ADHD)
83
+ args = %w[prego Wikipedia ADHD]
83
84
  out = capture_io { CLI.new(args, repo: repo).run }.first
84
- _(out).must_equal <<-end.dedent
85
- The Wikipedia page on ADHD is like 20 pages long. That’s just cruel.
86
- [Mark Pilgrim]
85
+ _(out).must_equal <<~end
86
+ The Wikipedia page on ADHD is like
87
+ 20 pages long. That’s just cruel.
88
+ [Mark Pilgrim]
87
89
  end
88
90
  end
89
91
 
90
92
  it 'handles multi-line signatures' do
91
- input = StringIO.new <<-end.dedent
93
+ input = StringIO.new <<~end
92
94
  ‘You’ve got an interesting accent. Subtle. I can’t place it.’
93
95
  ‘It’s text-to-speech… I was raised by smartphones.’
94
96
 
95
97
  Patrick Ewing\n\n\n
96
98
  end
97
99
  io = capture_io { CLI.new(['pronto'], repo: repo).run input: input }
98
- _(io.first).must_equal <<-end.dedent
100
+ _(io.first).must_equal <<~end
101
+
99
102
  text?
100
103
 
101
104
  author?
@@ -103,9 +106,11 @@ module Signore
103
106
  subject?
104
107
 
105
108
  source?
106
- ‘You’ve got an interesting accent. Subtle. I can’t place it.’
107
- ‘It’s text-to-speech… I was raised by smartphones.’
108
- [Patrick Ewing]
109
+ ‘You’ve got an interesting accent.
110
+ Subtle. I can’t place it.’
111
+ ‘It’s text-to-speech…
112
+ I was raised by smartphones.’
113
+ [Patrick Ewing]
109
114
  end
110
115
  end
111
116
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'fileutils'
4
2
  require 'pathname'
5
3
  require 'tempfile'
@@ -11,7 +9,27 @@ require_relative '../../lib/signore/tags'
11
9
 
12
10
  module Signore
13
11
  describe Repo do
14
- let(:path) { Pathname.new(Tempfile.new('').path) }
12
+ let(:path) { Pathname.new(Tempfile.new.path) }
13
+
14
+ describe '.default_path' do
15
+ it 'honours XDG_DATA_HOME if it’s set' do
16
+ old_xdg = ENV.delete('XDG_DATA_HOME')
17
+ ENV['XDG_DATA_HOME'] = Dir.mktmpdir
18
+ path = "#{ENV.fetch('XDG_DATA_HOME')}/signore/signatures.yml"
19
+ _(Repo.default_path).must_equal Pathname.new(path)
20
+ ensure
21
+ FileUtils.rmtree ENV.fetch('XDG_DATA_HOME')
22
+ old_xdg ? ENV['XDG_DATA_HOME'] = old_xdg : ENV.delete('XDG_DATA_HOME')
23
+ end
24
+
25
+ it 'defaults XDG_DATA_HOME to ~/.local/share if it’s not set' do
26
+ old_xdg = ENV.delete('XDG_DATA_HOME')
27
+ path = File.expand_path('~/.local/share/signore/signatures.yml')
28
+ _(Repo.default_path).must_equal Pathname.new(path)
29
+ ensure
30
+ ENV['XDG_DATA_HOME'] = old_xdg if old_xdg
31
+ end
32
+ end
15
33
 
16
34
  describe '.new' do
17
35
  it 'rewrites legacy file to hashes on first access' do
@@ -35,6 +53,11 @@ module Signore
35
53
  Repo.new(path: path) << sig
36
54
  _(path.read).wont_include 'Signore::Signature'
37
55
  end
56
+
57
+ it 'handles edge cases' do
58
+ sig = Signature.new(author: '000___000')
59
+ Repo.new(path: path) << sig
60
+ end
38
61
  end
39
62
 
40
63
  describe '#empty?' do
@@ -48,43 +71,6 @@ module Signore
48
71
  end
49
72
  end
50
73
 
51
- describe '#find' do
52
- let(:path) { Pathname.new('test/fixtures/signatures.yml') }
53
- let(:repo) { Repo.new(path: path, sig_finder: sig_finder) }
54
- let(:sig_finder) { fake(SigFinder) }
55
- let(:sigs) { repo.sigs }
56
- let(:store) { YAML::Store.new(path) }
57
-
58
- it 'returns a random signature by default' do
59
- stub(sig_finder).find(sigs, tags: Tags.new) { sigs.last }
60
- _(repo.find).must_equal sigs.last
61
- end
62
-
63
- it 'returns a random signature based on required and forbidden tags' do
64
- tags = Tags.new(forbidden: %w(programming security), required: %w(tech))
65
- stub(sig_finder).find(sigs, tags: tags) { sigs.first }
66
- _(repo.find(tags: tags)).must_equal sigs.first
67
- end
68
-
69
- it 'doesn’t blow up if the path is missing' do
70
- begin
71
- tempdir = Dir.mktmpdir
72
- path = Pathname.new("#{tempdir}/some_intermediate_dir/sigs.yml")
73
- _(Repo.new(path: path).find(tags: Tags.new)).must_equal Signature.new
74
- ensure
75
- FileUtils.rmtree tempdir
76
- end
77
- end
78
-
79
- it 'keeps working with legacy YAML files' do
80
- path = Pathname.new(Tempfile.new('').path)
81
- FileUtils.cp Pathname.new('test/fixtures/signatures.legacy.yml'), path
82
- repo = Repo.new(path: path, sig_finder: sig_finder)
83
- stub(sig_finder).find(sigs, tags: Tags.new) { sigs.last }
84
- _(repo.find).must_equal sigs.last
85
- end
86
- end
87
-
88
74
  describe '#sigs' do
89
75
  it 'returns all the Signatures from the Repo' do
90
76
  path = Pathname.new('test/fixtures/signatures.yml')
@@ -93,6 +79,23 @@ module Signore
93
79
  _(sigs.first.author).must_equal 'Gary Barnes'
94
80
  _(sigs.last.subject).must_equal 'Star Wars ending explained'
95
81
  end
82
+
83
+ it 'keeps working with legacy YAML files' do
84
+ legacy_path = Pathname.new('test/fixtures/signatures.legacy.yml')
85
+ temp_path = Pathname.new(Tempfile.new.path)
86
+ FileUtils.cp legacy_path, temp_path
87
+ legacy_repo = Repo.new(path: temp_path)
88
+ new_repo = Repo.new(path: Pathname.new('test/fixtures/signatures.yml'))
89
+ _(legacy_repo.sigs).must_equal new_repo.sigs
90
+ end
91
+
92
+ it 'doesn’t blow up if the path is missing' do
93
+ tempdir = Dir.mktmpdir
94
+ path = Pathname.new("#{tempdir}/some_intermediate_dir/sigs.yml")
95
+ _(Repo.new(path: path).sigs).must_equal []
96
+ ensure
97
+ FileUtils.rmtree tempdir
98
+ end
96
99
  end
97
100
  end
98
101
  end
@@ -1,5 +1,4 @@
1
- # frozen_string_literal: true
2
-
1
+ require 'fileutils'
3
2
  require 'pathname'
4
3
  require 'tmpdir'
5
4
  require_relative '../test_helper'
@@ -14,34 +13,10 @@ module Signore
14
13
  end
15
14
  end
16
15
 
17
- describe '#repo_path' do
18
- it 'honours XDG_DATA_HOME if it’s set' do
19
- begin
20
- old_xdg = ENV.delete('XDG_DATA_HOME')
21
- ENV['XDG_DATA_HOME'] = Dir.mktmpdir
22
- path = "#{ENV['XDG_DATA_HOME']}/signore/signatures.yml"
23
- _(Settings.new.repo_path).must_equal Pathname.new(path)
24
- ensure
25
- FileUtils.rmtree ENV['XDG_DATA_HOME']
26
- old_xdg ? ENV['XDG_DATA_HOME'] = old_xdg : ENV.delete('XDG_DATA_HOME')
27
- end
28
- end
29
-
30
- it 'defaults XDG_DATA_HOME to ~/.local/share if it’s not set' do
31
- begin
32
- old_xdg = ENV.delete('XDG_DATA_HOME')
33
- path = File.expand_path('~/.local/share/signore/signatures.yml')
34
- _(Settings.new.repo_path).must_equal Pathname.new(path)
35
- ensure
36
- ENV['XDG_DATA_HOME'] = old_xdg if old_xdg
37
- end
38
- end
39
- end
40
-
41
16
  describe '#tags' do
42
17
  it 'returns the forbidden and required tags' do
43
- tags = Tags.new(forbidden: %w(tech), required: %w(en))
44
- _(Settings.new(%w(prego ~tech en)).tags).must_equal tags
18
+ tags = Tags.new(forbidden: %w[tech], required: %w[en])
19
+ _(Settings.new(%w[prego ~tech en]).tags).must_equal tags
45
20
  end
46
21
 
47
22
  it 'doesn’t blow up on empty args' do
@@ -1,48 +1,43 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'yaml/store'
4
2
  require_relative '../test_helper'
5
3
  require_relative '../../lib/signore/sig_finder'
4
+ require_relative '../../lib/signore/signature'
6
5
  require_relative '../../lib/signore/tags'
7
6
 
8
7
  module Signore
9
8
  describe SigFinder do
10
- verify_contract SigFinder
11
-
12
9
  let(:sigs) do
13
10
  Repo.new(path: Pathname.new('test/fixtures/signatures.yml')).sigs
14
11
  end
15
12
 
16
- let(:sig_finder) { SigFinder.new }
17
-
18
13
  describe '#find' do
19
14
  it 'returns a random Signature by default' do
20
- _(SigFinder.new(random: Random.new(0)).find(sigs).text)
15
+ _(SigFinder.find(sigs, random: Random.new(0)).text)
21
16
  .must_include 'Amateur fighter pilot ignores orders'
22
- _(SigFinder.new(random: Random.new(1)).find(sigs).text)
17
+ _(SigFinder.find(sigs, random: Random.new(1)).text)
23
18
  .must_equal '// sometimes I believe compiler ignores all my comments'
24
19
  end
25
20
 
26
21
  it 'returns a random signature if the tags are empty' do
27
- _(SigFinder.new(random: Random.new(0)).find(sigs, tags: Tags.new).text)
22
+ _(SigFinder.find(sigs, random: Random.new(0), tags: Tags.new).text)
28
23
  .must_include 'Amateur fighter pilot ignores orders'
29
24
  end
30
25
 
31
26
  it 'returns a random signature based on provided tags' do
32
- _(sig_finder.find(sigs, tags: Tags.new(required: %w(programming))).text)
27
+ _(SigFinder.find(sigs, tags: Tags.new(required: %w[programming])).text)
33
28
  .must_equal '// sometimes I believe compiler ignores all my comments'
34
- _(sig_finder.find(sigs, tags: Tags.new(required: %w(work))).text)
29
+ _(SigFinder.find(sigs, tags: Tags.new(required: %w[work])).text)
35
30
  .must_equal 'You do have to be mad to work here, but it doesn’t help.'
36
31
  end
37
32
 
38
33
  it 'returns a random signature based on required and forbidden tags' do
39
- tags = Tags.new(forbidden: %w(programming security), required: %w(tech))
40
- _(sig_finder.find(sigs, tags: tags).text)
34
+ tags = Tags.new(forbidden: %w[programming security], required: %w[tech])
35
+ _(SigFinder.find(sigs, tags: tags).text)
41
36
  .must_equal 'You do have to be mad to work here, but it doesn’t help.'
42
37
  end
43
38
 
44
39
  it 'returns a null object if there are no results' do
45
- _(sig_finder.find([])).must_equal Signature.new
40
+ _(SigFinder.find([])).must_equal Signature.new
46
41
  end
47
42
  end
48
43
  end
@@ -1,15 +1,14 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'stringio'
4
2
  require_relative '../test_helper'
5
3
  require_relative '../../lib/signore/sig_from_stream'
6
4
 
7
5
  module Signore
8
6
  describe SigFromStream do
9
- describe '.sig_from' do
7
+ describe '.call' do
10
8
  it 'asks about signature parts' do
11
- io = capture_io { SigFromStream.sig_from StringIO.new("\n\n\n\n") }
12
- _(io.first).must_equal <<-end.dedent
9
+ io = capture_io { SigFromStream.call StringIO.new("\n\n\n\n\n") }
10
+ _(io.first).must_equal <<~end
11
+
13
12
  text?
14
13
 
15
14
  author?
@@ -21,7 +20,7 @@ module Signore
21
20
  end
22
21
 
23
22
  it 'asks about signature parts and returns resulting signature' do
24
- input = StringIO.new <<-end.dedent
23
+ input = StringIO.new <<~end
25
24
  You do have to be mad to work here, but it doesn’t help.
26
25
 
27
26
  Gary Barnes
@@ -29,14 +28,14 @@ module Signore
29
28
  asr
30
29
  end
31
30
  sig = nil
32
- capture_io { sig = SigFromStream.sig_from input }
31
+ capture_io { sig = SigFromStream.call input }
33
32
  text = 'You do have to be mad to work here, but it doesn’t help.'
34
33
  _(sig).must_equal Signature.new(author: 'Gary Barnes', source: 'asr',
35
34
  text: text)
36
35
  end
37
36
 
38
37
  it 'handles multi-line signatures' do
39
- input = StringIO.new <<-end.dedent
38
+ input = StringIO.new <<~end
40
39
  ‘You’ve got an interesting accent. Subtle. I can’t place it.’
41
40
  ‘It’s text-to-speech… I was raised by smartphones.’
42
41
 
@@ -45,8 +44,8 @@ module Signore
45
44
 
46
45
  end
47
46
  sig = nil
48
- capture_io { sig = SigFromStream.sig_from input }
49
- text = <<-end.dedent.strip
47
+ capture_io { sig = SigFromStream.call input }
48
+ text = <<~end.strip
50
49
  ‘You’ve got an interesting accent. Subtle. I can’t place it.’
51
50
  ‘It’s text-to-speech… I was raised by smartphones.’
52
51
  end
@@ -1,17 +1,27 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'yaml'
4
2
  require_relative '../test_helper'
5
- require_relative '../../lib/signore/mapper'
6
3
  require_relative '../../lib/signore/signature'
7
4
 
8
5
  module Signore # rubocop:disable Metrics/ModuleLength
9
6
  describe Signature do
7
+ describe '.from_h' do
8
+ it 'deserializes a Signature from a Hash' do
9
+ text = 'For the sake of topic titles, I’d rather if Monty saved Python.'
10
+ sig_hash = { 'author' => 'Anonymous Coward', 'source' => '/.',
11
+ 'subject' => 'on ‘Monty Wants to Save MySQL’',
12
+ 'tags' => %w[/. MySQL], 'text' => text }
13
+ signature = Signature.new(author: 'Anonymous Coward', source: '/.',
14
+ subject: 'on ‘Monty Wants to Save MySQL’',
15
+ tags: %w[/. MySQL], text: text)
16
+ _(Signature.from_h(sig_hash)).must_equal signature
17
+ end
18
+ end
19
+
10
20
  describe '.new' do
11
21
  it 'instantiates Signatures via parameters' do
12
22
  source = 'A History of Modern Computing'
13
23
  text = 'In 1940 he summarized his work in an influential book, ' \
14
- '‘Punched Card Methods in Scientific Computation’.'
24
+ '‘Punched Card Methods in Scientific Computation’.'
15
25
  sig = Signature.new(author: 'Paul E. Ceruzzi', source: source,
16
26
  subject: 'on Wallace Eckert',
17
27
  tags: ['punched cards'], text: text)
@@ -45,10 +55,10 @@ module Signore # rubocop:disable Metrics/ModuleLength
45
55
  text = 'For the sake of topic titles, I’d rather if Monty saved Python.'
46
56
  sig = Signature.new(author: 'Anonymous Coward', source: '/.',
47
57
  subject: 'on ‘Monty Wants to Save MySQL’',
48
- tags: %w(/. MySQL), text: text)
58
+ tags: %w[/. MySQL], text: text)
49
59
  _(sig.to_h).must_equal 'author' => 'Anonymous Coward', 'source' => '/.',
50
60
  'subject' => 'on ‘Monty Wants to Save MySQL’',
51
- 'tags' => %w(/. MySQL), 'text' => text
61
+ 'tags' => %w[/. MySQL], 'text' => text
52
62
  end
53
63
 
54
64
  it 'removes non-existing keys' do
@@ -62,7 +72,7 @@ module Signore # rubocop:disable Metrics/ModuleLength
62
72
  end
63
73
 
64
74
  it 'does not show meta if there’s nothing to show' do
65
- text = '// sometimes I believe compiler ignores all my comments'
75
+ text = "// sometimes I believe compiler\n// ignores all my comments"
66
76
  sig = Signature.new(text: text)
67
77
  _(sig.to_s).must_equal text
68
78
  end
@@ -70,7 +80,7 @@ module Signore # rubocop:disable Metrics/ModuleLength
70
80
  it 'shows author on its own' do
71
81
  sig = Signature.new(author: 'kodz',
72
82
  text: 'stay-at-home executives vs. wallstreet dads')
73
- _(sig.to_s).must_equal <<-end.dedent.strip
83
+ _(sig.to_s).must_equal <<~end.strip
74
84
  stay-at-home executives vs. wallstreet dads
75
85
  [kodz]
76
86
  end
@@ -79,18 +89,20 @@ module Signore # rubocop:disable Metrics/ModuleLength
79
89
  it 'shows author and source, comma-separated' do
80
90
  text = 'You do have to be mad to work here, but it doesn’t help.'
81
91
  sig = Signature.new(author: 'Gary Barnes', source: 'asr', text: text)
82
- _(sig.to_s).must_equal <<-end.dedent.strip
83
- You do have to be mad to work here, but it doesn’t help.
84
- [Gary Barnes, asr]
92
+ _(sig.to_s).must_equal <<~end.strip
93
+ You do have to be mad to work
94
+ here, but it doesn’t help.
95
+ [Gary Barnes, asr]
85
96
  end
86
97
  end
87
98
 
88
99
  it 'shows source on its own' do
89
100
  text = 'Bruce Schneier knows Alice and Bob’s shared secret.'
90
101
  sig = Signature.new(source: 'Bruce Schneier Facts', text: text)
91
- _(sig.to_s).must_equal <<-end.dedent.strip
92
- Bruce Schneier knows Alice and Bob’s shared secret.
93
- [Bruce Schneier Facts]
102
+ _(sig.to_s).must_equal <<~end.strip
103
+ Bruce Schneier knows Alice
104
+ and Bob’s shared secret.
105
+ [Bruce Schneier Facts]
94
106
  end
95
107
  end
96
108
 
@@ -98,7 +110,7 @@ module Signore # rubocop:disable Metrics/ModuleLength
98
110
  text = 'More gangland camp than neo-noir.'
99
111
  sig = Signature.new(author: 'Nicholas Christopher',
100
112
  subject: 'on Pulp Fiction', text: text)
101
- _(sig.to_s).must_equal <<-end.dedent.strip
113
+ _(sig.to_s).must_equal <<~end.strip
102
114
  More gangland camp than neo-noir.
103
115
  [Nicholas Christopher on Pulp Fiction]
104
116
  end
@@ -106,9 +118,9 @@ module Signore # rubocop:disable Metrics/ModuleLength
106
118
 
107
119
  it 'shows subject on its own' do
108
120
  text = 'Amateur fighter pilot ignores orders, listens ' \
109
- 'to the voices in his head and slaughters thousands.'
121
+ 'to the voices in his head and slaughters thousands.'
110
122
  sig = Signature.new(subject: 'Star Wars ending explained', text: text)
111
- _(sig.to_s).must_equal <<-end.dedent.strip
123
+ _(sig.to_s).must_equal <<~end.strip
112
124
  Amateur fighter pilot ignores orders, listens to
113
125
  the voices in his head and slaughters thousands.
114
126
  [Star Wars ending explained]
@@ -116,8 +128,10 @@ module Signore # rubocop:disable Metrics/ModuleLength
116
128
  end
117
129
 
118
130
  it 'handles edge cases properly' do
119
- YAML.load_file('test/fixtures/wrapper.yml').each do |sig, wrapped|
120
- _(Mapper.from_h(sig.to_h).to_s).must_equal wrapped
131
+ wrappings = YAML.load_file('test/fixtures/wrapper.yml',
132
+ permitted_classes: [Signature, Symbol])
133
+ wrappings.each do |sig, wrapped|
134
+ _(Signature.from_h(sig.to_h).to_s).must_equal wrapped
121
135
  end
122
136
  end
123
137
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require_relative '../test_helper'
4
2
  require_relative '../../lib/signore/tags'
5
3
 
@@ -7,24 +5,24 @@ module Signore
7
5
  describe Tags do
8
6
  describe '#match?' do
9
7
  it 'is a predicate whether the Tags match the given list of tags' do
10
- tags = %w(programming tech)
8
+ tags = %w[programming tech]
11
9
  assert Tags.new.match?([])
12
- assert Tags.new(forbidden: %w(fnord)).match?([])
10
+ assert Tags.new(forbidden: %w[fnord]).match?([])
13
11
  assert Tags.new.match?(tags)
14
- assert Tags.new(required: %w(programming)).match?(tags)
15
- assert Tags.new(required: %w(programming tech)).match?(tags)
16
- refute Tags.new(required: %w(programming tech Ruby)).match?(tags)
17
- refute Tags.new(forbidden: %w(programming)).match?(tags)
18
- refute Tags.new(forbidden: %w(tech), required: %w(tech)).match?(tags)
12
+ assert Tags.new(required: %w[programming]).match?(tags)
13
+ assert Tags.new(required: %w[programming tech]).match?(tags)
14
+ refute Tags.new(required: %w[programming tech Ruby]).match?(tags)
15
+ refute Tags.new(forbidden: %w[programming]).match?(tags)
16
+ refute Tags.new(forbidden: %w[tech], required: %w[tech]).match?(tags)
19
17
  end
20
18
  end
21
19
 
22
20
  describe '#to_s' do
23
21
  it 'returns a CLI-like representation of the Tags' do
24
22
  _(Tags.new.to_s).must_equal ''
25
- _(Tags.new(required: %w(tech)).to_s).must_equal 'tech'
26
- _(Tags.new(forbidden: %w(fnord)).to_s).must_equal '~fnord'
27
- _(Tags.new(forbidden: %w(fnord), required: %w(tech)).to_s)
23
+ _(Tags.new(required: %w[tech]).to_s).must_equal 'tech'
24
+ _(Tags.new(forbidden: %w[fnord]).to_s).must_equal '~fnord'
25
+ _(Tags.new(forbidden: %w[fnord], required: %w[tech]).to_s)
28
26
  .must_equal 'tech ~fnord'
29
27
  end
30
28
  end
data/test/test_helper.rb CHANGED
@@ -1,17 +1,4 @@
1
- # frozen_string_literal: true
2
-
3
1
  ENV['MT_NO_EXPECTATIONS'] = 'true'
4
- require 'bundler/setup'
5
2
  require 'minitest/autorun'
6
3
  require 'minitest/focus'
7
4
  require 'minitest/pride'
8
- require 'bogus/minitest/spec'
9
- require 'signore'
10
-
11
- Bogus.configure { |config| config.search_modules << Signore }
12
-
13
- class String
14
- def dedent
15
- gsub(/^#{scan(/^ +/).min}/, '')
16
- end
17
- end