Latest 0.1.0
Homepage https://github.com/otaviocc/OCExpectaMatchers
License MIT
Platforms ios 7.0, requires ARC
Dependencies Expecta
Authors

My personal collection of Expecta matchers. Install OCExpectaMatchers using CocoaPods by adding it to your Podfile:

target :AppTests do
    pod 'Specta', '1.0'
    pod 'Expecta', '1.0'
    pod 'OCExpectaMatchers', '0.1'
end

NSLayoutConstraint

Import the following header file

#import <OCExpectaMatchers/EXPMatchers+NSLayoutConstraint.h>

to have access to these matchers:

  • equalConstraint()
  • containConstraint()

.equalConstraint()

Tests NSLayoutConstraint equality.

describe(@".equalConstraint", ^{
    it(@"tests if two constraints are equal", ^{
        expect(testConstraint1).to.equalConstraint(testConstraint1);
    });

    it(@"tests if two constraints are different", ^{
        expect(testConstraint1).toNot.equalConstraint(testConstraint2);
    });
});

.containConstraint()

Tests if a NSArray containts a NSLayoutConstraint.

describe(@"FancyCell", ^{
    __block FancyCell *cell;

    beforeEach(^{
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FancyCell" owner:nil options:nil];
        cell = (FancyCell *) nib.firstObject;
    });

    describe(@"constraints", ^{
        describe(@"grayView", ^{
            it(@"has 1 constraint", ^{
                expect(cell.grayView.constraints.count).to.equal(1);
            });

            it(@"has the correct values for grayView (NSLayoutAttributeWidth) - grayView (NSLayoutAttributeHeight)", ^{
                NSLayoutConstraint *testConstraint = [NSLayoutConstraint constraintWithItem:cell.grayView
                                                                                  attribute:NSLayoutAttributeWidth
                                                                                  relatedBy:NSLayoutRelationEqual
                                                                                     toItem:cell.grayView
                                                                                  attribute:NSLayoutAttributeHeight
                                                                                 multiplier:1
                                                                                   constant:0];
                expect(cell.grayView.constraints).to.containConstraint(testConstraint);
            });
        });
    });
});

Latest podspec

{
    "name": "OCExpectaMatchers",
    "version": "0.1.0",
    "summary": "Personal collection of Expecta matchers.",
    "description": "OCExpectaMatchers is my personal collection of Expecta matchers.",
    "homepage": "https://github.com/otaviocc/OCExpectaMatchers",
    "license": "MIT",
    "authors": {
        "Otavio Cordeiro": "[email protected]"
    },
    "source": {
        "git": "https://github.com/otaviocc/OCExpectaMatchers.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/otaviocc",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "OCExpectaMatchersTests/EXPMatchers*",
    "dependencies": {
        "Expecta": []
    }
}

Pin It on Pinterest

Share This