Skip to content
This repository was archived by the owner on Jan 24, 2019. It is now read-only.

Commit bc63bd6

Browse files
committed
Merge branch 'release/0.1.0'
2 parents 4c48b6e + f685d75 commit bc63bd6

70 files changed

Lines changed: 2686 additions & 10 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
# OS X
2+
.DS_Store
3+
14
# Xcode
2-
#
35
build/
46
*.pbxuser
57
!default.pbxuser
@@ -17,10 +19,8 @@ DerivedData
1719
*.ipa
1820
*.xcuserstate
1921

20-
# CocoaPods
21-
#
22-
# We recommend against adding the Pods directory to your .gitignore. However
23-
# you should judge for yourself, the pros and cons are mentioned at:
24-
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25-
#
26-
#Pods/
22+
# AppCode
23+
.idea/
24+
25+
# CocoaPods
26+
Pods/

Example/OrangeFramework.xcodeproj/project.pbxproj

Lines changed: 393 additions & 0 deletions
Large diffs are not rendered by default.

Example/OrangeFramework.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0720"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
18+
BuildableName = "OrangeFramework_Example.app"
19+
BlueprintName = "OrangeFramework_Example"
20+
ReferencedContainer = "container:OrangeFramework.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
<BuildActionEntry
24+
buildForTesting = "YES"
25+
buildForRunning = "YES"
26+
buildForProfiling = "NO"
27+
buildForArchiving = "NO"
28+
buildForAnalyzing = "YES">
29+
<BuildableReference
30+
BuildableIdentifier = "primary"
31+
BlueprintIdentifier = "607FACE41AFB9204008FA782"
32+
BuildableName = "OrangeFramework_Specs.xctest"
33+
BlueprintName = "OrangeFramework_Specs"
34+
ReferencedContainer = "container:OrangeFramework.xcodeproj">
35+
</BuildableReference>
36+
</BuildActionEntry>
37+
</BuildActionEntries>
38+
</BuildAction>
39+
<TestAction
40+
buildConfiguration = "Debug"
41+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
42+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
shouldUseLaunchSchemeArgsEnv = "YES">
44+
<Testables>
45+
<TestableReference
46+
skipped = "NO">
47+
<BuildableReference
48+
BuildableIdentifier = "primary"
49+
BlueprintIdentifier = "607FACE41AFB9204008FA782"
50+
BuildableName = "OrangeFramework_Specs.xctest"
51+
BlueprintName = "OrangeFramework_Specs"
52+
ReferencedContainer = "container:OrangeFramework.xcodeproj">
53+
</BuildableReference>
54+
</TestableReference>
55+
</Testables>
56+
<MacroExpansion>
57+
<BuildableReference
58+
BuildableIdentifier = "primary"
59+
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
60+
BuildableName = "OrangeFramework_Example.app"
61+
BlueprintName = "OrangeFramework_Example"
62+
ReferencedContainer = "container:OrangeFramework.xcodeproj">
63+
</BuildableReference>
64+
</MacroExpansion>
65+
<AdditionalOptions>
66+
</AdditionalOptions>
67+
</TestAction>
68+
<LaunchAction
69+
buildConfiguration = "Debug"
70+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
71+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
72+
launchStyle = "0"
73+
useCustomWorkingDirectory = "NO"
74+
ignoresPersistentStateOnLaunch = "NO"
75+
debugDocumentVersioning = "YES"
76+
debugServiceExtension = "internal"
77+
allowLocationSimulation = "YES">
78+
<BuildableProductRunnable
79+
runnableDebuggingMode = "0">
80+
<BuildableReference
81+
BuildableIdentifier = "primary"
82+
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
83+
BuildableName = "OrangeFramework_Example.app"
84+
BlueprintName = "OrangeFramework_Example"
85+
ReferencedContainer = "container:OrangeFramework.xcodeproj">
86+
</BuildableReference>
87+
</BuildableProductRunnable>
88+
<AdditionalOptions>
89+
</AdditionalOptions>
90+
</LaunchAction>
91+
<ProfileAction
92+
buildConfiguration = "Release"
93+
shouldUseLaunchSchemeArgsEnv = "YES"
94+
savedToolIdentifier = ""
95+
useCustomWorkingDirectory = "NO"
96+
debugDocumentVersioning = "YES">
97+
<BuildableProductRunnable
98+
runnableDebuggingMode = "0">
99+
<BuildableReference
100+
BuildableIdentifier = "primary"
101+
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
102+
BuildableName = "OrangeFramework_Example.app"
103+
BlueprintName = "OrangeFramework_Example"
104+
ReferencedContainer = "container:OrangeFramework.xcodeproj">
105+
</BuildableReference>
106+
</BuildableProductRunnable>
107+
</ProfileAction>
108+
<AnalyzeAction
109+
buildConfiguration = "Debug">
110+
</AnalyzeAction>
111+
<ArchiveAction
112+
buildConfiguration = "Release"
113+
revealArchiveInOrganizer = "YES">
114+
</ArchiveAction>
115+
</Scheme>

Example/OrangeFramework.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Podfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source 'https://github.com/CocoaPods/Specs.git'
2+
use_frameworks!
3+
4+
target 'OrangeFramework_Specs', :exclusive => true do
5+
pod "OrangeFramework", :path => "../"
6+
7+
pod 'Quick', '~> 0.8.0'
8+
pod 'Nimble', '3.0.0'
9+
end

Example/Podfile.lock

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
PODS:
2+
- Nimble (3.0.0)
3+
- OrangeFramework (0.1.0):
4+
- OrangeFramework/Dependency (= 0.1.0)
5+
- OrangeFramework/Extensions (= 0.1.0)
6+
- OrangeFramework/Log (= 0.1.0)
7+
- OrangeFramework/Segues (= 0.1.0)
8+
- OrangeFramework/SystemInfo (= 0.1.0)
9+
- OrangeFramework/Dependency (0.1.0)
10+
- OrangeFramework/Extensions (0.1.0)
11+
- OrangeFramework/Log (0.1.0)
12+
- OrangeFramework/Segues (0.1.0)
13+
- OrangeFramework/SystemInfo (0.1.0)
14+
- Quick (0.8.0)
15+
16+
DEPENDENCIES:
17+
- Nimble (= 3.0.0)
18+
- OrangeFramework (from `../`)
19+
- Quick (~> 0.8.0)
20+
21+
EXTERNAL SOURCES:
22+
OrangeFramework:
23+
:path: ../
24+
25+
SPEC CHECKSUMS:
26+
Nimble: 4c353d43735b38b545cbb4cb91504588eb5de926
27+
OrangeFramework: 74be818e2371656a4b4e9b80bb76b0aa7a61c369
28+
Quick: 563d0f6ec5f72e394645adb377708639b7dd38ab
29+
30+
COCOAPODS: 0.39.0

Example/Specs/Info.plist

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>BNDL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleSignature</key>
20+
<string>????</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
</dict>
24+
</plist>

Example/Specs/OFDependencySpec.m

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
@import Quick;
2+
@import Nimble;
3+
@import OrangeFramework;
4+
5+
@protocol TestProtocol <NSObject> @end
6+
@interface TestClass : NSObject<TestProtocol> @end
7+
@implementation TestClass @end
8+
9+
QuickSpecBegin(OFDependencySpec)
10+
11+
describe(@"dependency", ^{
12+
13+
describe(@"by key", ^{
14+
NSString *dependencyKey = @"some_key";
15+
context(@"when registered", ^{
16+
context(@"on factory mode", ^{
17+
beforeEach(^{
18+
[OFDependency registerWithKey:dependencyKey mode:OFDependencyModeFactory constructor:^id _Nonnull{
19+
return [NSObject new];
20+
}];
21+
});
22+
it(@"is available", ^{
23+
expect(@([OFDependency availableForKey:dependencyKey])).to(beTrue());
24+
});
25+
it(@"resolve with new instance everytime", ^{
26+
id instance1 = [OFDependency resolveByKey:dependencyKey];
27+
id instance2 = [OFDependency resolveByKey:dependencyKey];
28+
expect(instance1).toNot(beIdenticalTo(instance2));
29+
});
30+
});
31+
context(@"on singleton mode", ^{
32+
beforeEach(^{
33+
[OFDependency registerWithKey:dependencyKey mode:OFDependencyModeSingleton constructor:^id _Nonnull{
34+
return [NSObject new];
35+
}];
36+
});
37+
it(@"is available", ^{
38+
expect(@([OFDependency availableForKey:dependencyKey])).to(beTrue());
39+
});
40+
it(@"resolve with single instance everytime", ^{
41+
__weak id instance1 = [OFDependency resolveByKey:dependencyKey];
42+
id instance2 = [OFDependency resolveByKey:dependencyKey];
43+
expect(instance1).to(beIdenticalTo(instance2));
44+
});
45+
});
46+
context(@"on weak singleton mode", ^{
47+
beforeEach(^{
48+
[OFDependency registerWithKey:dependencyKey mode:OFDependencyModeWeakSingleton constructor:^id _Nonnull{
49+
return [NSObject new];
50+
}];
51+
});
52+
it(@"is available", ^{
53+
expect(@([OFDependency availableForKey:dependencyKey])).to(beTrue());
54+
});
55+
it(@"resolve with last instance if it's not deallocated", ^{
56+
id instance1 = [OFDependency resolveByKey:dependencyKey];
57+
id instance2 = [OFDependency resolveByKey:dependencyKey];
58+
expect(instance1).to(beIdenticalTo(instance2));
59+
});
60+
it(@"resolve with new instance if last instance is deallocated", ^{
61+
__block __weak id instance1;
62+
__block id instance2;
63+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
64+
instance1 = [OFDependency resolveByKey:dependencyKey];
65+
instance2 = [OFDependency resolveByKey:dependencyKey];
66+
});
67+
expect(instance2).toNotEventually(beIdenticalTo(instance1));
68+
});
69+
});
70+
});
71+
context(@"when removed", ^{
72+
beforeEach(^{
73+
[OFDependency registerWithKey:dependencyKey mode:OFDependencyModeFactory constructor:^id _Nonnull{
74+
return [NSObject new];
75+
}];
76+
[OFDependency removeForKey:dependencyKey];
77+
});
78+
it(@"is not available", ^{
79+
expect(@([OFDependency availableForKey:dependencyKey])).to(beFalse());
80+
});
81+
it(@"resolve with exception", ^{
82+
expect([OFDependency resolveByKey:dependencyKey]).to(raiseException());
83+
});
84+
});
85+
});
86+
87+
describe(@"by class", ^{
88+
context(@"when constructor result is kind of registered class", ^{
89+
it(@"resolve", ^{
90+
[OFDependency registerWithClass:[TestClass class] mode:OFDependencyModeFactory constructor:^id _Nonnull{
91+
return [TestClass new];
92+
}];
93+
expect([OFDependency resolveByClass:[TestClass class]]).to(beAKindOf([TestClass class]));
94+
});
95+
});
96+
context(@"when constructor result is NOT kind of registered class", ^{
97+
it(@"resolve with exception", ^{
98+
[OFDependency registerWithClass:[TestClass class] mode:OFDependencyModeFactory constructor:^id _Nonnull{
99+
return [NSString new];
100+
}];
101+
expect([OFDependency resolveByClass:[TestClass class]]).to(raiseException());
102+
});
103+
});
104+
});
105+
106+
describe(@"by protocol", ^{
107+
context(@"when constructor result class conformed to registered protocol", ^{
108+
it(@"resolve", ^{
109+
[OFDependency registerWithProtocol:@protocol(TestProtocol) mode:OFDependencyModeFactory constructor:^id _Nonnull{
110+
return [TestClass new];
111+
}];
112+
expect(@([[OFDependency resolveByProtocol:@protocol(TestProtocol)] conformsToProtocol:@protocol(TestProtocol)])).to(beTrue());
113+
});
114+
});
115+
context(@"when constructor result class NOT conformed to registered protocol", ^{
116+
it(@"resolve with exception", ^{
117+
[OFDependency registerWithProtocol:@protocol(TestProtocol) mode:OFDependencyModeFactory constructor:^id _Nonnull{
118+
return [NSString new];
119+
}];
120+
expect([OFDependency resolveByProtocol:@protocol(TestProtocol)]).to(raiseException());
121+
});
122+
});
123+
});
124+
125+
});
126+
127+
QuickSpecEnd
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Quick
2+
import Nimble
3+
import OrangeFramework
4+
5+
protocol TestProtocol {}
6+
class TestClass: TestProtocol {}
7+
struct TestStruct {}
8+
9+
class OFDependencySpec: QuickSpec {
10+
override func spec() {
11+
12+
describe("dependency by class type") {
13+
it("resolve after register") {
14+
OFDependency.registerWithType(TestClass.self, mode: .Factory) {
15+
return TestClass()
16+
}
17+
expect(OFDependency.resolveByType(TestClass.self)).toNot(raiseException())
18+
}
19+
it("resolve with exception after remove") {
20+
OFDependency.removeForType(TestClass.self)
21+
expect(OFDependency.resolveByType(TestClass.self)).to(raiseException())
22+
}
23+
}
24+
25+
describe("dependency by protocol type") {
26+
it("resolve after register") {
27+
OFDependency.registerWithType(TestProtocol.self, mode: .Factory) {
28+
return TestClass()
29+
}
30+
expect(OFDependency.resolveByType(TestProtocol.self)).toNot(raiseException())
31+
}
32+
}
33+
34+
describe("dependency by value type") {
35+
it("resolve after register") {
36+
OFDependency.registerWithType(TestStruct.self, mode: .Factory) {
37+
return TestStruct()
38+
}
39+
expect(OFDependency.resolveByType(TestStruct.self)).toNot(raiseException())
40+
}
41+
}
42+
43+
}
44+
}

0 commit comments

Comments
 (0)