|
542 | 542 | });
|
543 | 543 | });
|
544 | 544 |
|
| 545 | +describe(@"-userSignatureForNow", ^{ |
| 546 | + static NSString * const userName = @"johnsmith"; |
| 547 | + static NSString * const email = @"[email protected]"; |
| 548 | + |
| 549 | + __block GTConfiguration *configuration; |
| 550 | + |
| 551 | + beforeEach(^{ |
| 552 | + configuration = [repository configurationWithError:NULL]; |
| 553 | + expect(configuration).notTo(beNil()); |
| 554 | + }); |
| 555 | + |
| 556 | + it(@"should use the values from the config", ^{ |
| 557 | + [configuration setString:userName forKey:@"user.name"]; |
| 558 | + [configuration setString:email forKey:@"user.email"]; |
| 559 | + |
| 560 | + GTSignature *signature = [repository userSignatureForNow]; |
| 561 | + expect(signature.name).to(equal(userName)); |
| 562 | + expect(signature.email).to(equal(email)); |
| 563 | + }); |
| 564 | + |
| 565 | + describe(@"invalid values", ^{ |
| 566 | + it(@"should use a default value if the name is empty", ^{ |
| 567 | + [configuration setString:@"" forKey:@"user.name"]; |
| 568 | + [configuration setString:email forKey:@"user.email"]; |
| 569 | + |
| 570 | + GTSignature *signature = [repository userSignatureForNow]; |
| 571 | + expect(@(signature.name.length)).to(beGreaterThan(@0)); |
| 572 | + expect(@(signature.email.length)).to(beGreaterThan(@0)); |
| 573 | + }); |
| 574 | + |
| 575 | + it(@"should use a default value if the email is empty", ^{ |
| 576 | + [configuration setString:userName forKey:@"user.name"]; |
| 577 | + [configuration setString:@"" forKey:@"user.email"]; |
| 578 | + |
| 579 | + GTSignature *signature = [repository userSignatureForNow]; |
| 580 | + expect(@(signature.name.length)).to(beGreaterThan(@0)); |
| 581 | + expect(@(signature.email.length)).to(beGreaterThan(@0)); |
| 582 | + }); |
| 583 | + |
| 584 | + it(@"should use a default value if the email contains angled brackets", ^{ |
| 585 | + [configuration setString:userName forKey:@"user.name"]; |
| 586 | + [configuration setString:@"<[email protected]>" forKey:@"user.email"]; |
| 587 | + |
| 588 | + GTSignature *signature = [repository userSignatureForNow]; |
| 589 | + expect(@(signature.name.length)).to(beGreaterThan(@0)); |
| 590 | + expect(@(signature.email.length)).to(beGreaterThan(@0)); |
| 591 | + }); |
| 592 | + }); |
| 593 | +}); |
| 594 | + |
545 | 595 | afterEach(^{
|
546 | 596 | [self tearDown];
|
547 | 597 | });
|
|
0 commit comments