Working functional test for deleting a row in a table view

This commit is contained in:
Mark Rickert
2013-06-01 12:10:57 -04:00
parent c653d63496
commit a937e804eb
3 changed files with 23 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
describe "ProMotion::TestTableScreen functionality" do
tests PM::TestTableScreen
# Override controller to properly instantiate
def controller
rotate_device to: :portrait, button: :bottom
@@ -8,33 +8,39 @@ describe "ProMotion::TestTableScreen functionality" do
@controller.on_load
@controller.main_controller
end
after do
@controller = nil
end
it "should have a navigation bar" do
@controller.navigationController.should.be.kind_of(UINavigationController)
end
it "should increment the tap counter on tap" do
tap("Increment")
@controller.tap_counter.should == 3
end
it "should add a new table cell on tap" do
tap("Add New Row")
view("Dynamically Added").class.should == UILabel
end
it "should do nothing when no action specified" do
tap("Just another blank row")
@controller.should == @controller
end
it "should increment the tap counter by one on tap" do
it "should increment the tap counter by one on tap" do
tap("Increment One")
@controller.tap_counter.should == 1
end
end
it "should delete the specified row from the table view on tap" do
@controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 4
tap("Delete the row below")
@controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 3
end
end

View File

@@ -14,6 +14,7 @@ class TestTableScreen < ProMotion::SectionedTableScreen
cells: [
{ title: "Increment", action: :increment_counter_by, arguments: { number: 3 } },
{ title: "Add New Row", action: :add_tableview_row, accessibilityLabel: "Add New Row" },
{ title: "Delete the row below", action: :delete_row, arguments: {section: 0, row:3 }, accessibilityLabel: "Delete the row below" },
{ title: "Just another blank row" }
]
}, {
@@ -44,6 +45,11 @@ class TestTableScreen < ProMotion::SectionedTableScreen
update_table_data
end
def delete_row(args={})
@data[args[:section]][:cells].delete_at args[:row]
update_table_data
end
def increment_counter(args={})
@tap_counter += 1
end

View File

@@ -12,7 +12,7 @@ describe "table screens" do
end
it "should have proper cell numbers" do
@screen.tableView(@screen.tableView, numberOfRowsInSection:0).should == 3
@screen.tableView(@screen.tableView, numberOfRowsInSection:0).should == 4
@screen.tableView(@screen.tableView, numberOfRowsInSection:1).should == 2
@screen.tableView(@screen.tableView, numberOfRowsInSection:2).should == 4
end