Skip to content
This repository
Browse code

Remove error raising from Table#number_of_columns and return the actu…

…al number of columns
  • Loading branch information...
commit f9a70870bdce541f98fbad10ddfb407a206f68da 1 parent 8945911
René Föhring rrrene authored

Showing 2 changed files with 6 additions and 13 deletions. Show diff stats Hide diff stats

  1. +1 11 lib/terminal-table/table.rb
  2. +5 2 spec/table_spec.rb
12 lib/terminal-table/table.rb
@@ -2,12 +2,6 @@
2 2 module Terminal
3 3 class Table
4 4
5   - #--
6   - # Exceptions
7   - #++
8   -
9   - Error = Class.new StandardError
10   -
11 5 attr_reader :title
12 6 attr_reader :headings
13 7 attr_accessor :width
@@ -96,11 +90,7 @@ def column_width n
96 90 # Return total number of columns available.
97 91
98 92 def number_of_columns
99   - if rows.empty?
100   - raise Error, 'your table needs some rows'
101   - else
102   - rows.map { |r| r.size }.max
103   - end
  93 + headings_with_rows.map { |r| r.size }.max
104 94 end
105 95
106 96 ##
7 spec/table_spec.rb
@@ -95,8 +95,11 @@ module Terminal
95 95 @table.rows.size.should == 2
96 96 end
97 97
98   - it "should bitch and complain when you have no rows" do
99   - lambda { @table.render }.should raise_error(Terminal::Table::Error)
  98 + it "should render an empty table properly" do
  99 + @table.render.should == <<-EOF.deindent
  100 + ++
  101 + ++
  102 + EOF
100 103 end
101 104
102 105 it "should render properly" do

0 comments on commit f9a7087

Please sign in to comment.
Something went wrong with that request. Please try again.