|
19 | 19 | }); |
20 | 20 |
|
21 | 21 | describe(@"+initializeEmptyRepositoryAtFileURL:bare:error:", ^{ |
22 | | - __block GTRepository * (^createRepository)(BOOL bare); |
23 | | - |
24 | | - beforeEach(^{ |
25 | | - createRepository = ^(BOOL bare) { |
26 | | - NSURL *newRepoURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"unit_test"]]; |
27 | | - [NSFileManager.defaultManager removeItemAtURL:newRepoURL error:NULL]; |
28 | | - |
29 | | - GTRepository *repository = [GTRepository initializeEmptyRepositoryAtFileURL:newRepoURL bare:bare error:NULL]; |
30 | | - expect(repository).notTo.beNil(); |
31 | | - expect(repository.gitDirectoryURL).notTo.beNil(); |
32 | | - return repository; |
33 | | - }; |
34 | | - }); |
35 | | - |
36 | 22 | it(@"should initialize a repository with a working directory by default", ^{ |
37 | | - GTRepository *repository = createRepository(NO); |
| 23 | + NSURL *newRepoURL = [self.tempDirectoryFileURL URLByAppendingPathComponent:@"init-repo"]; |
| 24 | + |
| 25 | + GTRepository *repository = [GTRepository initializeEmptyRepositoryAtFileURL:newRepoURL bare:NO error:NULL]; |
| 26 | + expect(repository).notTo.beNil(); |
| 27 | + expect(repository.gitDirectoryURL).notTo.beNil(); |
38 | 28 | expect(repository.bare).to.beFalsy(); |
39 | 29 | }); |
40 | 30 |
|
41 | 31 | it(@"should initialize a bare repository", ^{ |
42 | | - GTRepository *repository = createRepository(YES); |
| 32 | + NSURL *newRepoURL = [self.tempDirectoryFileURL URLByAppendingPathComponent:@"init-repo.git"]; |
| 33 | + |
| 34 | + GTRepository *repository = [GTRepository initializeEmptyRepositoryAtFileURL:newRepoURL bare:YES error:NULL]; |
| 35 | + expect(repository).notTo.beNil(); |
| 36 | + expect(repository.gitDirectoryURL).notTo.beNil(); |
| 37 | + return repository; |
43 | 38 | expect(repository.bare).to.beTruthy(); |
44 | 39 | }); |
45 | 40 | }); |
|
79 | 74 | workdirURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"unit_test"]]; |
80 | 75 | }); |
81 | 76 |
|
82 | | - afterEach(^{ |
83 | | - if ([NSFileManager.defaultManager fileExistsAtPath:workdirURL.path isDirectory:NULL]) { |
84 | | - NSError *error = nil; |
85 | | - BOOL success = [NSFileManager.defaultManager removeItemAtURL:workdirURL error:&error]; |
86 | | - expect(success).to.beTruthy(); |
87 | | - expect(error).to.beNil(); |
88 | | - } |
89 | | - }); |
90 | | - |
91 | 77 | it(@"should handle normal clones", ^{ |
92 | 78 | NSError *error = nil; |
93 | 79 | repository = [GTRepository cloneFromURL:originURL toWorkingDirectory:workdirURL options:nil error:&error transferProgressBlock:transferProgressBlock checkoutProgressBlock:checkoutProgressBlock]; |
|
0 commit comments