spec/unit/tables/table_module_spec.rb in ProMotion-2.0.0 vs spec/unit/tables/table_module_spec.rb in ProMotion-2.0.1
- old
+ new
@@ -49,10 +49,12 @@
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: [ ]
+ },{
+ title: "Action WIth Index Path Group", cells: [ cell_factory(title: "IndexPath Group 1", action: :tests_index_path) ]
}]
end
@subject.on_load
@@ -61,11 +63,11 @@
@subject.update_table_data
end
it "should have the right number of sections" do
- @subject.numberOfSectionsInTableView(@subject.table_view).should == 6
+ @subject.numberOfSectionsInTableView(@subject.table_view).should == 7
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"
@@ -111,9 +113,20 @@
@subject.mock! :tapped_cell_1 do |args|
args[:data].should == [ "lots", "of", "data" ]
end
@subject.tableView(@subject.table_view, didSelectRowAtIndexPath:@custom_ip)
+ end
+
+ it "should return an NSIndexPath when the action has two parameters" do
+ ip = NSIndexPath.indexPathForRow(0, inSection: 6)
+
+ @subject.tableView(@subject.table_view, didSelectRowAtIndexPath:ip)
+
+ tapped_ip = @subject.got_index_path
+ tapped_ip.should.be.kind_of NSIndexPath
+ tapped_ip.section.should == 6
+ tapped_ip.row.should == 0
end
# TODO - make this test work when MacBacon supports long press gestures
# https://github.com/HipByte/RubyMotion/issues/160
#