Sha256: c28848f80d46bea4999ccd992f0641bd32e3c50ed51847bb317d3aa5da1c0cdb

Contents?: true

Size: 1.81 KB

Versions: 24

Compression:

Stored size: 1.81 KB

Contents

class MagicSizeView < UIView

  def intrinsicContentSize
    CGSize.new(200, 100)
  end

end


describe 'Constraints - Size helpers' do

  before do
    @layout = MK::Layout.new
    @constraint = nil
    @view = MagicSizeView.new
  end

  it 'should support `height :scale`' do
    @layout.context(@view) do
      @layout.constraints do
        @constraint = @layout.height(:scale)
      end
    end

    @constraint.target.should == @view
    @constraint.attribute.should == :height
    @constraint.attribute2.should == :width
    @constraint.relationship.should == :equal
    @constraint.multiplier.should == 0.5
    nsconstraint = @constraint.resolve_all(@layout, @view).first
    nsconstraint.firstItem.should == @view
    nsconstraint.firstAttribute.should == NSLayoutAttributeHeight
    nsconstraint.secondItem.should == @view
    nsconstraint.secondAttribute.should == NSLayoutAttributeWidth
    nsconstraint.relation.should == NSLayoutRelationEqual
    nsconstraint.multiplier.should == 0.5
    nsconstraint.constant.should == 0
  end

  it 'should support `width :scale`' do
    @layout.context(@view) do
      @layout.constraints do
        @constraint = @layout.width(:scale)
      end
    end

    @constraint.target.should == @view
    @constraint.attribute.should == :width
    @constraint.attribute2.should == :height
    @constraint.relationship.should == :equal
    @constraint.multiplier.should == 2.0
    nsconstraint = @constraint.resolve_all(@layout, @view).first
    nsconstraint.firstItem.should == @view
    nsconstraint.firstAttribute.should == NSLayoutAttributeWidth
    nsconstraint.secondItem.should == @view
    nsconstraint.secondAttribute.should == NSLayoutAttributeHeight
    nsconstraint.relation.should == NSLayoutRelationEqual
    nsconstraint.multiplier.should == 2.0
    nsconstraint.constant.should == 0
  end

end

Version data entries

24 entries across 18 versions & 1 rubygems

Version Path
motion-kit-1.1.1 spec/tvos/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.1.1 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.1.0 spec/tvos/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.1.0 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.0.3 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.0.3 spec/tvos/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.0.2 spec/tvos/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.0.2 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.0.1 spec/tvos/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.0.1 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.0.0 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-1.0.0 spec/tvos/constraints_helpers/scale_constraints_spec.rb
motion-kit-0.18.0 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-0.17.0 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-0.16.0 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-0.15.0 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-0.14.2 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-0.14.1 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-0.14.0 spec/ios/constraints_helpers/scale_constraints_spec.rb
motion-kit-0.13.0 spec/ios/constraints_helpers/scale_constraints_spec.rb