lovely_rufus 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,27 +1,31 @@
1
+ require 'stringio'
1
2
  require_relative '../spec_helper'
3
+ require_relative '../../lib/lovely_rufus/cli_wrapper'
2
4
 
3
- module LovelyRufus describe CLIWrapper do
4
- describe '#run' do
5
- let(:text) { "all right: stop, collaborate and listen\n" }
6
- let(:text_wrapper) { fake :text_wrapper, as: :class }
5
+ module LovelyRufus
6
+ describe CLIWrapper do
7
+ describe '#run' do
8
+ let(:text) { "all right: stop, collaborate and listen\n" }
9
+ let(:text_wrapper) { fake(:text_wrapper, as: :class) }
7
10
 
8
- it 'reads the passed stream to TextWrapper and prints the results' do
9
- stub(text_wrapper).wrap(text, width: 72) { text }
10
- lambda do
11
- CLIWrapper.new(text_wrapper: text_wrapper).run StringIO.new text
12
- end.must_output text
13
- end
11
+ it 'reads the passed stream to TextWrapper and prints the results' do
12
+ stub(text_wrapper).wrap(text, width: 72) { text }
13
+ lambda do
14
+ CLIWrapper.new(text_wrapper: text_wrapper).run StringIO.new(text)
15
+ end.must_output text
16
+ end
14
17
 
15
- it 'accepts the desired width and passes it to TextWrapper' do
16
- wrap = <<-end.dedent
17
- all right: stop,
18
- collaborate and listen
18
+ it 'accepts the desired width and passes it to TextWrapper' do
19
+ wrap = <<-end.dedent
20
+ all right: stop,
21
+ collaborate and listen
22
+ end
23
+ stub(text_wrapper).wrap(text, width: 22) { wrap }
24
+ lambda do
25
+ stream = StringIO.new(text)
26
+ CLIWrapper.new(%w(--width=22), text_wrapper: text_wrapper).run stream
27
+ end.must_output wrap
19
28
  end
20
- stub(text_wrapper).wrap(text, width: 22) { wrap }
21
- lambda do
22
- stream = StringIO.new text
23
- CLIWrapper.new(%w(--width 22), text_wrapper: text_wrapper).run stream
24
- end.must_output wrap
25
29
  end
26
30
  end
27
- end end
31
+ end
@@ -1,25 +1,30 @@
1
1
  require_relative '../spec_helper'
2
+ require_relative '../../lib/lovely_rufus/hangout_wrapper'
3
+ require_relative '../../lib/lovely_rufus/wrap'
2
4
 
3
- module LovelyRufus describe HangoutWrapper do
4
- describe '#call' do
5
- it 'removes hangouts from the text' do
6
- text = <<-end.dedent
7
- I go crazy when I hear a cymbal and
8
- a hi-hat with a souped-up tempo
5
+ module LovelyRufus
6
+ describe HangoutWrapper do
7
+ describe '#call' do
8
+ it 'removes hangouts from the text' do
9
+ text = <<-end.dedent
10
+ I go crazy when I hear a cymbal and
11
+ a hi-hat with a souped-up tempo
12
+ end
13
+ wrap = <<-end.dedent
14
+ I go crazy when I hear a cymbal
15
+ and a hi-hat with a souped-up tempo
16
+ end
17
+ hw = HangoutWrapper.new
18
+ hw.call(Wrap[text, width: 35]).must_equal Wrap[wrap, width: 35]
9
19
  end
10
- wrap = <<-end.dedent
11
- I go crazy when I hear a cymbal
12
- and a hi-hat with a souped-up tempo
13
- end
14
- hw = HangoutWrapper.new
15
- hw.call(Wrap[text, width: 35]).must_equal Wrap[wrap, width: 35]
16
- end
17
20
 
18
- it 'passes the fixed text to the next layer and returns its outcome' do
19
- final = fake :wrap
20
- layer = fake :layer
21
- mock(layer).call(any Wrap) { final }
22
- HangoutWrapper.new(layer).call(Wrap["I O\nU", width: 4]).must_equal final
21
+ it 'passes the fixed text to the next layer and returns its outcome' do
22
+ final = fake(:wrap)
23
+ layer = fake(:layer)
24
+ mock(layer).call(any(Wrap)) { final }
25
+ wrapped = HangoutWrapper.new(layer).call(Wrap["I O\nU", width: 4])
26
+ wrapped.must_equal final
27
+ end
23
28
  end
24
29
  end
25
- end end
30
+ end
@@ -1,26 +1,31 @@
1
1
  require_relative '../spec_helper'
2
+ require_relative '../../lib/lovely_rufus/one_letter_gluer'
3
+ require_relative '../../lib/lovely_rufus/wrap'
2
4
 
3
- module LovelyRufus describe OneLetterGluer do
4
- describe '#call' do
5
- it 'replaces spaces after one-letter words with non-break spaces' do
6
- text = 'I go crazy when I hear a cymbal and a hi-hat'
7
- glue = 'I go crazy when I hear a cymbal and a hi-hat'
8
- olg = OneLetterGluer.new
9
- olg.call(Wrap[text, width: 42]).must_equal Wrap[glue, width: 42]
10
- end
5
+ module LovelyRufus
6
+ describe OneLetterGluer do
7
+ describe '#call' do
8
+ it 'replaces spaces after one-letter words with non-break spaces' do
9
+ text = 'I go crazy when I hear a cymbal and a hi-hat'
10
+ glue = 'I go crazy when I hear a cymbal and a hi-hat'
11
+ olg = OneLetterGluer.new
12
+ olg.call(Wrap[text, width: 42]).must_equal Wrap[glue, width: 42]
13
+ end
11
14
 
12
- it 'glues subsequent one-letter words' do
13
- text = 'one-letter words in English: a, I & o'
14
- glue = 'one-letter words in English: a, I & o'
15
- olg = OneLetterGluer.new
16
- olg.call(Wrap[text, width: 42]).must_equal Wrap[glue, width: 42]
17
- end
15
+ it 'glues subsequent one-letter words' do
16
+ text = 'one-letter words in English: a, I & o'
17
+ glue = 'one-letter words in English: a, I & o'
18
+ olg = OneLetterGluer.new
19
+ olg.call(Wrap[text, width: 42]).must_equal Wrap[glue, width: 42]
20
+ end
18
21
 
19
- it 'passes the fixed text to the next layer and returns its outcome' do
20
- final = fake :wrap
21
- layer = fake :layer
22
- mock(layer).call(Wrap['I O U', width: 69]) { final }
23
- OneLetterGluer.new(layer).call(Wrap['I O U', width: 69]).must_equal final
22
+ it 'passes the fixed text to the next layer and returns its outcome' do
23
+ final = fake(:wrap)
24
+ layer = fake(:layer)
25
+ mock(layer).call(Wrap['I O U', width: 69]) { final }
26
+ glued = OneLetterGluer.new(layer).call(Wrap['I O U', width: 69])
27
+ glued.must_equal final
28
+ end
24
29
  end
25
30
  end
26
- end end
31
+ end
@@ -1,127 +1,131 @@
1
1
  require_relative '../spec_helper'
2
+ require_relative '../../lib/lovely_rufus/quote_stripper'
3
+ require_relative '../../lib/lovely_rufus/wrap'
2
4
 
3
- module LovelyRufus describe QuoteStripper do
4
- describe '#call' do
5
- it 'strips quotes and adjusts width before calling the next layer' do
6
- quoted = <<-end.dedent
7
- > to the extreme I rock a mic like a vandal
8
- > light up a stage and wax a chump like a candle
5
+ module LovelyRufus
6
+ describe QuoteStripper do
7
+ describe '#call' do
8
+ it 'strips quotes and adjusts width before calling the next layer' do
9
+ quoted = <<-end.dedent
10
+ > to the extreme I rock a mic like a vandal
11
+ > light up a stage and wax a chump like a candle
12
+ end
13
+ unquoted = <<-end.dedent
14
+ to the extreme I rock a mic like a vandal
15
+ light up a stage and wax a chump like a candle
16
+ end
17
+ layer = fake(:layer, call: Wrap[unquoted, width: 70])
18
+ QuoteStripper.new(layer).call(Wrap[quoted, width: 72])
19
+ layer.must_have_received :call, [Wrap[unquoted, width: 70]]
9
20
  end
10
- unquoted = <<-end.dedent
11
- to the extreme I rock a mic like a vandal
12
- light up a stage and wax a chump like a candle
13
- end
14
- layer = fake :layer, call: Wrap[unquoted, width: 70]
15
- QuoteStripper.new(layer).call Wrap[quoted, width: 72]
16
- layer.must_have_received :call, [Wrap[unquoted, width: 70]]
17
- end
18
21
 
19
- it 'adds quotes back in (and adjusts width) before returning' do
20
- quoted = <<-end.dedent
21
- > take heed, ’cause I’m a lyrical poet
22
- > Miami’s on the scene just in case you didn’t know it
22
+ it 'adds quotes back in (and adjusts width) before returning' do
23
+ quoted = <<-end.dedent
24
+ > take heed, ’cause I’m a lyrical poet
25
+ > Miami’s on the scene just in case you didn’t know it
26
+ end
27
+ wrap = Wrap[quoted, width: 72]
28
+ QuoteStripper.new.call(wrap).must_equal wrap
23
29
  end
24
- wrap = Wrap[quoted, width: 72]
25
- QuoteStripper.new.call(wrap).must_equal wrap
26
- end
27
30
 
28
- it 'does not touch non-quoted texts' do
29
- plain = <<-end.dedent
30
- my town, that created all the bass sound
31
- enough to shake and kick holes in the ground
31
+ it 'does not touch non-quoted texts' do
32
+ plain = <<-end.dedent
33
+ my town, that created all the bass sound
34
+ enough to shake and kick holes in the ground
35
+ end
36
+ wrap = Wrap[plain, width: 72]
37
+ QuoteStripper.new.call(wrap).must_equal wrap
32
38
  end
33
- wrap = Wrap[plain, width: 72]
34
- QuoteStripper.new.call(wrap).must_equal wrap
35
- end
36
39
 
37
- it 'does not alter text contents' do
38
- wrap = Wrap['> Ice > Ice > Baby']
39
- QuoteStripper.new.call(wrap).must_equal wrap
40
- end
41
-
42
- it 'strips multilevel quotes' do
43
- quoted = <<-end.dedent
44
- >> ’cause my style’s like a chemical spill
45
- >> feasible rhymes that you can vision and feel
46
- end
47
- unquoted = <<-end.dedent
48
- ’cause my style’s like a chemical spill
49
- feasible rhymes that you can vision and feel
40
+ it 'does not alter text contents' do
41
+ wrap = Wrap['> Ice > Ice > Baby']
42
+ QuoteStripper.new.call(wrap).must_equal wrap
50
43
  end
51
- layer = fake :layer, call: Wrap[unquoted, width: 69]
52
- QuoteStripper.new(layer).call Wrap[quoted, width: 72]
53
- layer.must_have_received :call, [Wrap[unquoted, width: 69]]
54
- end
55
44
 
56
- it 'strips broken quotes properly' do
57
- quoted = <<-end.dedent
58
- > > >conducted and formed this is a hell of a concept
59
- > > >we make it hype and you want to step with this
60
- end
61
- unquoted = <<-end.dedent
62
- conducted and formed this is a hell of a concept
63
- we make it hype and you want to step with this
45
+ it 'strips multilevel quotes' do
46
+ quoted = <<-end.dedent
47
+ >> ’cause my style’s like a chemical spill
48
+ >> feasible rhymes that you can vision and feel
49
+ end
50
+ unquoted = <<-end.dedent
51
+ ’cause my style’s like a chemical spill
52
+ feasible rhymes that you can vision and feel
53
+ end
54
+ layer = fake(:layer, call: Wrap[unquoted, width: 69])
55
+ QuoteStripper.new(layer).call(Wrap[quoted, width: 72])
56
+ layer.must_have_received :call, [Wrap[unquoted, width: 69]]
64
57
  end
65
- layer = fake :layer, call: Wrap[unquoted, width: 68]
66
- QuoteStripper.new(layer).call Wrap[quoted, width: 72]
67
- layer.must_have_received :call, [Wrap[unquoted, width: 68]]
68
- end
69
58
 
70
- it 'fixes broken quotes when adding them back in' do
71
- quoted = <<-end.dedent
72
- > > >Shay plays on the fade,
73
- > > >slice like a ninja
74
- > > >cut like a razor blade
75
- end
76
- fixed = <<-end.dedent
77
- >>> Shay plays on the fade,
78
- >>> slice like a ninja
79
- >>> cut like a razor blade
59
+ it 'strips broken quotes properly' do
60
+ quoted = <<-end.dedent
61
+ > > >conducted and formed this is a hell of a concept
62
+ > > >we make it hype and you want to step with this
63
+ end
64
+ unquoted = <<-end.dedent
65
+ conducted and formed this is a hell of a concept
66
+ we make it hype and you want to step with this
67
+ end
68
+ layer = fake(:layer, call: Wrap[unquoted, width: 68])
69
+ QuoteStripper.new(layer).call(Wrap[quoted, width: 72])
70
+ layer.must_have_received :call, [Wrap[unquoted, width: 68]]
80
71
  end
81
- wrap = Wrap[quoted, width: 72]
82
- QuoteStripper.new.call(wrap).must_equal Wrap[fixed, width: 72]
83
- end
84
72
 
85
- it 'strips // code comments' do
86
- quoted = <<-end.dedent
87
- // so fast other DJs say ‘damn!’
88
- // if my rhyme was a drug I’d sell it by the gram
89
- end
90
- unquoted = <<-end.dedent
91
- so fast other DJs say ‘damn!’
92
- if my rhyme was a drug I’d sell it by the gram
73
+ it 'fixes broken quotes when adding them back in' do
74
+ quoted = <<-end.dedent
75
+ > > >Shay plays on the fade,
76
+ > > >slice like a ninja
77
+ > > >cut like a razor blade
78
+ end
79
+ fixed = <<-end.dedent
80
+ >>> Shay plays on the fade,
81
+ >>> slice like a ninja
82
+ >>> cut like a razor blade
83
+ end
84
+ wrap = Wrap[quoted, width: 72]
85
+ QuoteStripper.new.call(wrap).must_equal Wrap[fixed, width: 72]
93
86
  end
94
- layer = fake :layer, call: Wrap[unquoted, width: 69]
95
- QuoteStripper.new(layer).call Wrap[quoted, width: 72]
96
- layer.must_have_received :call, [Wrap[unquoted, width: 69]]
97
- end
98
87
 
99
- it 'strips # code comments' do
100
- quoted = <<-end.dedent
101
- # keep my composure when it’s time to get loose
102
- # magnetized by the mic while I kick my juice
103
- end
104
- unquoted = <<-end.dedent
105
- keep my composure when it’s time to get loose
106
- magnetized by the mic while I kick my juice
88
+ it 'strips // code comments' do
89
+ quoted = <<-end.dedent
90
+ // so fast other DJs say ‘damn!’
91
+ // if my rhyme was a drug I’d sell it by the gram
92
+ end
93
+ unquoted = <<-end.dedent
94
+ so fast other DJs say ‘damn!’
95
+ if my rhyme was a drug I’d sell it by the gram
96
+ end
97
+ layer = fake(:layer, call: Wrap[unquoted, width: 69])
98
+ QuoteStripper.new(layer).call(Wrap[quoted, width: 72])
99
+ layer.must_have_received :call, [Wrap[unquoted, width: 69]]
107
100
  end
108
- layer = fake :layer, call: Wrap[unquoted, width: 70]
109
- QuoteStripper.new(layer).call Wrap[quoted, width: 72]
110
- layer.must_have_received :call, [Wrap[unquoted, width: 70]]
111
- end
112
101
 
113
- it 'only considers homogenous characters as comments' do
114
- quoted = <<-end.dedent
115
- > /if there was a problem,
116
- > yo I’ll solve it!/
102
+ it 'strips # code comments' do
103
+ quoted = <<-end.dedent
104
+ # keep my composure when it’s time to get loose
105
+ # magnetized by the mic while I kick my juice
106
+ end
107
+ unquoted = <<-end.dedent
108
+ keep my composure when it’s time to get loose
109
+ magnetized by the mic while I kick my juice
110
+ end
111
+ layer = fake(:layer, call: Wrap[unquoted, width: 70])
112
+ QuoteStripper.new(layer).call(Wrap[quoted, width: 72])
113
+ layer.must_have_received :call, [Wrap[unquoted, width: 70]]
117
114
  end
118
- unquoted = <<-end.dedent
119
- /if there was a problem,
120
- yo I’ll solve it!/
115
+
116
+ it 'only considers homogenous characters as comments' do
117
+ quoted = <<-end.dedent
118
+ > /if there was a problem,
119
+ > yo – I’ll solve it!/
120
+ end
121
+ unquoted = <<-end.dedent
122
+ /if there was a problem,
123
+ yo – I’ll solve it!/
124
+ end
125
+ layer = fake(:layer, call: Wrap[unquoted, width: 70])
126
+ QuoteStripper.new(layer).call(Wrap[quoted, width: 72])
127
+ layer.must_have_received :call, [Wrap[unquoted, width: 70]]
121
128
  end
122
- layer = fake :layer, call: Wrap[unquoted, width: 70]
123
- QuoteStripper.new(layer).call Wrap[quoted, width: 72]
124
- layer.must_have_received :call, [Wrap[unquoted, width: 70]]
125
129
  end
126
130
  end
127
- end end
131
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../spec_helper'
2
+ require_relative '../../lib/lovely_rufus/settings'
3
+
4
+ module LovelyRufus
5
+ describe Settings do
6
+ describe '#width' do
7
+ it 'defaults to 72' do
8
+ Settings.new([]).width.must_equal 72
9
+ end
10
+
11
+ it 'can be set via --width' do
12
+ Settings.new(%w(--width=42)).width.must_equal 42
13
+ end
14
+
15
+ it 'can be set via -w' do
16
+ Settings.new(%w(-w 42)).width.must_equal 42
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,48 +1,53 @@
1
+ require 'yaml'
1
2
  require_relative '../spec_helper'
3
+ require_relative '../../lib/lovely_rufus/text_wrapper'
2
4
 
3
- module LovelyRufus describe TextWrapper do
4
- describe '.wrap' do
5
- it 'wraps the passed String to 72 characters by default' do
6
- short = 'all right: stop, collaborate and listen'
7
- long = short + ' Ice is back with a brand new invention'
8
- wrap = <<-end.dedent
9
- all right: stop, collaborate and listen
10
- Ice is back with a brand new invention
5
+ module LovelyRufus
6
+ describe TextWrapper do
7
+ describe '.wrap' do
8
+ it 'wraps the passed String to 72 characters by default' do
9
+ short = 'all right: stop, collaborate and listen'
10
+ long = short + ' – Ice is back with a brand new invention'
11
+ wrap = <<-end.dedent
12
+ all right: stop, collaborate and listen
13
+ – Ice is back with a brand new invention
14
+ end
15
+ TextWrapper.wrap(short).must_equal "#{short}\n"
16
+ TextWrapper.wrap(long).must_equal wrap
11
17
  end
12
- TextWrapper.wrap(short).must_equal "#{short}\n"
13
- TextWrapper.wrap(long).must_equal wrap
14
- end
15
18
 
16
- it 'wraps the passed String to the given number of characters' do
17
- input = 'something grabs a hold of me tightly; ' \
18
- 'flow like a harpoon – daily and nightly'
19
- TextWrapper.wrap(input, width: 40).must_equal <<-end.dedent
20
- something grabs a hold of me tightly;
21
- flow like a harpoon – daily and nightly
22
- end
23
- TextWrapper.wrap(input, width: 21).must_equal <<-end.dedent
24
- something grabs
25
- a hold of me tightly;
26
- flow like a harpoon
27
- – daily and nightly
19
+ it 'wraps the passed String to the given number of characters' do
20
+ input = 'something grabs a hold of me tightly; ' \
21
+ 'flow like a harpoon – daily and nightly'
22
+ TextWrapper.wrap(input, width: 40).must_equal <<-end.dedent
23
+ something grabs a hold of me tightly;
24
+ flow like a harpoon – daily and nightly
25
+ end
26
+ TextWrapper.wrap(input, width: 21).must_equal <<-end.dedent
27
+ something grabs
28
+ a hold of me tightly;
29
+ flow like a harpoon
30
+ – daily and nightly
31
+ end
28
32
  end
29
- end
30
33
 
31
- it 'rewraps a String from zero' do
32
- broken = <<-end.dedent
33
- turn off
34
- the lights and I’ll glow
34
+ it 'rewraps a String from zero' do
35
+ broken = <<-end.dedent
36
+ turn off
37
+ the lights and I’ll glow
38
+ end
39
+ wrapped = TextWrapper.wrap(broken)
40
+ wrapped.must_equal "turn off the lights and I’ll glow\n"
35
41
  end
36
- TextWrapper.wrap(broken).must_equal "turn off the lights and I’ll glow\n"
37
- end
38
42
 
39
- it 'supports all the example use-cases' do
40
- path = File.expand_path 'text_wrapper_spec.yml', __dir__
41
- YAML.load_file(path).each do |spec|
42
- width = spec.fetch('width') { 72 }
43
- wrap = "#{spec['output']}\n"
44
- TextWrapper.wrap(spec['input'], width: width).must_equal wrap
43
+ it 'supports all the example use-cases' do
44
+ path = File.expand_path('text_wrapper_spec.yml', __dir__)
45
+ YAML.load_file(path).each do |spec|
46
+ width = spec.fetch('width') { 72 }
47
+ wrap = "#{spec['output']}\n"
48
+ TextWrapper.wrap(spec['input'], width: width).must_equal wrap
49
+ end
45
50
  end
46
51
  end
47
52
  end
48
- end end
53
+ end
@@ -1,27 +1,30 @@
1
1
  require_relative '../spec_helper'
2
+ require_relative '../../lib/lovely_rufus/wrap'
2
3
 
3
- module LovelyRufus describe Wrap do
4
- describe '.[]' do
5
- it 'creates a Wrap with the given text and target width' do
6
- Wrap['Ice Ice Baby', width: 7].text.must_equal 'Ice Ice Baby'
7
- Wrap['Ice Ice Baby', width: 7].width.must_equal 7
8
- end
4
+ module LovelyRufus
5
+ describe Wrap do
6
+ describe '.[]' do
7
+ it 'creates a Wrap with the given text and target width' do
8
+ Wrap['Ice Ice Baby', width: 7].text.must_equal 'Ice Ice Baby'
9
+ Wrap['Ice Ice Baby', width: 7].width.must_equal 7
10
+ end
9
11
 
10
- it 'defaults to empty text and width of 72' do
11
- Wrap[].text.must_equal ''
12
- Wrap[].width.must_equal 72
12
+ it 'defaults to empty text and width of 72' do
13
+ Wrap[].text.must_equal ''
14
+ Wrap[].width.must_equal 72
15
+ end
13
16
  end
14
- end
15
17
 
16
- describe '#text' do
17
- it 'accesses the text of the Wrap' do
18
- Wrap['Ice Ice Baby', width: 7].text.must_equal 'Ice Ice Baby'
18
+ describe '#text' do
19
+ it 'accesses the text of the Wrap' do
20
+ Wrap['Ice Ice Baby', width: 7].text.must_equal 'Ice Ice Baby'
21
+ end
19
22
  end
20
- end
21
23
 
22
- describe '#width' do
23
- it 'accesses the target width of the Wrap' do
24
- Wrap['Ice Ice Baby', width: 7].width.must_equal 7
24
+ describe '#width' do
25
+ it 'accesses the target width of the Wrap' do
26
+ Wrap['Ice Ice Baby', width: 7].width.must_equal 7
27
+ end
25
28
  end
26
29
  end
27
- end end
30
+ end
@@ -0,0 +1,51 @@
1
+ require 'yaml'
2
+ require_relative 'spec_helper'
3
+ require_relative '../lib/lovely_rufus'
4
+
5
+ describe LovelyRufus do
6
+ describe '.wrap' do
7
+ it 'wraps the passed String to 72 characters by default' do
8
+ short = 'all right: stop, collaborate and listen'
9
+ long = short + ' – Ice is back with a brand new invention'
10
+ wrap = <<-end.dedent
11
+ all right: stop, collaborate and listen
12
+ – Ice is back with a brand new invention
13
+ end
14
+ LovelyRufus.wrap(short).must_equal "#{short}\n"
15
+ LovelyRufus.wrap(long).must_equal wrap
16
+ end
17
+
18
+ it 'wraps the passed String to the given number of characters' do
19
+ input = 'something grabs a hold of me tightly; ' \
20
+ 'flow like a harpoon – daily and nightly'
21
+ LovelyRufus.wrap(input, width: 40).must_equal <<-end.dedent
22
+ something grabs a hold of me tightly;
23
+ flow like a harpoon – daily and nightly
24
+ end
25
+ LovelyRufus.wrap(input, width: 21).must_equal <<-end.dedent
26
+ something grabs
27
+ a hold of me tightly;
28
+ flow like a harpoon
29
+ – daily and nightly
30
+ end
31
+ end
32
+
33
+ it 'rewraps a String from zero' do
34
+ broken = <<-end.dedent
35
+ turn off
36
+ the lights and I’ll glow
37
+ end
38
+ wrapped = LovelyRufus.wrap(broken)
39
+ wrapped.must_equal "turn off the lights and I’ll glow\n"
40
+ end
41
+
42
+ it 'supports all the example use-cases' do
43
+ path = File.expand_path('lovely_rufus/text_wrapper_spec.yml', __dir__)
44
+ YAML.load_file(path).each do |spec|
45
+ width = spec.fetch('width') { 72 }
46
+ wrap = "#{spec['output']}\n"
47
+ LovelyRufus.wrap(spec['input'], width: width).must_equal wrap
48
+ end
49
+ end
50
+ end
51
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,7 +3,6 @@ require 'minitest/autorun'
3
3
  require 'minitest/focus'
4
4
  require 'minitest/pride'
5
5
  require 'bogus/minitest/spec'
6
- require 'yaml'
7
6
  require 'lovely_rufus'
8
7
 
9
8
  Bogus.configure { |config| config.search_modules << LovelyRufus }