spec/unit/view_helper_spec.rb in ProMotion-2.1.0 vs spec/unit/view_helper_spec.rb in ProMotion-2.2.0

- old
+ new

@@ -1,5 +1,18 @@ +class TestView < UIView + attr_accessor :on_load_fired + attr_accessor :on_styled_fired + + def on_load + self.on_load_fired = true + end + + def on_styled + self.on_styled_fired = true + end +end + describe "view helpers" do def equal_rect(rect) ->(obj) { CGRectEqualToRect obj, rect } end @@ -57,9 +70,21 @@ content_mode: UIViewContentModeBottom } layered_view.contentMode.should == UIViewContentModeBottom layered_view.layer.backgroundColor.should == UIColor.redColor.CGColor + end + + it "should trigger on_load on a view that supports it" do + v = TestView.new + @dummy.add v + v.on_load_fired.should == true + end + + it "should trigger on_styled on a view that supports it" do + v = TestView.new + @dummy.set_attributes v, { background_color: UIColor.blueColor } + v.on_styled_fired.should == true end context "content sizing" do