Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 57 lines (52 sloc) 1.451 kB
84d51a6 @cldwalker seperate out table tests
cldwalker authored
1 require File.join(File.dirname(__FILE__), 'test_helper')
2
3 class Hirb::Helpers::ObjectTableTest < Test::Unit::TestCase
4 context "object table" do
5 before(:all) {
6 @pets = [stub(:name=>'rufus', :age=>7, :to_s=>'rufus'), stub(:name=>'alf', :age=>101, :to_s=>'alf')]
7 }
8 test "renders" do
9 expected_table = <<-TABLE.unindent
10 +-------+-----+
11 | name | age |
12 +-------+-----+
13 | rufus | 7 |
14 | alf | 101 |
15 +-------+-----+
16 2 rows in set
17 TABLE
18 Hirb::Helpers::ObjectTable.render(@pets, :fields=>[:name, :age]).should == expected_table
19 end
20
21 test "with no options defaults to to_s field" do
22 expected_table = <<-TABLE.unindent
23 +-------+
24 | value |
25 +-------+
26 | rufus |
27 | alf |
28 +-------+
29 2 rows in set
30 TABLE
31 Hirb::Helpers::ObjectTable.render(@pets).should == expected_table
32 end
33
34 test "renders simple arrays" do
35 expected_table = <<-TABLE.unindent
36 +-------+
37 | value |
38 +-------+
39 | 1 |
40 | 2 |
41 | 3 |
42 | 4 |
43 +-------+
44 4 rows in set
45 TABLE
46 Hirb::Helpers::ObjectTable.render([1,2,3,4]).should == expected_table
47 end
45a1cd0 @spastorino fixes 'error occurred while evaluating nil.<=' for example for models…
authored
48
49 test "with empty fields" do
50 expected_table = <<-TABLE.unindent
51 0 rows in set
52 TABLE
53 Hirb::Helpers::ObjectTable.render(@pets, :fields => []).should == expected_table
54 end
84d51a6 @cldwalker seperate out table tests
cldwalker authored
55 end
45a1cd0 @spastorino fixes 'error occurred while evaluating nil.<=' for example for models…
authored
56 end
Something went wrong with that request. Please try again.