spec/unit/tables/table_module_spec.rb in ProMotion-0.7.8 vs spec/unit/tables/table_module_spec.rb in ProMotion-1.0.0
- old
+ new
@@ -3,30 +3,29 @@
def cell_factory(args={})
{ title: "Basic", action: :basic_cell_tapped, arguments: { id: 1 } }.merge!(args)
end
def custom_cell
+ @image = UIImage.imageNamed("list")
cell_factory({
title: "Crazy Full Featured Cell",
subtitle: "This is way too huge..see note",
arguments: { data: [ "lots", "of", "data" ] },
action: :tapped_cell_1,
height: 50, # manually changes the cell's height
cell_style: UITableViewCellStyleSubtitle,
cell_identifier: "Cell",
cell_class: PM::TableViewCell,
masks_to_bounds: true,
- background_color: UIColor.whiteColor,
+ background_color: UIColor.colorWithPatternImage(@image),
selection_style: UITableViewCellSelectionStyleGray,
- cell_class_attributes: {
- # any Obj-C attributes to set on the cell
- backgroundColor: UIColor.whiteColor
+ accessory: {
+ view: :switch, # currently only :switch is supported
+ type: UITableViewCellAccessoryCheckmark,
+ checked: true # whether it's "checked" or not
},
- accessory: :switch, # currently only :switch is supported
- accessory_type: UITableViewCellAccessoryCheckmark,
- accessory_checked: true, # whether it's "checked" or not
- image: { image: UIImage.imageNamed("something"), radius: 15 },
+ image: { image: @image, radius: 15 },
remote_image: { # remote image, requires SDWebImage CocoaPod
url: "http://placekitten.com/200/300", placeholder: "some-local-image",
size: 50, radius: 15
},
subviews: [ @some_view, @some_other_view ] # arbitrary views added to the cell
@@ -39,11 +38,11 @@
[{
title: "Table cell group 1", cells: [ ]
},{
title: "Table cell group 2", cells: [ cell_factory ]
},{
- title: "Table cell group 3", cells: [ cell_factory(title: "3-1"), cell_factory(title: "3-2") ]
+ 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") ]
}]
end
@@ -100,8 +99,24 @@
@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 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)
+ cell.backgroundColor.should.be.kind_of(UIColor)
+ cell.backgroundColor.should == UIColor.colorWithPatternImage(@image)
+ end
+
+ 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
end