table_print 1.5.7 → 1.6.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.
@@ -6,46 +6,46 @@ describe TablePrint::ConfigResolver do
6
6
  # Sandbox.add_class("Configged")
7
7
  # TablePrint::Config.set(Sandbox::Configged, [:title, :author])
8
8
  # c = TablePrint::ConfigResolver.new(Object, Object, [:name])
9
- # c.columns.length.should == 2
10
- # c.columns.first.name.should == 'title'
11
- # c.columns.last.name.should == 'author'
9
+ # expect(c.columns.length).to eq 2
10
+ # expect(c.columns.first.name).to eq 'title'
11
+ # expect(c.columns.last.name).to eq 'author'
12
12
  #end
13
13
 
14
14
  describe "#get_and_remove" do
15
15
  it "deletes and returns the :except key from an array" do
16
16
  c = TablePrint::ConfigResolver.new(Object, [])
17
17
  options = [:title, :author, {:except => [:title]}]
18
- c.get_and_remove(options, :except).should == [:title]
19
- options.should == [:title, :author]
18
+ expect(c.get_and_remove(options, :except)).to eq [:title]
19
+ expect(options).to eq [:title, :author]
20
20
  end
21
21
 
22
22
  it "deletes and returns the :except key from an array with an :include key" do
23
23
  c = TablePrint::ConfigResolver.new(Object, [])
24
24
  options = [:title, {:except => [:title]}, {:include => [:author]}]
25
- c.get_and_remove(options, :except).should == [:title]
26
- options.should == [:title, {:include => [:author]}]
25
+ expect(c.get_and_remove(options, :except)).to eq [:title]
26
+ expect(options).to eq [:title, {:include => [:author]}]
27
27
  end
28
28
 
29
29
  it "deletes and returns the :except key from a hash with an :include key" do
30
30
  c = TablePrint::ConfigResolver.new(Object, [])
31
31
  options = [:title, {:except => [:title], :include => [:author]}]
32
- c.get_and_remove(options, :except).should == [:title]
33
- options.should == [:title, {:include => [:author]}]
32
+ expect(c.get_and_remove(options, :except)).to eq [:title]
33
+ expect(options).to eq [:title, {:include => [:author]}]
34
34
  end
35
35
 
36
36
  it "deletes and returns both the :include and :except keys" do
37
37
  c = TablePrint::ConfigResolver.new(Object, [])
38
38
  options = [:title, {:except => [:title]}, {:include => [:author]}]
39
- c.get_and_remove(options, :include).should == [:author]
40
- c.get_and_remove(options, :except).should == [:title]
41
- options.should == [:title]
39
+ expect(c.get_and_remove(options, :include)).to eq [:author]
40
+ expect(c.get_and_remove(options, :except)).to eq [:title]
41
+ expect(options).to eq [:title]
42
42
  end
43
43
 
44
44
  it "works even if the array doesn't have an exception hash" do
45
45
  c = TablePrint::ConfigResolver.new(Object, [])
46
46
  options = [:title, :author]
47
- c.get_and_remove(options, :except).should == []
48
- options.should == [:title, :author]
47
+ expect(c.get_and_remove(options, :except)).to eq []
48
+ expect(options).to eq [:title, :author]
49
49
  end
50
50
  end
51
51
 
@@ -53,23 +53,23 @@ describe TablePrint::ConfigResolver do
53
53
  context "with a symbol" do
54
54
  it "returns a column named foo" do
55
55
  c = TablePrint::ConfigResolver.new(Object, [:title], :foo)
56
- c.columns.length.should == 1
57
- c.columns.first.name.should == 'foo'
56
+ expect(c.columns.length).to eq 1
57
+ expect(c.columns.first.name).to eq 'foo'
58
58
  end
59
59
  end
60
60
  context "with a string" do
61
61
  it "returns a column named foo" do
62
62
  c = TablePrint::ConfigResolver.new(Object, [:title], 'foo')
63
- c.columns.length.should == 1
64
- c.columns.first.name.should == 'foo'
63
+ expect(c.columns.length).to eq 1
64
+ expect(c.columns.first.name).to eq 'foo'
65
65
  end
66
66
  end
67
67
  context "with an array of symbols and strings" do
68
68
  it "returns columns named foo and bar" do
69
69
  c = TablePrint::ConfigResolver.new(Object, [:title], :foo, 'bar')
70
- c.columns.length.should == 2
71
- c.columns.first.name.should == 'foo'
72
- c.columns.last.name.should == 'bar'
70
+ expect(c.columns.length).to eq 2
71
+ expect(c.columns.first.name).to eq 'foo'
72
+ expect(c.columns.last.name).to eq 'bar'
73
73
  end
74
74
  end
75
75
  end
@@ -78,29 +78,29 @@ describe TablePrint::ConfigResolver do
78
78
  context "with a symbol" do
79
79
  it "adds foo to the list of methods" do
80
80
  c = TablePrint::ConfigResolver.new(Object, [:title], :include => :foo)
81
- c.columns.length.should == 2
82
- c.columns.first.name.should == 'title'
83
- c.columns.last.name.should == 'foo'
81
+ expect(c.columns.length).to eq 2
82
+ expect(c.columns.first.name).to eq 'title'
83
+ expect(c.columns.last.name).to eq 'foo'
84
84
  end
85
85
  end
86
86
 
87
87
  context "with an array" do
88
88
  it "adds foo and bar to the list of methods" do
89
89
  c = TablePrint::ConfigResolver.new(Object, [:title], :include => [:foo, :bar])
90
- c.columns.length.should == 3
91
- c.columns.first.name.should == 'title'
92
- c.columns.last.name.should == 'bar'
90
+ expect(c.columns.length).to eq 3
91
+ expect(c.columns.first.name).to eq 'title'
92
+ expect(c.columns.last.name).to eq 'bar'
93
93
  end
94
94
  end
95
95
 
96
96
  context "with options" do
97
97
  it "adds foo to the list of methods and remembers its options" do
98
98
  c = TablePrint::ConfigResolver.new(Object, [:title], :include => {:foo => {:width => 10}})
99
- c.columns.length.should == 2
100
- c.columns.first.name.should == 'title'
99
+ expect(c.columns.length).to eq 2
100
+ expect(c.columns.first.name).to eq 'title'
101
101
 
102
- c.columns.last.name.should == 'foo'
103
- c.columns.last.default_width.should == 10
102
+ expect(c.columns.last.name).to eq 'foo'
103
+ expect(c.columns.last.default_width).to eq 10
104
104
  end
105
105
  end
106
106
  end
@@ -109,15 +109,15 @@ describe TablePrint::ConfigResolver do
109
109
  context "with a symbol" do
110
110
  it "removes foo from the list of methods" do
111
111
  c = TablePrint::ConfigResolver.new(Object, [:title, :foo], :except => :foo)
112
- c.columns.length.should == 1
113
- c.columns.first.name.should == 'title'
112
+ expect(c.columns.length).to eq 1
113
+ expect(c.columns.first.name).to eq 'title'
114
114
  end
115
115
  end
116
116
  context "with an array" do
117
117
  it "removes foo and bar from the list of methods" do
118
118
  c = TablePrint::ConfigResolver.new(Object, [:title, :foo, :bar], :except => [:foo, 'bar'])
119
- c.columns.length.should == 1
120
- c.columns.first.name.should == 'title'
119
+ expect(c.columns.length).to eq 1
120
+ expect(c.columns.first.name).to eq 'title'
121
121
  end
122
122
  end
123
123
  end
@@ -126,56 +126,138 @@ describe TablePrint::ConfigResolver do
126
126
  it "uses the key as the name and the lambda as the display method" do
127
127
  lam = lambda {}
128
128
  c = TablePrint::ConfigResolver.new(Object, [:title], :foo => {:display_method => lam})
129
- c.columns.length.should == 1
130
- c.columns.first.name.should == 'foo'
131
- c.columns.first.display_method.should == lam
129
+ expect(c.columns.length).to eq 1
130
+ expect(c.columns.first.name).to eq 'foo'
131
+ expect(c.columns.first.display_method).to eq lam
132
132
  end
133
133
 
134
134
  context "without the display_method keyword" do
135
135
  it "uses the key as the name and the lambda as the display method" do
136
136
  lam = lambda {}
137
137
  c = TablePrint::ConfigResolver.new(Object, [:title], :foo => lam)
138
- c.columns.length.should == 1
139
- c.columns.first.name.should == 'foo'
140
- c.columns.first.display_method.should == lam
138
+ expect(c.columns.length).to eq 1
139
+ expect(c.columns.first.name).to eq 'foo'
140
+ expect(c.columns.first.display_method).to eq lam
141
141
  end
142
142
  end
143
143
  end
144
144
 
145
+ describe "several columns in one hash" do
146
+ let(:first) { lambda { |row| "one" } }
147
+ let(:second) { lambda { |row| "two" } }
148
+
149
+ it "makes a column out of every key" do
150
+ c = TablePrint::ConfigResolver.new(Object, [], :title => { :max_width => 3 }, :author => { :max_width => 5 })
151
+
152
+ expect(c.columns.collect(&:name)).to eq %w[title author]
153
+ expect(c.columns.collect(&:default_width)).to eq [3, 5]
154
+ end
155
+
156
+ it "handles more than two" do
157
+ c = TablePrint::ConfigResolver.new(Object, [], :a => {}, :b => {}, :c => {})
158
+
159
+ expect(c.columns.collect(&:name)).to eq %w[a b c]
160
+ end
161
+
162
+ it "keeps them in the order they were written" do
163
+ c = TablePrint::ConfigResolver.new(Object, [], :zebra => {}, :aardvark => {})
164
+
165
+ expect(c.columns.collect(&:name)).to eq %w[zebra aardvark]
166
+ end
167
+
168
+ it "takes a lambda for each one" do
169
+ c = TablePrint::ConfigResolver.new(Object, [], :a => first, :b => second)
170
+
171
+ expect(c.columns.collect(&:name)).to eq %w[a b]
172
+ expect(c.columns.collect(&:display_method)).to eq [first, second]
173
+ end
174
+
175
+ it "mixes lambdas and option hashes in the same hash" do
176
+ c = TablePrint::ConfigResolver.new(Object, [], :a => first, :title => { :max_width => 3 })
177
+
178
+ expect(c.columns.collect(&:name)).to eq %w[a title]
179
+ expect(c.columns.first.display_method).to eq first
180
+ expect(c.columns.last.default_width).to eq 3
181
+ end
182
+
183
+ it "works for columns added with :include" do
184
+ c = TablePrint::ConfigResolver.new(Object, [:title], :include => { :a => first, :b => second })
185
+
186
+ expect(c.columns.collect(&:name)).to eq %w[title a b]
187
+ expect(c.columns.last.display_method).to eq second
188
+ end
189
+
190
+ it "works alongside :except in the same hash" do
191
+ c = TablePrint::ConfigResolver.new(Object, [:title, :author], :except => :author, :include => { :a => first, :b => second })
192
+
193
+ expect(c.columns.collect(&:name)).to eq %w[title a b]
194
+ end
195
+
196
+ it "carries display_name and display_method through for each one" do
197
+ c = TablePrint::ConfigResolver.new(Object, [],
198
+ :one => { :display_name => "First One", :display_method => first },
199
+ :two => { :display_name => "Second One", :display_method => second })
200
+
201
+ expect(c.columns.collect(&:name)).to eq ["First One", "Second One"]
202
+ expect(c.columns.collect(&:display_method)).to eq [first, second]
203
+ end
204
+
205
+ it "still accepts a column per hash, with braces" do
206
+ c = TablePrint::ConfigResolver.new(Object, [], [{ :title => { :max_width => 3 } }, { :author => { :max_width => 5 } }])
207
+
208
+ expect(c.columns.collect(&:name)).to eq %w[title author]
209
+ expect(c.columns.collect(&:default_width)).to eq [3, 5]
210
+ end
211
+
212
+ it "still accepts a single-key hash" do
213
+ c = TablePrint::ConfigResolver.new(Object, [], :title => { :max_width => 3 })
214
+
215
+ expect(c.columns.collect(&:name)).to eq %w[title]
216
+ expect(c.columns.first.default_width).to eq 3
217
+ end
218
+
219
+ it "still accepts a Column object passed to :include" do
220
+ column = TablePrint::Column.new(:name => "handmade")
221
+ c = TablePrint::ConfigResolver.new(Object, [:title], :include => column)
222
+
223
+ expect(c.columns.collect(&:name)).to eq %w[title handmade]
224
+ end
225
+ end
226
+
145
227
  describe "#usable_column_names" do
146
228
  it "returns default columns" do
147
229
  c = TablePrint::ConfigResolver.new(Object, [:title])
148
- c.usable_column_names.should == ['title']
230
+ expect(c.usable_column_names).to eq ['title']
149
231
  end
150
232
 
151
233
  it "returns specified columns instead of default columns" do
152
234
  c = TablePrint::ConfigResolver.new(Object, [:title], [:author])
153
- c.usable_column_names.should == ['author']
235
+ expect(c.usable_column_names).to eq ['author']
154
236
  end
155
237
 
156
238
  it "applies includes on top of default columns" do
157
239
  c = TablePrint::ConfigResolver.new(Object, [:title], [:include => :author])
158
- c.usable_column_names.should == ['title', 'author']
240
+ expect(c.usable_column_names).to eq ['title', 'author']
159
241
  end
160
242
 
161
243
  it "applies includes on top of specified columns" do
162
244
  c = TablePrint::ConfigResolver.new(Object, [:title], [:author, {:include => :pub_date}])
163
- c.usable_column_names.should == ['author', 'pub_date']
245
+ expect(c.usable_column_names).to eq ['author', 'pub_date']
164
246
  end
165
247
 
166
248
  it "applies excepts on top of default columns" do
167
249
  c = TablePrint::ConfigResolver.new(Object, [:title, :author], [:except => :author])
168
- c.usable_column_names.should == ['title']
250
+ expect(c.usable_column_names).to eq ['title']
169
251
  end
170
252
 
171
253
  it "applies excepts on top of specified columns" do
172
254
  c = TablePrint::ConfigResolver.new(Object, [:title, :author], [:pub_date, :length, {:except => :length}])
173
- c.usable_column_names.should == ['pub_date']
255
+ expect(c.usable_column_names).to eq ['pub_date']
174
256
  end
175
257
 
176
258
  it "applies both includes and excepts on top of specified columns" do
177
259
  c = TablePrint::ConfigResolver.new(Object, [:title, :author], [:pub_date, :length, {:except => :length, :include => :foobar}])
178
- c.usable_column_names.should == ['pub_date', 'foobar']
260
+ expect(c.usable_column_names).to eq ['pub_date', 'foobar']
179
261
  end
180
262
  end
181
263
 
@@ -183,17 +265,27 @@ describe TablePrint::ConfigResolver do
183
265
  context "display_method" do
184
266
  it "sets the display method on the column" do
185
267
  c = TablePrint::ConfigResolver.new(Object, [:title], :title => {:display_method => :boofar})
186
- c.columns.length.should == 1
187
- c.columns.first.name.should == 'title'
188
- c.columns.first.display_method.should == "boofar"
268
+ expect(c.columns.length).to eq 1
269
+ expect(c.columns.first.name).to eq 'title'
270
+ expect(c.columns.first.display_method).to eq "boofar"
189
271
  end
190
272
  end
191
273
  context "width" do
192
274
  it "sets the default width" do
193
275
  c = TablePrint::ConfigResolver.new(Object, [:title], :title => {:width => 100})
194
- c.columns.length.should == 1
195
- c.columns.first.name.should == 'title'
196
- c.columns.first.default_width.should == 100
276
+ expect(c.columns.length).to eq 1
277
+ expect(c.columns.first.name).to eq 'title'
278
+ expect(c.columns.first.default_width).to eq 100
279
+ end
280
+
281
+ it "accepts max_width, the current spelling of the same option" do
282
+ c = TablePrint::ConfigResolver.new(Object, [:title], :title => {:max_width => 100})
283
+ expect(c.columns.first.default_width).to eq 100
284
+ end
285
+
286
+ it "prefers max_width when both spellings are given" do
287
+ c = TablePrint::ConfigResolver.new(Object, [:title], :title => {:width => 10, :max_width => 100})
288
+ expect(c.columns.first.default_width).to eq 100
197
289
  end
198
290
  end
199
291
  context "formatters" do
@@ -201,17 +293,32 @@ describe TablePrint::ConfigResolver do
201
293
  f1 = {}
202
294
  f2 = {}
203
295
  c = TablePrint::ConfigResolver.new(Object, [:title], :title => {:formatters => [f1, f2]})
204
- c.columns.length.should == 1
205
- c.columns.first.name.should == 'title'
206
- c.columns.first.formatters.should == [f1, f2]
296
+ expect(c.columns.length).to eq 1
297
+ expect(c.columns.first.name).to eq 'title'
298
+ expect(c.columns.first.formatters).to eq [f1, f2]
207
299
  end
208
300
  end
209
301
  context "display_name" do
210
302
  it "sets the display name on the column" do
211
303
  c = TablePrint::ConfigResolver.new(Object, [], :title => {:display_name => "Ti Tle"})
212
- c.columns.length.should == 1
213
- c.columns.first.name.should == 'Ti Tle'
214
- c.columns.first.display_method.should == "title"
304
+ expect(c.columns.length).to eq 1
305
+ expect(c.columns.first.name).to eq 'Ti Tle'
306
+ expect(c.columns.first.display_method).to eq "title"
307
+ end
308
+
309
+ it "keeps a display_method the caller specified" do
310
+ lam = lambda { |row| row }
311
+ c = TablePrint::ConfigResolver.new(Object, [], :whatever => {:display_name => "Ti Tle", :display_method => lam})
312
+
313
+ expect(c.columns.first.name).to eq "Ti Tle"
314
+ expect(c.columns.first.display_method).to eq lam
315
+ end
316
+
317
+ it "keeps a display_method given as a symbol, too" do
318
+ c = TablePrint::ConfigResolver.new(Object, [], :whatever => {:display_name => "Ti Tle", :display_method => :title})
319
+
320
+ expect(c.columns.first.name).to eq "Ti Tle"
321
+ expect(c.columns.first.display_method).to eq "title"
215
322
  end
216
323
  end
217
324
  end
@@ -221,22 +328,22 @@ describe TablePrint::ConfigResolver do
221
328
  it "returns a column named foo" do
222
329
  c = TablePrint::ConfigResolver.new(Object, [])
223
330
  column = c.option_to_column(:foo)
224
- column.name.should == 'foo'
331
+ expect(column.name).to eq 'foo'
225
332
  end
226
333
  end
227
334
  context "with a string" do
228
335
  it "returns a column named foo" do
229
336
  c = TablePrint::ConfigResolver.new(Object, [])
230
337
  column = c.option_to_column('foo')
231
- column.name.should == 'foo'
338
+ expect(column.name).to eq 'foo'
232
339
  end
233
340
  end
234
341
  context "with a hash" do
235
342
  it "returns a column named foo and the specified options" do
236
343
  c = TablePrint::ConfigResolver.new(Object, [])
237
344
  column = c.option_to_column({:foo => {:default_width => 10}})
238
- column.name.should == 'foo'
239
- column.default_width.should == 10
345
+ expect(column.name).to eq 'foo'
346
+ expect(column.default_width).to eq 10
240
347
  end
241
348
  end
242
349
  end
data/spec/config_spec.rb CHANGED
@@ -2,18 +2,22 @@ require 'spec_helper'
2
2
 
3
3
  describe TablePrint::Config do
4
4
  it "defaults max_width to 30" do
5
- TablePrint::Config.max_width.should == 30
5
+ expect(TablePrint::Config.max_width).to eq 30
6
6
  end
7
7
 
8
8
  it "defaults time_format to year-month-day-hour-minute-second" do
9
- TablePrint::Config.time_format.should == "%Y-%m-%d %H:%M:%S"
9
+ expect(TablePrint::Config.time_format).to eq "%Y-%m-%d %H:%M:%S"
10
+ end
11
+
12
+ it "defaults multibyte to false" do
13
+ expect(TablePrint::Config.multibyte).to eq false
10
14
  end
11
15
 
12
16
  describe "individual config options" do
13
17
  describe "storing and retrieving" do
14
18
  it "sets the variable" do
15
19
  TablePrint::Config.set(:max_width, [10])
16
- TablePrint::Config.max_width.should == 10
20
+ expect(TablePrint::Config.max_width).to eq 10
17
21
  TablePrint::Config.set(:max_width, [30])
18
22
  end
19
23
  end
@@ -22,7 +26,13 @@ describe TablePrint::Config do
22
26
  it "resets the variable to its initial value" do
23
27
  TablePrint::Config.set(:max_width, [10])
24
28
  TablePrint::Config.clear(:max_width)
25
- TablePrint::Config.max_width.should == 30
29
+ expect(TablePrint::Config.max_width).to eq 30
30
+ end
31
+
32
+ it "resets multibyte" do
33
+ TablePrint::Config.set(:multibyte, [true])
34
+ TablePrint::Config.clear(:multibyte)
35
+ expect(TablePrint::Config.multibyte).to eq false
26
36
  end
27
37
  end
28
38
  end
@@ -35,7 +45,21 @@ describe TablePrint::Config do
35
45
  describe "storing and retrieving" do
36
46
  it "stores the column hash" do
37
47
  TablePrint::Config.set(Sandbox::Blog, [:title, :author])
38
- TablePrint::Config.for(Sandbox::Blog).should == [:title, :author]
48
+ expect(TablePrint::Config.for(Sandbox::Blog)).to eq [:title, :author]
49
+ end
50
+
51
+ it "hands out a copy, so a caller can't empty the stored config" do
52
+ TablePrint::Config.set(Sandbox::Blog, [:title, :author])
53
+ TablePrint::Config.for(Sandbox::Blog).clear
54
+
55
+ expect(TablePrint::Config.for(Sandbox::Blog)).to eq [:title, :author]
56
+ end
57
+
58
+ it "copies the hashes inside it too, since that's what gets consumed" do
59
+ TablePrint::Config.set(Sandbox::Blog, [{ :except => :title }])
60
+ TablePrint::Config.for(Sandbox::Blog).first.delete(:except)
61
+
62
+ expect(TablePrint::Config.for(Sandbox::Blog)).to eq [{ :except => :title }]
39
63
  end
40
64
  end
41
65
 
@@ -43,11 +67,64 @@ describe TablePrint::Config do
43
67
  it "removes the class from storage" do
44
68
  TablePrint::Config.set(Sandbox::Blog, [:title, :author])
45
69
  TablePrint::Config.clear(Sandbox::Blog)
46
- TablePrint::Config.for(Sandbox::Blog).should be_nil
70
+ expect(TablePrint::Config.for(Sandbox::Blog)).to be_nil
47
71
  end
48
72
  end
49
73
  end
50
74
 
75
+ describe "unreachable_value" do
76
+ it "defaults to Method Missing" do
77
+ expect(TablePrint::Config.unreachable_value).to eq "Method Missing"
78
+ end
79
+
80
+ it "takes any string, or nil to leave those cells blank" do
81
+ TablePrint::Config.set(:unreachable_value, ["-"])
82
+ expect(TablePrint::Config.unreachable_value).to eq "-"
83
+
84
+ TablePrint::Config.set(:unreachable_value, [nil])
85
+ expect(TablePrint::Config.unreachable_value).to be_nil
86
+
87
+ TablePrint::Config.clear(:unreachable_value)
88
+ expect(TablePrint::Config.unreachable_value).to eq "Method Missing"
89
+ end
90
+ end
91
+
92
+ describe "show_headers" do
93
+ it "defaults to true" do
94
+ expect(TablePrint::Config.show_headers).to eq true
95
+ end
96
+
97
+ it "can be turned off and back on" do
98
+ TablePrint::Config.set(:show_headers, [false])
99
+ expect(TablePrint::Config.show_headers).to eq false
100
+
101
+ TablePrint::Config.clear(:show_headers)
102
+ expect(TablePrint::Config.show_headers).to eq true
103
+ end
104
+ end
105
+
106
+ describe "horizontal_separator" do
107
+ it "defaults to a hyphen" do
108
+ expect(TablePrint::Config.horizontal_separator).to eq "-"
109
+ end
110
+
111
+ it "takes a single character, or nil for no line" do
112
+ TablePrint::Config.set(:horizontal_separator, ["="])
113
+ expect(TablePrint::Config.horizontal_separator).to eq "="
114
+
115
+ TablePrint::Config.set(:horizontal_separator, [nil])
116
+ expect(TablePrint::Config.horizontal_separator).to be_nil
117
+
118
+ TablePrint::Config.clear(:horizontal_separator)
119
+ expect(TablePrint::Config.horizontal_separator).to eq "-"
120
+ end
121
+
122
+ it "rejects anything longer than one character" do
123
+ expect { TablePrint::Config.horizontal_separator = "==" }.to raise_error StandardError
124
+ expect(TablePrint::Config.horizontal_separator).to eq "-"
125
+ end
126
+ end
127
+
51
128
  describe "io" do
52
129
  before :all do
53
130
  Sandbox.add_class("MyIO")
@@ -57,20 +134,20 @@ describe TablePrint::Config do
57
134
  it "accepts object that respond to puts" do
58
135
  myIO = Sandbox::MyIO.new
59
136
  TablePrint::Config.set(:io, [myIO])
60
- TablePrint::Config.io.should == myIO
137
+ expect(TablePrint::Config.io).to eq myIO
61
138
  end
62
139
 
63
140
  it "doesn't accept objects unless they respond to puts" do
64
- lambda {
141
+ expect {
65
142
  TablePrint::Config.set(:io, [""])
66
- }.should raise_error StandardError
143
+ }.to raise_error StandardError
67
144
  end
68
145
 
69
146
  it "defaults to STDOUT" do
70
147
  myIO = Sandbox::MyIO.new
71
148
  TablePrint::Config.set(:io, [myIO])
72
149
  TablePrint::Config.clear(:io)
73
- TablePrint::Config.io.should == STDOUT
150
+ expect(TablePrint::Config.io).to eq STDOUT
74
151
  end
75
152
  end
76
153
  end