describe "Gradient" do tests FirstController before do @root_view = window.subviews[0] end it "should insert gradient layer when gradient style is set" do @root_view.style(gradient: { colors: [UIColor.redColor, UIColor.yellowColor] }) @root_view.layer.sublayers.size.should == 2 @root_view.layer.sublayers.first.class.should == CAGradientLayer end it "should not insert another gradient layer when gradient style is changed" do @root_view.style(gradient: { colors: [UIColor.redColor, UIColor.yellowColor] }) @root_view.style(gradient: { colors: [UIColor.greenColor, UIColor.whiteColor] }) @root_view.layer.sublayers.size.should == 2 end it "should change gradient layer when gradient style is changed" do @root_view.style(gradient: { colors: [UIColor.redColor, UIColor.yellowColor] }) before = @root_view.layer.sublayers.first.colors.first @root_view.style(gradient: { colors: [UIColor.greenColor, UIColor.whiteColor] }) after = @root_view.layer.sublayers.first.colors.first before.should != after end it "should accept CGColors" do @root_view.style(gradient: { colors: [UIColor.redColor.CGColor, UIColor.yellowColor.CGColor] }) @root_view.layer.sublayers.size.should == 2 end end