Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…al number of columns
  • Loading branch information...
commit f9a70870bdce541f98fbad10ddfb407a206f68da 1 parent 8945911
@rrrene rrrene authored
Showing with 6 additions and 13 deletions.
  1. +1 −11 lib/terminal-table/table.rb
  2. +5 −2 spec/table_spec.rb
View
12 lib/terminal-table/table.rb
@@ -2,12 +2,6 @@
module Terminal
class Table
- #--
- # Exceptions
- #++
-
- Error = Class.new StandardError
-
attr_reader :title
attr_reader :headings
attr_accessor :width
@@ -96,11 +90,7 @@ def column_width n
# Return total number of columns available.
def number_of_columns
- if rows.empty?
- raise Error, 'your table needs some rows'
- else
- rows.map { |r| r.size }.max
- end
+ headings_with_rows.map { |r| r.size }.max
end
##
View
7 spec/table_spec.rb
@@ -95,8 +95,11 @@ module Terminal
@table.rows.size.should == 2
end
- it "should bitch and complain when you have no rows" do
- lambda { @table.render }.should raise_error(Terminal::Table::Error)
+ it "should render an empty table properly" do
+ @table.render.should == <<-EOF.deindent
+ ++
+ ++
+ EOF
end
it "should render properly" do

0 comments on commit f9a7087

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