spec/table_spec.rb in visionmedia-terminal-table-1.0.4 vs spec/table_spec.rb in visionmedia-terminal-table-1.0.5
- old
+ new
@@ -57,10 +57,14 @@
it "should render seperators" do
@table.headings = ['Char', 'Num']
@table << ['a', 1]
@table.seperator.should == '+------+-----+'
end
+
+ it "should bitch and complain when you have no rows" do
+ lambda { @table.render }.should raise_error(Terminal::Table::Error)
+ end
it "should render properly" do
@table.headings = ['Char', 'Num']
@table << ['a', 1]
@table << ['b', 2]
@@ -146,12 +150,12 @@
+----------------------+-----+
EOF
end
it "should allow alignment of headings and cells" do
- @table.headings = ['Characters', { :value => 'Nums', :align => :right }]
- @table << [{ :value => 'a', :align => :center }, 1]
+ @table.headings = ['Characters', ['Nums', :right ]]
+ @table << [['a', :center ], 1]
@table << ['b', 222222222222222]
@table << ['c', 3]
@table.render.should == <<-EOF.deindent
+------------+-----------------+
| Characters | Nums |
@@ -164,10 +168,10 @@
end
it "should align columns, but allow specifics to remain" do
@table.headings = ['Just some characters', 'Num']
- @table.rows = [[{ :value => 'a', :align => :left }, 1], ['b', 2], ['c', 3]]
+ @table.rows = [[['a', :left], 1], ['b', 2], ['c', 3]]
@table.align_column 0, :center
@table.align_column 1, :right
@table.render.should == <<-EOF.deindent
+----------------------+-----+
| Just some characters | Num |
\ No newline at end of file