Sha256: 671dabd2b1ff094d19a1709f812975f475089c8c742db96e0da1528454c2935a

Contents?: true

Size: 1.67 KB

Versions: 4

Compression:

Stored size: 1.67 KB

Contents

//
//  NSStringTests.m
//  SampleProject
//
//  Created by Neil on 05/12/2012.
//  Copyright (c) 2012 @mneorr | mneorr.com. All rights reserved.
//

#import "Kiwi.h"
#import "ObjectiveSugar.h"

SPEC_BEGIN(StringAdditions)

describe(@"Foundation-style functions", ^{

    it(@"NSStringWithFormat makes NSString -stringWithFormat", ^{

        [[NSStringWithFormat(@"This is %@", @1) should] equal:@"This is 1"];
    });

});

describe(@"Additions", ^{

    NSString *sentence = @"Jane Doe's going    in a shop,and,yeah;";

    it(@"-split splits by whitespace", ^{
        [[[@" the\r\nquick brown\t \tfox\n" split] should] equal:@[@"the", @"quick", @"brown", @"fox"]];
    });

    it(@"-split: splits with given delimiter", ^{
        [[[sentence split:@","] should] equal:@[@"Jane Doe's going    in a shop", @"and", @"yeah;"]];
    });

    it(@"-split: splits with delimiter string, not just a char", ^{
        [[[@"one / two / three" split:@" / "] should] equal:@[@"one", @"two", @"three"]];
    });

    it(@"contains string", ^{
        [[@([sentence containsString:@"jane doe"]) should] beTrue];
    });

    context(@"CamelCase and snake_case", ^{

        it(@"converts snake_cased to CamelCased", ^{
            [[[@"snake_case" camelCase] should] equal:@"SnakeCase"];
        });

        it(@"handles correctly snake case on beginning and at the end", ^{
            [[[@"_snake_case" camelCase] should] equal:@"SnakeCase"];
            [[[@"snake_case_" camelCase] should] equal:@"SnakeCase"];
        });

    });

    it(@"-strip strips whitespaces and newlines from both ends", ^{
        [[[@"  Look mo, no empties!   " strip] should] equal:@"Look mo, no empties!"];
    });

});



SPEC_END

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
learn-xcpretty-0.1.12 spec/fixtures/NSStringTests.m
learn-xcpretty-0.1.11 spec/fixtures/NSStringTests.m
xcpretty-0.1.7 spec/fixtures/NSStringTests.m
xcpretty-0.1.6 spec/fixtures/NSStringTests.m