@@ -15,44 +15,69 @@ import Tentacle
1515
1616class ProjectSpec : QuickSpec {
1717 override func spec( ) {
18- let directoryURL = NSBundle ( forClass: self . dynamicType) . URLForResource ( " CartfilePrivateOnly " , withExtension: nil ) !
18+ describe ( " loadCombinedCartfile " ) {
19+ it ( " should load a combined Cartfile when only a Cartfile is present " ) {
20+ let directoryURL = NSBundle ( forClass: self . dynamicType) . URLForResource ( " CartfileOnly " , withExtension: nil ) !
21+ let result = Project ( directoryURL: directoryURL) . loadCombinedCartfile ( ) . single ( )
22+ expect ( result) . notTo ( beNil ( ) )
23+ expect ( result? . value) . notTo ( beNil ( ) )
24+
25+ let dependencies = result? . value? . dependencies
26+ expect ( dependencies? . count) == 1
27+ expect ( dependencies? . first? . project. name) == " Carthage "
28+ }
1929
20- it ( " should load a combined Cartfile when only a Cartfile.private is present " ) {
21- let result = Project ( directoryURL: directoryURL) . loadCombinedCartfile ( ) . single ( )
22- expect ( result) . notTo ( beNil ( ) )
23- expect ( result? . value) . notTo ( beNil ( ) )
30+ it ( " should load a combined Cartfile when only a Cartfile.private is present " ) {
31+ let directoryURL = NSBundle ( forClass: self . dynamicType) . URLForResource ( " CartfilePrivateOnly " , withExtension: nil ) !
32+ let result = Project ( directoryURL: directoryURL) . loadCombinedCartfile ( ) . single ( )
33+ expect ( result) . notTo ( beNil ( ) )
34+ expect ( result? . value) . notTo ( beNil ( ) )
2435
25- let dependencies = result? . value? . dependencies
26- expect ( dependencies? . count) == 1
27- expect ( dependencies? . first? . project. name) == " Carthage "
28- }
36+ let dependencies = result? . value? . dependencies
37+ expect ( dependencies? . count) == 1
38+ expect ( dependencies? . first? . project. name) == " Carthage "
39+ }
2940
30- it ( " should detect duplicate dependencies across Cartfile and Cartfile.private " ) {
31- let directoryURL = NSBundle ( forClass: self . dynamicType) . URLForResource ( " DuplicateDependencies " , withExtension: nil ) !
32- let result = Project ( directoryURL: directoryURL) . loadCombinedCartfile ( ) . single ( )
33- expect ( result) . notTo ( beNil ( ) )
41+ it ( " should detect duplicate dependencies across Cartfile and Cartfile.private " ) {
42+ let directoryURL = NSBundle ( forClass: self . dynamicType) . URLForResource ( " DuplicateDependencies " , withExtension: nil ) !
43+ let result = Project ( directoryURL: directoryURL) . loadCombinedCartfile ( ) . single ( )
44+ expect ( result) . notTo ( beNil ( ) )
3445
35- let resultError = result? . error
36- expect ( resultError) . notTo ( beNil ( ) )
46+ let resultError = result? . error
47+ expect ( resultError) . notTo ( beNil ( ) )
3748
38- let makeDependency : ( String , String , [ String ] ) -> DuplicateDependency = { ( repoOwner, repoName, locations) in
39- let project = ProjectIdentifier . GitHub ( Repository ( owner: repoOwner, name: repoName) )
40- return DuplicateDependency ( project: project, locations: locations)
41- }
49+ let makeDependency : ( String , String , [ String ] ) -> DuplicateDependency = { ( repoOwner, repoName, locations) in
50+ let project = ProjectIdentifier . GitHub ( Repository ( owner: repoOwner, name: repoName) )
51+ return DuplicateDependency ( project: project, locations: locations)
52+ }
4253
43- let mainLocation = [ " \( CarthageProjectCartfilePath) " ]
44- let bothLocations = [ " \( CarthageProjectCartfilePath) " , " \( CarthageProjectPrivateCartfilePath) " ]
54+ let mainLocation = [ " \( CarthageProjectCartfilePath) " ]
55+ let bothLocations = [ " \( CarthageProjectCartfilePath) " , " \( CarthageProjectPrivateCartfilePath) " ]
4556
46- let expectedError = CarthageError . DuplicateDependencies ( [
47- makeDependency ( " self2 " , " self2 " , mainLocation) ,
48- makeDependency ( " self3 " , " self3 " , mainLocation) ,
49- makeDependency ( " 1 " , " 1 " , bothLocations) ,
50- makeDependency ( " 3 " , " 3 " , bothLocations) ,
51- makeDependency ( " 5 " , " 5 " , bothLocations) ,
52- ] )
57+ let expectedError = CarthageError . DuplicateDependencies ( [
58+ makeDependency ( " self2 " , " self2 " , mainLocation) ,
59+ makeDependency ( " self3 " , " self3 " , mainLocation) ,
60+ makeDependency ( " 1 " , " 1 " , bothLocations) ,
61+ makeDependency ( " 3 " , " 3 " , bothLocations) ,
62+ makeDependency ( " 5 " , " 5 " , bothLocations) ,
63+ ] )
5364
54- expect ( resultError) == expectedError
55- }
65+ expect ( resultError) == expectedError
66+ }
67+
68+ it ( " should error when neither a Cartfile nor a Cartfile.private exists " ) {
69+ let directoryURL = NSBundle ( forClass: self . dynamicType) . URLForResource ( " NoCartfile " , withExtension: nil ) !
70+ let result = Project ( directoryURL: directoryURL) . loadCombinedCartfile ( ) . single ( )
71+ expect ( result) . notTo ( beNil ( ) )
72+
73+ if case let . ReadFailed( _, underlyingError) ? = result? . error {
74+ expect ( underlyingError? . domain) == NSCocoaErrorDomain
75+ expect ( underlyingError? . code) == NSFileReadNoSuchFileError
76+ } else {
77+ fail ( )
78+ }
79+ }
80+ }
5681
5782 describe ( " cloneOrFetchProject " ) {
5883 // https://github.com/Carthage/Carthage/issues/1191
0 commit comments