spec/unit/tables/table_module_spec.rb in ProMotion-1.0.4 vs spec/unit/tables/table_module_spec.rb in ProMotion-1.1.0.rc1
- old
+ new
@@ -41,10 +41,14 @@
title: "Table cell group 2", cells: [ cell_factory ]
},{
title: "Table cell group 3", cells: [ cell_factory(title: "3-1"), cell_factory(title: "3-2", background_color: UIColor.blueColor) ]
},{
title: "Table cell group 4", cells: [ custom_cell, cell_factory(title: "4-2"), cell_factory(title: "4-3"), cell_factory(title: "4-4") ]
+ },{
+ title: "Custom section title 1", title_view: CustomTitleView, cells: [ ]
+ },{
+ title: "Custom section title 2", title_view: CustomTitleView.new, title_view_height: 50, cells: [ ]
}]
end
@subject.on_load
@@ -53,25 +57,29 @@
@subject.update_table_data
end
it "should have the right number of sections" do
- @subject.numberOfSectionsInTableView(@subject.table_view).should == 4
+ @subject.numberOfSectionsInTableView(@subject.table_view).should == 6
end
it "should set the section titles" do
@subject.tableView(@subject.table_view, titleForHeaderInSection:0).should == "Table cell group 1"
@subject.tableView(@subject.table_view, titleForHeaderInSection:1).should == "Table cell group 2"
@subject.tableView(@subject.table_view, titleForHeaderInSection:2).should == "Table cell group 3"
@subject.tableView(@subject.table_view, titleForHeaderInSection:3).should == "Table cell group 4"
+ @subject.tableView(@subject.table_view, titleForHeaderInSection:4).should == "Custom section title 1"
+ @subject.tableView(@subject.table_view, titleForHeaderInSection:5).should == "Custom section title 2"
end
it "should create the right number of cells" do
@subject.tableView(@subject.table_view, numberOfRowsInSection:0).should == 0
@subject.tableView(@subject.table_view, numberOfRowsInSection:1).should == 1
@subject.tableView(@subject.table_view, numberOfRowsInSection:2).should == 2
@subject.tableView(@subject.table_view, numberOfRowsInSection:3).should == 4
+ @subject.tableView(@subject.table_view, numberOfRowsInSection:4).should == 0
+ @subject.tableView(@subject.table_view, numberOfRowsInSection:5).should == 0
end
it "should create the jumplist" do
@subject.mock! :table_data_index, do
Array("A".."Z")
@@ -100,11 +108,11 @@
args[:data].should == [ "lots", "of", "data" ]
end
@subject.tableView(@subject.table_view, didSelectRowAtIndexPath:@custom_ip)
end
-
+
it "should set a custom cell background image" do
@image.should.not.be.nil
ip = NSIndexPath.indexPathForRow(0, inSection: 3) # Cell 2-1
cell = @subject.tableView(@subject.table_view, cellForRowAtIndexPath: ip)
cell.should.be.kind_of(UITableViewCell)
@@ -115,8 +123,26 @@
it "should set a custom cell background color" do
cell = @subject.tableView(@subject.table_view, cellForRowAtIndexPath: @ip)
cell.should.be.kind_of(UITableViewCell)
cell.backgroundColor.should.be.kind_of(UIColor)
cell.backgroundColor.should == UIColor.blueColor
+ end
+
+ describe("section with custom title_view") do
+
+ it "should use the correct class for section view" do
+ cell = @subject.tableView(@subject.table_view, viewForHeaderInSection: 4)
+ cell.should.be.kind_of(CustomTitleView)
+ end
+
+ it "should use the default section height if none is specified" do
+ header_height = (UIDevice.currentDevice.systemVersion.to_f >= 7.0) ? 23.0 : 22.0
+ @subject.tableView(@subject.table_view, heightForHeaderInSection:4).should == header_height # Built-in default
+ end
+
+ it "should use the set title_view_height if one is specified" do
+ @subject.tableView(@subject.table_view, heightForHeaderInSection:5).should == 50.0
+ end
+
end
end