瀏覽代碼

moat tests

Jonas Budelmann 12 年之前
父節點
當前提交
c653197dd0

+ 4 - 0
Masonry.xcodeproj/project.pbxproj

@@ -13,6 +13,7 @@
 		9CEFD2DA17CCF7A90014B0FF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CEFD2D817CCF7210014B0FF /* UIKit.framework */; };
 		9CEFD2DA17CCF7A90014B0FF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CEFD2D817CCF7210014B0FF /* UIKit.framework */; };
 		9CEFD2DB17CCF80D0014B0FF /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C61C40017CCF3F0001A124A /* Cocoa.framework */; };
 		9CEFD2DB17CCF80D0014B0FF /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C61C40017CCF3F0001A124A /* Cocoa.framework */; };
 		9DAD1ADAED04452C8C32D34E /* libPods-Masonry iOS Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3FF61518EB0044E0A00EB62E /* libPods-Masonry iOS Tests.a */; };
 		9DAD1ADAED04452C8C32D34E /* libPods-Masonry iOS Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3FF61518EB0044E0A00EB62E /* libPods-Masonry iOS Tests.a */; };
+		DD2F3B3B17CDF44500770F03 /* NSObject+MASSubscriptSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = DD2F3B3917CDF44500770F03 /* NSObject+MASSubscriptSupport.h */; };
 		DD38397E17A5170F00C35C17 /* MASConstraintDelegateMock.m in Sources */ = {isa = PBXBuildFile; fileRef = DD38397D17A5170F00C35C17 /* MASConstraintDelegateMock.m */; };
 		DD38397E17A5170F00C35C17 /* MASConstraintDelegateMock.m in Sources */ = {isa = PBXBuildFile; fileRef = DD38397D17A5170F00C35C17 /* MASConstraintDelegateMock.m */; };
 		DD52F1AE179CA93B005CD195 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD52F1AD179CA93B005CD195 /* Foundation.framework */; };
 		DD52F1AE179CA93B005CD195 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD52F1AD179CA93B005CD195 /* Foundation.framework */; };
 		DD52F1BD179CA93B005CD195 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD52F1BC179CA93B005CD195 /* SenTestingKit.framework */; };
 		DD52F1BD179CA93B005CD195 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD52F1BC179CA93B005CD195 /* SenTestingKit.framework */; };
@@ -102,6 +103,7 @@
 		9CC1B90117CCE7BA0032BB18 /* Masonry-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Masonry-Info.plist"; sourceTree = "<group>"; };
 		9CC1B90117CCE7BA0032BB18 /* Masonry-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Masonry-Info.plist"; sourceTree = "<group>"; };
 		9CEFD2D817CCF7210014B0FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
 		9CEFD2D817CCF7210014B0FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
 		B8646E0425DE4F42A4314C3C /* Pods-Masonry iOS Tests.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Masonry iOS Tests.xcconfig"; path = "Pods/Pods-Masonry iOS Tests.xcconfig"; sourceTree = SOURCE_ROOT; };
 		B8646E0425DE4F42A4314C3C /* Pods-Masonry iOS Tests.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Masonry iOS Tests.xcconfig"; path = "Pods/Pods-Masonry iOS Tests.xcconfig"; sourceTree = SOURCE_ROOT; };
+		DD2F3B3917CDF44500770F03 /* NSObject+MASSubscriptSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+MASSubscriptSupport.h"; sourceTree = "<group>"; };
 		DD38397C17A5170F00C35C17 /* MASConstraintDelegateMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraintDelegateMock.h; sourceTree = "<group>"; };
 		DD38397C17A5170F00C35C17 /* MASConstraintDelegateMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraintDelegateMock.h; sourceTree = "<group>"; };
 		DD38397D17A5170F00C35C17 /* MASConstraintDelegateMock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraintDelegateMock.m; sourceTree = "<group>"; };
 		DD38397D17A5170F00C35C17 /* MASConstraintDelegateMock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraintDelegateMock.m; sourceTree = "<group>"; };
 		DD52F1AA179CA93B005CD195 /* libMasonry.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMasonry.a; sourceTree = BUILT_PRODUCTS_DIR; };
 		DD52F1AA179CA93B005CD195 /* libMasonry.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMasonry.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -254,6 +256,7 @@
 		DD52F1C5179CA93B005CD195 /* Supporting Files */ = {
 		DD52F1C5179CA93B005CD195 /* Supporting Files */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
+				DD2F3B3917CDF44500770F03 /* NSObject+MASSubscriptSupport.h */,
 				DD38397C17A5170F00C35C17 /* MASConstraintDelegateMock.h */,
 				DD38397C17A5170F00C35C17 /* MASConstraintDelegateMock.h */,
 				DD38397D17A5170F00C35C17 /* MASConstraintDelegateMock.m */,
 				DD38397D17A5170F00C35C17 /* MASConstraintDelegateMock.m */,
 				DD52F1D6179CAA71005CD195 /* MasonryTests-Prefix.pch */,
 				DD52F1D6179CAA71005CD195 /* MasonryTests-Prefix.pch */,
@@ -332,6 +335,7 @@
 				DD52F26A179CB365005CD195 /* MASCompositeConstraint.h in Headers */,
 				DD52F26A179CB365005CD195 /* MASCompositeConstraint.h in Headers */,
 				DD7CC16E17ACCF22007A469E /* NSLayoutConstraint+MASDebugAdditions.h in Headers */,
 				DD7CC16E17ACCF22007A469E /* NSLayoutConstraint+MASDebugAdditions.h in Headers */,
 				DDA5752B17C17C3E0010F88E /* MASUtilities.h in Headers */,
 				DDA5752B17C17C3E0010F88E /* MASUtilities.h in Headers */,
+				DD2F3B3B17CDF44500770F03 /* NSObject+MASSubscriptSupport.h in Headers */,
 			);
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 		};

+ 1 - 1
Masonry/MASViewConstraint.m

@@ -76,7 +76,7 @@
     } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) {
     } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) {
         _secondViewAttribute = secondViewAttribute;
         _secondViewAttribute = secondViewAttribute;
     } else {
     } else {
-        NSAssert(YES, @"attempting to add unsupported attribute: %@", secondViewAttribute);
+        NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute);
     }
     }
 }
 }
 
 

+ 55 - 10
MasonryTests/MASCompositeConstraintSpec.m

@@ -22,6 +22,7 @@
 @property (nonatomic, weak) MASLayoutConstraint *layoutConstraint;
 @property (nonatomic, weak) MASLayoutConstraint *layoutConstraint;
 @property (nonatomic, assign) CGFloat layoutConstant;
 @property (nonatomic, assign) CGFloat layoutConstant;
 @property (nonatomic, assign) MASLayoutPriority layoutPriority;
 @property (nonatomic, assign) MASLayoutPriority layoutPriority;
+@property (nonatomic, assign) CGFloat layoutMultiplier;
 
 
 @end
 @end
 
 
@@ -37,29 +38,30 @@ beforeEach(^{
     view = MAS_VIEW.new;
     view = MAS_VIEW.new;
     superview = MAS_VIEW.new;
     superview = MAS_VIEW.new;
     [superview addSubview:view];
     [superview addSubview:view];
+});
+
+it(@"should complete children", ^{
     NSArray *children = @[
     NSArray *children = @[
         [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_width],
         [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_width],
         [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_height]
         [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_height]
     ];
     ];
     composite = [[MASCompositeConstraint alloc] initWithChildren:children];
     composite = [[MASCompositeConstraint alloc] initWithChildren:children];
     composite.delegate = delegate;
     composite.delegate = delegate;
-});
-
-it(@"should complete children", ^{
+    
     MAS_VIEW *newView = MAS_VIEW.new;
     MAS_VIEW *newView = MAS_VIEW.new;
 
 
     //first equality statement
     //first equality statement
-    composite.equalTo(newView).sizeOffset(CGSizeMake(90, 30)).priorityLow();
+    composite.greaterThanOrEqualTo(newView).sizeOffset(CGSizeMake(90, 30)).multipliedBy(3).priorityLow();
     
     
     expect(composite.childConstraints).to.haveCountOf(2);
     expect(composite.childConstraints).to.haveCountOf(2);
 
 
-    MASViewConstraint *viewConstraint = [composite.childConstraints objectAtIndex:0];
+    MASViewConstraint *viewConstraint = composite.childConstraints[0];
     expect(viewConstraint.secondViewAttribute.view).to.beIdenticalTo(newView);
     expect(viewConstraint.secondViewAttribute.view).to.beIdenticalTo(newView);
     expect(viewConstraint.secondViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeWidth);
     expect(viewConstraint.secondViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeWidth);
     expect(viewConstraint.layoutConstant).to.equal(90);
     expect(viewConstraint.layoutConstant).to.equal(90);
     expect(viewConstraint.layoutPriority).to.equal(MASLayoutPriorityDefaultLow);
     expect(viewConstraint.layoutPriority).to.equal(MASLayoutPriorityDefaultLow);
 
 
-    viewConstraint = [composite.childConstraints objectAtIndex:1];
+    viewConstraint = composite.childConstraints[1];
     expect(viewConstraint.secondViewAttribute.view).to.beIdenticalTo(newView);
     expect(viewConstraint.secondViewAttribute.view).to.beIdenticalTo(newView);
     expect(viewConstraint.secondViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeHeight);
     expect(viewConstraint.secondViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeHeight);
     expect(viewConstraint.layoutConstant).to.equal(30);
     expect(viewConstraint.layoutConstant).to.equal(30);
@@ -67,25 +69,68 @@ it(@"should complete children", ^{
 });
 });
 
 
 it(@"should not remove on install", ^{
 it(@"should not remove on install", ^{
+    NSArray *children = @[
+        [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_centerX],
+        [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_centerY]
+    ];
+    composite = [[MASCompositeConstraint alloc] initWithChildren:children];
+    composite.delegate = delegate;
     MAS_VIEW *newView = MAS_VIEW.new;
     MAS_VIEW *newView = MAS_VIEW.new;
     [superview addSubview:newView];
     [superview addSubview:newView];
 
 
     //first equality statement
     //first equality statement
-    composite.equalTo(newView).sizeOffset(CGSizeMake(90, 30));
-
+    composite.equalTo(newView).centerOffset(CGPointMake(90, 30)).dividedBy(2).priorityHigh();
     [composite install];
     [composite install];
 
 
     expect(composite.childConstraints).to.haveCountOf(2);
     expect(composite.childConstraints).to.haveCountOf(2);
+    
+    MASViewConstraint *viewConstraint = composite.childConstraints[0];
+    expect([viewConstraint layoutConstant]).to.equal(90);
+    expect([viewConstraint layoutMultiplier]).to.equal(0.5);
+    expect([viewConstraint layoutPriority]).to.equal(MASLayoutPriorityDefaultHigh);
+
+    viewConstraint = composite.childConstraints[1];
+    expect([viewConstraint layoutConstant]).to.equal(30);
+    expect([viewConstraint layoutMultiplier]).to.equal(0.5);
+    expect([viewConstraint layoutPriority]).to.equal(MASLayoutPriorityDefaultHigh);
 });
 });
 
 
 it(@"should spawn child composite constraints", ^{
 it(@"should spawn child composite constraints", ^{
+    NSArray *children = @[
+        [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_width],
+        [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_height]
+    ];
+    composite = [[MASCompositeConstraint alloc] initWithChildren:children];
+    composite.delegate = delegate;
     MAS_VIEW *otherView = MAS_VIEW.new;
     MAS_VIEW *otherView = MAS_VIEW.new;
     [superview addSubview:otherView];
     [superview addSubview:otherView];
     composite.lessThanOrEqualTo(@[@2, otherView]);
     composite.lessThanOrEqualTo(@[@2, otherView]);
 
 
     expect(composite.childConstraints).to.haveCountOf(2);
     expect(composite.childConstraints).to.haveCountOf(2);
-    expect([composite.childConstraints objectAtIndex:0]).to.beKindOf(MASCompositeConstraint.class);
-    expect([composite.childConstraints objectAtIndex:1]).to.beKindOf(MASCompositeConstraint.class);
+    expect(composite.childConstraints[0]).to.beKindOf(MASCompositeConstraint.class);
+    expect(composite.childConstraints[1]).to.beKindOf(MASCompositeConstraint.class);
+});
+
+it(@"should modify insets on appropriate children", ^{
+    NSArray *children = @[
+        [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_right],
+        [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_top],
+        [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_bottom],
+        [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_left],
+        [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_baseline],
+        [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_width],
+    ];
+    composite = [[MASCompositeConstraint alloc] initWithChildren:children];
+    composite.delegate = delegate;
+
+    composite.with.insets((MASEdgeInsets){1, 2, 3, 4});
+
+    expect([children[0] layoutConstant]).to.equal(-4);
+    expect([children[1] layoutConstant]).to.equal(1);
+    expect([children[2] layoutConstant]).to.equal(-3);
+    expect([children[3] layoutConstant]).to.equal(2);
+    expect([children[4] layoutConstant]).to.equal(0);
+    expect([children[5] layoutConstant]).to.equal(0);
 });
 });
 
 
 SpecEnd
 SpecEnd

+ 8 - 8
MasonryTests/MASConstraintMakerSpec.m

@@ -44,11 +44,11 @@ it(@"should create centerY and centerX children", ^{
 
 
     expect(composite.childConstraints).to.haveCountOf(2);
     expect(composite.childConstraints).to.haveCountOf(2);
 
 
-    MASViewConstraint *viewConstraint = [composite.childConstraints objectAtIndex:0];
+    MASViewConstraint *viewConstraint = composite.childConstraints[0];
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeCenterX);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeCenterX);
 
 
-    viewConstraint = [composite.childConstraints objectAtIndex:1];
+    viewConstraint = composite.childConstraints[1];
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeCenterY);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeCenterY);
 });
 });
@@ -61,22 +61,22 @@ it(@"should create top, left, bottom, right children", ^{
     expect(composite.childConstraints).to.haveCountOf(4);
     expect(composite.childConstraints).to.haveCountOf(4);
 
 
     //top
     //top
-    MASViewConstraint *viewConstraint = [composite.childConstraints objectAtIndex:0];
+    MASViewConstraint *viewConstraint = composite.childConstraints[0];
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeTop);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeTop);
 
 
     //left
     //left
-    viewConstraint = [composite.childConstraints objectAtIndex:1];
+    viewConstraint = composite.childConstraints[1];
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeLeft);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeLeft);
 
 
     //bottom
     //bottom
-    viewConstraint = [composite.childConstraints objectAtIndex:2];
+    viewConstraint = composite.childConstraints[2];
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeBottom);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeBottom);
 
 
     //right
     //right
-    viewConstraint = [composite.childConstraints objectAtIndex:3];
+    viewConstraint = composite.childConstraints[3];
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeRight);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeRight);
 });
 });
@@ -85,11 +85,11 @@ it(@"should create width and height children", ^{
     composite = maker.size;
     composite = maker.size;
     expect(composite.childConstraints).to.haveCountOf(2);
     expect(composite.childConstraints).to.haveCountOf(2);
 
 
-    MASViewConstraint *viewConstraint = [composite.childConstraints objectAtIndex:0];
+    MASViewConstraint *viewConstraint = composite.childConstraints[0];
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeWidth);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeWidth);
 
 
-    viewConstraint = [composite.childConstraints objectAtIndex:1];
+    viewConstraint = composite.childConstraints[1];
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.view).to.beIdenticalTo(maker.view);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeHeight);
     expect(viewConstraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeHeight);
 });
 });

+ 91 - 8
MasonryTests/MASViewConstraintSpec.m

@@ -122,10 +122,10 @@ describe(@"create equality constraint", ^{
         MASCompositeConstraint *composite = (id)constraint.equalTo(views).priorityMedium().offset(-10);
         MASCompositeConstraint *composite = (id)constraint.equalTo(views).priorityMedium().offset(-10);
 
 
         expect(delegate.constraints).to.haveCountOf(1);
         expect(delegate.constraints).to.haveCountOf(1);
-        expect([delegate.constraints objectAtIndex:0]).to.beKindOf(MASCompositeConstraint.class);
+        expect(delegate.constraints[0]).to.beKindOf(MASCompositeConstraint.class);
         for (MASViewConstraint *constraint in composite.childConstraints) {
         for (MASViewConstraint *constraint in composite.childConstraints) {
             NSUInteger index = [composite.childConstraints indexOfObject:constraint];
             NSUInteger index = [composite.childConstraints indexOfObject:constraint];
-            expect(constraint.secondViewAttribute.view).to.beIdenticalTo((MAS_VIEW *)[views objectAtIndex:index]);
+            expect(constraint.secondViewAttribute.view).to.beIdenticalTo((MAS_VIEW *)views[index]);
             expect(constraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeWidth);
             expect(constraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeWidth);
             expect(constraint.secondViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeWidth);
             expect(constraint.secondViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeWidth);
             expect(constraint.layoutPriority).to.equal(MASLayoutPriorityDefaultMedium);
             expect(constraint.layoutPriority).to.equal(MASLayoutPriorityDefaultMedium);
@@ -140,16 +140,50 @@ describe(@"create equality constraint", ^{
         MASCompositeConstraint *composite = (id)constraint.equalTo(viewAttributes).priority(60).offset(10);
         MASCompositeConstraint *composite = (id)constraint.equalTo(viewAttributes).priority(60).offset(10);
 
 
         expect(delegate.constraints).to.haveCountOf(1);
         expect(delegate.constraints).to.haveCountOf(1);
-        expect([delegate.constraints objectAtIndex:0]).to.beKindOf(MASCompositeConstraint.class);
+        expect(delegate.constraints[0]).to.beKindOf(MASCompositeConstraint.class);
         for (MASViewConstraint *constraint in composite.childConstraints) {
         for (MASViewConstraint *constraint in composite.childConstraints) {
             NSUInteger index = [composite.childConstraints indexOfObject:constraint];
             NSUInteger index = [composite.childConstraints indexOfObject:constraint];
-            expect(constraint.secondViewAttribute.view).to.beIdenticalTo([[viewAttributes objectAtIndex:index] view]);
+            expect(constraint.secondViewAttribute.view).to.beIdenticalTo([viewAttributes[index] view]);
             expect(constraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeWidth);
             expect(constraint.firstViewAttribute.layoutAttribute).to.equal(NSLayoutAttributeWidth);
-            expect(constraint.secondViewAttribute.layoutAttribute).to.equal([[viewAttributes objectAtIndex:index] layoutAttribute]);
+            expect(constraint.secondViewAttribute.layoutAttribute).to.equal([viewAttributes[index] layoutAttribute]);
             expect(constraint.layoutPriority).to.equal(60);
             expect(constraint.layoutPriority).to.equal(60);
             expect(constraint.layoutConstant).to.equal(10);
             expect(constraint.layoutConstant).to.equal(10);
         }
         }
     });
     });
+
+    it(@"should complain when using unnsupported equality argument", ^{
+        expect(^{
+            constraint.equalTo(@{});
+        }).to.raise(@"NSInternalInconsistencyException");
+    });
+});
+
+describe(@"prioritise", ^{
+
+    it(@"should set priorityHigh", ^{
+        constraint.equalTo(otherView);
+        constraint.with.priorityHigh();
+        [constraint install];
+
+        expect(constraint.layoutPriority).to.equal(MASLayoutPriorityDefaultHigh);
+        expect(constraint.layoutConstraint.priority).to.equal(MASLayoutPriorityDefaultHigh);
+    });
+    it(@"should set priorityLow", ^{
+        constraint.equalTo(otherView);
+        constraint.with.priorityLow();
+        [constraint install];
+
+        expect(constraint.layoutPriority).to.equal(MASLayoutPriorityDefaultLow);
+        expect(constraint.layoutConstraint.priority).to.equal(MASLayoutPriorityDefaultLow);
+    });
+    it(@"should set priorityMedium", ^{
+        constraint.equalTo(otherView);
+        constraint.with.priorityMedium();
+        [constraint install];
+
+        expect(constraint.layoutPriority).to.equal(MASLayoutPriorityDefaultMedium);
+        expect(constraint.layoutConstraint.priority).to.equal(MASLayoutPriorityDefaultMedium);
+    });
 });
 });
 
 
 describe(@"multiplier & constant", ^{
 describe(@"multiplier & constant", ^{
@@ -161,6 +195,24 @@ describe(@"multiplier & constant", ^{
             constraint.multipliedBy(0.9);
             constraint.multipliedBy(0.9);
         }).to.raise(@"NSInternalInconsistencyException");
         }).to.raise(@"NSInternalInconsistencyException");
     });
     });
+
+    it(@"should set multipler with multipliedBy", ^{
+        constraint.equalTo(otherView);
+        constraint.multipliedBy(5);
+        [constraint install];
+
+        expect(constraint.layoutMultiplier).to.equal(5);
+        expect(constraint.layoutConstraint.multiplier).to.equal(5);
+    });
+
+    it(@"should set multipler with dividedBy", ^{
+        constraint.equalTo(otherView);
+        constraint.dividedBy(10);
+        [constraint install];
+
+        expect(constraint.layoutMultiplier).to.equal(0.1);
+        expect(constraint.layoutConstraint.multiplier).to.beCloseTo(0.1);
+    });
     
     
     it(@"should allow update of constant after layoutconstraint is created", ^{
     it(@"should allow update of constant after layoutconstraint is created", ^{
         [constraint install];
         [constraint install];
@@ -172,7 +224,7 @@ describe(@"multiplier & constant", ^{
     
     
     it(@"should update sides offset only", ^{
     it(@"should update sides offset only", ^{
         MASViewConstraint *centerY = [[MASViewConstraint alloc] initWithFirstViewAttribute:otherView.mas_centerY];
         MASViewConstraint *centerY = [[MASViewConstraint alloc] initWithFirstViewAttribute:otherView.mas_centerY];
-        centerY.insets((MASEdgeInsets){10, 10, 10, 10});
+        centerY.with.insets((MASEdgeInsets){10, 10, 10, 10});
         expect(centerY.layoutConstant).to.equal(0);
         expect(centerY.layoutConstant).to.equal(0);
 
 
         MASViewConstraint *top = [[MASViewConstraint alloc] initWithFirstViewAttribute:otherView.mas_top];
         MASViewConstraint *top = [[MASViewConstraint alloc] initWithFirstViewAttribute:otherView.mas_top];
@@ -240,7 +292,38 @@ describe(@"install", ^{
         expect(constraint.layoutConstraint.priority).to.equal(345);
         expect(constraint.layoutConstraint.priority).to.equal(345);
         expect(constraint.layoutConstraint.multiplier).to.equal(0.5);
         expect(constraint.layoutConstraint.multiplier).to.equal(0.5);
 
 
-        expect([superview.constraints objectAtIndex:0]).to.beIdenticalTo(constraint.layoutConstraint);
+        expect(superview.constraints[0]).to.beIdenticalTo(constraint.layoutConstraint);
+    });
+
+    it(@"alignment should be relative to superview", ^{
+        MAS_VIEW *view = MAS_VIEW.new;
+        constraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:view.mas_baseline];
+        constraint.delegate = delegate;
+        [superview addSubview:view];
+        
+        constraint.equalTo(@10);
+        [constraint install];
+
+        expect(constraint.layoutConstraint.firstAttribute).to.equal(NSLayoutAttributeBaseline);
+        expect(constraint.layoutConstraint.secondAttribute).to.equal(NSLayoutAttributeBaseline);
+        expect(constraint.layoutConstraint.firstItem).to.beIdenticalTo(constraint.firstViewAttribute.view);
+        expect(constraint.layoutConstraint.secondItem).to.beIdenticalTo(superview);
+        expect(constraint.layoutConstraint.relation).to.equal(NSLayoutRelationEqual);
+        expect(constraint.layoutConstraint.constant).to.equal(10);
+        expect(superview.constraints[0]).to.beIdenticalTo(constraint.layoutConstraint);
+    });
+
+    it(@"size should be constant", ^{
+        constraint.equalTo(@10);
+        [constraint install];
+
+        expect(constraint.layoutConstraint.firstAttribute).to.equal(NSLayoutAttributeWidth);
+        expect(constraint.layoutConstraint.secondAttribute).to.equal(NSLayoutAttributeNotAnAttribute);
+        expect(constraint.layoutConstraint.firstItem).to.beIdenticalTo(constraint.firstViewAttribute.view);
+        expect(constraint.layoutConstraint.secondItem).to.beNil();
+        expect(constraint.layoutConstraint.relation).to.equal(NSLayoutRelationEqual);
+        expect(constraint.layoutConstraint.constant).to.equal(10);
+        expect(constraint.firstViewAttribute.view.constraints[0]).to.beIdenticalTo(constraint.layoutConstraint);
     });
     });
 
 
     it(@"should uninstall constraint", ^{
     it(@"should uninstall constraint", ^{
@@ -249,7 +332,7 @@ describe(@"install", ^{
         [constraint install];
         [constraint install];
 
 
         expect(superview.constraints).to.haveCountOf(1);
         expect(superview.constraints).to.haveCountOf(1);
-        expect([superview.constraints objectAtIndex:0]).to.equal(constraint.layoutConstraint);
+        expect(superview.constraints[0]).to.equal(constraint.layoutConstraint);
 
 
         [constraint uninstall];
         [constraint uninstall];
         expect(superview.constraints).to.haveCountOf(0);
         expect(superview.constraints).to.haveCountOf(0);

+ 4 - 0
MasonryTests/MasonryTests-Prefix.pch

@@ -11,4 +11,8 @@
     #import "Expecta.h"
     #import "Expecta.h"
 
 
     #import "MASUtilities.h"
     #import "MASUtilities.h"
+
+    #if __MAC_OS_X_VERSION_MAX_ALLOWED <= 1070
+    #import "NSObject+MASSubscriptSupport.h"
+    #endif
 #endif
 #endif

+ 18 - 0
MasonryTests/NSObject+MASSubscriptSupport.h

@@ -0,0 +1,18 @@
+//
+//  NSObject+MASSubscriptSupport.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 28/08/13.
+//  Copyright (c) 2013 Jonas Budelmann. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface NSObject (MASSubscriptSupport)
+
+- (id)objectAtIndexedSubscript:(NSUInteger)idx;
+- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
+- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
+- (id)objectForKeyedSubscript:(id)key;
+
+@end