Sha256: e6710e973af440af7ece41a60e9802ce162ebc44fb851b93d69670d5a2a390bb

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

describe "view helpers" do

  def equal_rect(rect)
    ->(obj) { CGRectEqualToRect obj, rect }
  end
  
  before do
    @dummy = UIView.alloc.initWithFrame CGRectZero
    @dummy.extend ProMotion::ViewHelper
  end

  it "#frame_from_array should return zero rect for bad input" do
    @dummy.frame_from_array([]).should equal_rect(CGRectZero)
  end

  it "#frame_from_array should return a valid CGRect" do
    @dummy.frame_from_array([0,0,320,480]).should equal_rect(CGRectMake(0,0,320,480)) 
  end

  it "should allow you to set attributes" do
    @dummy.set_attributes @dummy, backgroundColor: UIColor.redColor
    @dummy.backgroundColor.should == UIColor.redColor
  end

  describe "content height" do

    before do
      @child = UIView.alloc.initWithFrame([[20,100],[300,380]])
      @dummy.addSubview @child
    end

    it "should return content height" do
      @dummy.content_height(@dummy).should == 480
    end

    it "should ignore hidden subviews" do
      @child.hidden = true
      @dummy.content_height(@dummy).should == 0
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ProMotion-0.5.2 spec/view_helper_spec.rb