swiftfake 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/ExampleApp/ExampleApp/AppDelegate.swift +46 -0
  3. data/ExampleApp/ExampleApp/Assets.xcassets/AppIcon.appiconset/Contents.json +38 -0
  4. data/ExampleApp/ExampleApp/Base.lproj/LaunchScreen.storyboard +27 -0
  5. data/ExampleApp/ExampleApp/Base.lproj/Main.storyboard +26 -0
  6. data/ExampleApp/ExampleApp/Info.plist +40 -0
  7. data/ExampleApp/ExampleApp/Widget.swift +11 -0
  8. data/ExampleApp/ExampleApp/WidgetService.swift +10 -0
  9. data/ExampleApp/ExampleApp/WidgetViewController.swift +14 -0
  10. data/ExampleApp/ExampleApp.xcodeproj/project.pbxproj +423 -0
  11. data/ExampleApp/ExampleApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  12. data/ExampleApp/ExampleApp.xcodeproj/project.xcworkspace/xcuserdata/oli.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  13. data/ExampleApp/ExampleApp.xcodeproj/xcuserdata/oli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +5 -0
  14. data/ExampleApp/ExampleApp.xcodeproj/xcuserdata/oli.xcuserdatad/xcschemes/ExampleApp.xcscheme +101 -0
  15. data/ExampleApp/ExampleApp.xcodeproj/xcuserdata/oli.xcuserdatad/xcschemes/xcschememanagement.plist +27 -0
  16. data/ExampleApp/ExampleAppTests/Fakes/FakeWidgetService.swift +19 -0
  17. data/ExampleApp/ExampleAppTests/Info.plist +24 -0
  18. data/ExampleApp/ExampleAppTests/WidgetViewControllerTests.swift +40 -0
  19. data/README.md +7 -1
  20. data/lib/swiftfake/presenter.rb +4 -0
  21. data/lib/swiftfake/source_kit_parser.rb +8 -1
  22. data/lib/swiftfake/swift_class.rb +3 -2
  23. data/lib/swiftfake/version.rb +1 -1
  24. data/lib/template.erb +2 -0
  25. metadata +19 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 007987a78aae5059e7268d48151f69c00d247429
4
- data.tar.gz: 7b28363798a818aa5f807ccce4b86046d8c03e29
3
+ metadata.gz: 7e09f41b73f49a7c08317ebf466589ded46a3473
4
+ data.tar.gz: 1090a2b18ff29a0441cc25ab55a8c13e2ffd3454
5
5
  SHA512:
6
- metadata.gz: 7d4463b69d9214a109995d97a913b2a5e0be642345089618a0e3719c45f5ddb1a918e8630934d4b20d3e64dd4f719e2c0849fd4bbea54247f1c43f4d939dbedc
7
- data.tar.gz: c0660fb5edd18c6356a3b656e78e286e3dbe04b36d6f2d96a5de2fbadad5fdd5d20593c32768fa8d1062918aaa8bd01ed326e42ec3ee35934dcda0bc594785f3
6
+ metadata.gz: 4801683a62a702d4a2301a8348f08e8a90c9070dbac76f703304ac2d7a40404b80c7c05628ffb5b8d03d68de3ef2686f900a3d4a63031b7844c7b6d00f9e4060
7
+ data.tar.gz: 57281c055c072fc2426b54a0a2470a07b3f4c7594f63ab22529c617da312fc75197d05901be5a1794f37394733da6457a1c3c86507fb6eaf571d5759883407e2
@@ -0,0 +1,46 @@
1
+ //
2
+ // AppDelegate.swift
3
+ // ExampleApp
4
+ //
5
+ // Created by Oliver Peate on 11/07/2016.
6
+ // Copyright © 2016 Oliver Peate. All rights reserved.
7
+ //
8
+
9
+ import UIKit
10
+
11
+ @UIApplicationMain
12
+ class AppDelegate: UIResponder, UIApplicationDelegate {
13
+
14
+ var window: UIWindow?
15
+
16
+
17
+ func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
18
+ // Override point for customization after application launch.
19
+ return true
20
+ }
21
+
22
+ func applicationWillResignActive(application: UIApplication) {
23
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
25
+ }
26
+
27
+ func applicationDidEnterBackground(application: UIApplication) {
28
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30
+ }
31
+
32
+ func applicationWillEnterForeground(application: UIApplication) {
33
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34
+ }
35
+
36
+ func applicationDidBecomeActive(application: UIApplication) {
37
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38
+ }
39
+
40
+ func applicationWillTerminate(application: UIApplication) {
41
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42
+ }
43
+
44
+
45
+ }
46
+
@@ -0,0 +1,38 @@
1
+ {
2
+ "images" : [
3
+ {
4
+ "idiom" : "iphone",
5
+ "size" : "29x29",
6
+ "scale" : "2x"
7
+ },
8
+ {
9
+ "idiom" : "iphone",
10
+ "size" : "29x29",
11
+ "scale" : "3x"
12
+ },
13
+ {
14
+ "idiom" : "iphone",
15
+ "size" : "40x40",
16
+ "scale" : "2x"
17
+ },
18
+ {
19
+ "idiom" : "iphone",
20
+ "size" : "40x40",
21
+ "scale" : "3x"
22
+ },
23
+ {
24
+ "idiom" : "iphone",
25
+ "size" : "60x60",
26
+ "scale" : "2x"
27
+ },
28
+ {
29
+ "idiom" : "iphone",
30
+ "size" : "60x60",
31
+ "scale" : "3x"
32
+ }
33
+ ],
34
+ "info" : {
35
+ "version" : 1,
36
+ "author" : "xcode"
37
+ }
38
+ }
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
3
+ <dependencies>
4
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
5
+ </dependencies>
6
+ <scenes>
7
+ <!--View Controller-->
8
+ <scene sceneID="EHf-IW-A2E">
9
+ <objects>
10
+ <viewController id="01J-lp-oVM" sceneMemberID="viewController">
11
+ <layoutGuides>
12
+ <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
13
+ <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
14
+ </layoutGuides>
15
+ <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
16
+ <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
17
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
18
+ <animations/>
19
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
20
+ </view>
21
+ </viewController>
22
+ <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
23
+ </objects>
24
+ <point key="canvasLocation" x="53" y="375"/>
25
+ </scene>
26
+ </scenes>
27
+ </document>
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
3
+ <dependencies>
4
+ <deployment identifier="iOS"/>
5
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
6
+ </dependencies>
7
+ <scenes>
8
+ <!--Widget View Controller-->
9
+ <scene sceneID="tne-QT-ifu">
10
+ <objects>
11
+ <viewController storyboardIdentifier="WidgetViewController" id="BYZ-38-t0r" customClass="WidgetViewController" customModule="ExampleApp" customModuleProvider="target" sceneMemberID="viewController">
12
+ <layoutGuides>
13
+ <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
14
+ <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
15
+ </layoutGuides>
16
+ <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
17
+ <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
18
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
20
+ </view>
21
+ </viewController>
22
+ <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
23
+ </objects>
24
+ </scene>
25
+ </scenes>
26
+ </document>
@@ -0,0 +1,40 @@
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>APPL</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
+ <key>LSRequiresIPhoneOS</key>
24
+ <true/>
25
+ <key>UILaunchStoryboardName</key>
26
+ <string>LaunchScreen</string>
27
+ <key>UIMainStoryboardFile</key>
28
+ <string>Main</string>
29
+ <key>UIRequiredDeviceCapabilities</key>
30
+ <array>
31
+ <string>armv7</string>
32
+ </array>
33
+ <key>UISupportedInterfaceOrientations</key>
34
+ <array>
35
+ <string>UIInterfaceOrientationPortrait</string>
36
+ <string>UIInterfaceOrientationLandscapeLeft</string>
37
+ <string>UIInterfaceOrientationLandscapeRight</string>
38
+ </array>
39
+ </dict>
40
+ </plist>
@@ -0,0 +1,11 @@
1
+ import Foundation
2
+
3
+ struct Widget {
4
+ let name: String
5
+ let color: String
6
+ }
7
+
8
+ func ==(a: Widget, b: Widget) -> Bool {
9
+ return a.name == b.name
10
+ && a.color == b.color
11
+ }
@@ -0,0 +1,10 @@
1
+ import Foundation
2
+
3
+ class WidgetService {
4
+
5
+ func fetchWidgets(onlyBlue: Bool) -> [Widget] {
6
+ // ... Complex business logic
7
+ return []
8
+ }
9
+
10
+ }
@@ -0,0 +1,14 @@
1
+ import UIKit
2
+
3
+ class WidgetViewController: UIViewController {
4
+
5
+ var widgetService = WidgetService()
6
+ var widgets: [Widget]?
7
+
8
+ override func viewDidLoad() {
9
+ super.viewDidLoad()
10
+ widgets = widgetService.fetchWidgets(true)
11
+ }
12
+
13
+ }
14
+
@@ -0,0 +1,423 @@
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 46;
7
+ objects = {
8
+
9
+ /* Begin PBXBuildFile section */
10
+ 4F8734921D33807C005F8846 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8734911D33807C005F8846 /* AppDelegate.swift */; };
11
+ 4F8734941D33807C005F8846 /* WidgetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8734931D33807C005F8846 /* WidgetViewController.swift */; };
12
+ 4F8734971D33807C005F8846 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4F8734951D33807C005F8846 /* Main.storyboard */; };
13
+ 4F8734991D33807C005F8846 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4F8734981D33807C005F8846 /* Assets.xcassets */; };
14
+ 4F87349C1D33807C005F8846 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4F87349A1D33807C005F8846 /* LaunchScreen.storyboard */; };
15
+ 4F8734A71D33807D005F8846 /* WidgetViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8734A61D33807D005F8846 /* WidgetViewControllerTests.swift */; };
16
+ 4F8734B21D338095005F8846 /* WidgetService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8734B11D338095005F8846 /* WidgetService.swift */; };
17
+ 4F8734B41D3380CB005F8846 /* Widget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8734B31D3380CB005F8846 /* Widget.swift */; };
18
+ 4F8734B71D33827C005F8846 /* FakeWidgetService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8734B61D33827C005F8846 /* FakeWidgetService.swift */; };
19
+ /* End PBXBuildFile section */
20
+
21
+ /* Begin PBXContainerItemProxy section */
22
+ 4F8734A31D33807D005F8846 /* PBXContainerItemProxy */ = {
23
+ isa = PBXContainerItemProxy;
24
+ containerPortal = 4F8734861D33807C005F8846 /* Project object */;
25
+ proxyType = 1;
26
+ remoteGlobalIDString = 4F87348D1D33807C005F8846;
27
+ remoteInfo = ExampleApp;
28
+ };
29
+ /* End PBXContainerItemProxy section */
30
+
31
+ /* Begin PBXFileReference section */
32
+ 4F87348E1D33807C005F8846 /* ExampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
33
+ 4F8734911D33807C005F8846 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
34
+ 4F8734931D33807C005F8846 /* WidgetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetViewController.swift; sourceTree = "<group>"; };
35
+ 4F8734961D33807C005F8846 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
36
+ 4F8734981D33807C005F8846 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
37
+ 4F87349B1D33807C005F8846 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
38
+ 4F87349D1D33807C005F8846 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
39
+ 4F8734A21D33807D005F8846 /* ExampleAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
40
+ 4F8734A61D33807D005F8846 /* WidgetViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetViewControllerTests.swift; sourceTree = "<group>"; };
41
+ 4F8734A81D33807D005F8846 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
42
+ 4F8734B11D338095005F8846 /* WidgetService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WidgetService.swift; sourceTree = "<group>"; };
43
+ 4F8734B31D3380CB005F8846 /* Widget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Widget.swift; sourceTree = "<group>"; };
44
+ 4F8734B61D33827C005F8846 /* FakeWidgetService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FakeWidgetService.swift; sourceTree = "<group>"; };
45
+ /* End PBXFileReference section */
46
+
47
+ /* Begin PBXFrameworksBuildPhase section */
48
+ 4F87348B1D33807C005F8846 /* Frameworks */ = {
49
+ isa = PBXFrameworksBuildPhase;
50
+ buildActionMask = 2147483647;
51
+ files = (
52
+ );
53
+ runOnlyForDeploymentPostprocessing = 0;
54
+ };
55
+ 4F87349F1D33807D005F8846 /* Frameworks */ = {
56
+ isa = PBXFrameworksBuildPhase;
57
+ buildActionMask = 2147483647;
58
+ files = (
59
+ );
60
+ runOnlyForDeploymentPostprocessing = 0;
61
+ };
62
+ /* End PBXFrameworksBuildPhase section */
63
+
64
+ /* Begin PBXGroup section */
65
+ 4F8734851D33807C005F8846 = {
66
+ isa = PBXGroup;
67
+ children = (
68
+ 4F8734901D33807C005F8846 /* ExampleApp */,
69
+ 4F8734A51D33807D005F8846 /* ExampleAppTests */,
70
+ 4F87348F1D33807C005F8846 /* Products */,
71
+ );
72
+ sourceTree = "<group>";
73
+ };
74
+ 4F87348F1D33807C005F8846 /* Products */ = {
75
+ isa = PBXGroup;
76
+ children = (
77
+ 4F87348E1D33807C005F8846 /* ExampleApp.app */,
78
+ 4F8734A21D33807D005F8846 /* ExampleAppTests.xctest */,
79
+ );
80
+ name = Products;
81
+ sourceTree = "<group>";
82
+ };
83
+ 4F8734901D33807C005F8846 /* ExampleApp */ = {
84
+ isa = PBXGroup;
85
+ children = (
86
+ 4F8734911D33807C005F8846 /* AppDelegate.swift */,
87
+ 4F8734981D33807C005F8846 /* Assets.xcassets */,
88
+ 4F87349D1D33807C005F8846 /* Info.plist */,
89
+ 4F87349A1D33807C005F8846 /* LaunchScreen.storyboard */,
90
+ 4F8734951D33807C005F8846 /* Main.storyboard */,
91
+ 4F8734931D33807C005F8846 /* WidgetViewController.swift */,
92
+ 4F8734B31D3380CB005F8846 /* Widget.swift */,
93
+ 4F8734B11D338095005F8846 /* WidgetService.swift */,
94
+ );
95
+ path = ExampleApp;
96
+ sourceTree = "<group>";
97
+ };
98
+ 4F8734A51D33807D005F8846 /* ExampleAppTests */ = {
99
+ isa = PBXGroup;
100
+ children = (
101
+ 4F8734B51D338242005F8846 /* Fakes */,
102
+ 4F8734A61D33807D005F8846 /* WidgetViewControllerTests.swift */,
103
+ 4F8734A81D33807D005F8846 /* Info.plist */,
104
+ );
105
+ path = ExampleAppTests;
106
+ sourceTree = "<group>";
107
+ };
108
+ 4F8734B51D338242005F8846 /* Fakes */ = {
109
+ isa = PBXGroup;
110
+ children = (
111
+ 4F8734B61D33827C005F8846 /* FakeWidgetService.swift */,
112
+ );
113
+ path = Fakes;
114
+ sourceTree = "<group>";
115
+ };
116
+ /* End PBXGroup section */
117
+
118
+ /* Begin PBXNativeTarget section */
119
+ 4F87348D1D33807C005F8846 /* ExampleApp */ = {
120
+ isa = PBXNativeTarget;
121
+ buildConfigurationList = 4F8734AB1D33807D005F8846 /* Build configuration list for PBXNativeTarget "ExampleApp" */;
122
+ buildPhases = (
123
+ 4F87348A1D33807C005F8846 /* Sources */,
124
+ 4F87348B1D33807C005F8846 /* Frameworks */,
125
+ 4F87348C1D33807C005F8846 /* Resources */,
126
+ );
127
+ buildRules = (
128
+ );
129
+ dependencies = (
130
+ );
131
+ name = ExampleApp;
132
+ productName = ExampleApp;
133
+ productReference = 4F87348E1D33807C005F8846 /* ExampleApp.app */;
134
+ productType = "com.apple.product-type.application";
135
+ };
136
+ 4F8734A11D33807D005F8846 /* ExampleAppTests */ = {
137
+ isa = PBXNativeTarget;
138
+ buildConfigurationList = 4F8734AE1D33807D005F8846 /* Build configuration list for PBXNativeTarget "ExampleAppTests" */;
139
+ buildPhases = (
140
+ 4F87349E1D33807D005F8846 /* Sources */,
141
+ 4F87349F1D33807D005F8846 /* Frameworks */,
142
+ 4F8734A01D33807D005F8846 /* Resources */,
143
+ );
144
+ buildRules = (
145
+ );
146
+ dependencies = (
147
+ 4F8734A41D33807D005F8846 /* PBXTargetDependency */,
148
+ );
149
+ name = ExampleAppTests;
150
+ productName = ExampleAppTests;
151
+ productReference = 4F8734A21D33807D005F8846 /* ExampleAppTests.xctest */;
152
+ productType = "com.apple.product-type.bundle.unit-test";
153
+ };
154
+ /* End PBXNativeTarget section */
155
+
156
+ /* Begin PBXProject section */
157
+ 4F8734861D33807C005F8846 /* Project object */ = {
158
+ isa = PBXProject;
159
+ attributes = {
160
+ LastSwiftUpdateCheck = 0730;
161
+ LastUpgradeCheck = 0730;
162
+ ORGANIZATIONNAME = "Oliver Peate";
163
+ TargetAttributes = {
164
+ 4F87348D1D33807C005F8846 = {
165
+ CreatedOnToolsVersion = 7.3.1;
166
+ };
167
+ 4F8734A11D33807D005F8846 = {
168
+ CreatedOnToolsVersion = 7.3.1;
169
+ TestTargetID = 4F87348D1D33807C005F8846;
170
+ };
171
+ };
172
+ };
173
+ buildConfigurationList = 4F8734891D33807C005F8846 /* Build configuration list for PBXProject "ExampleApp" */;
174
+ compatibilityVersion = "Xcode 3.2";
175
+ developmentRegion = English;
176
+ hasScannedForEncodings = 0;
177
+ knownRegions = (
178
+ en,
179
+ Base,
180
+ );
181
+ mainGroup = 4F8734851D33807C005F8846;
182
+ productRefGroup = 4F87348F1D33807C005F8846 /* Products */;
183
+ projectDirPath = "";
184
+ projectRoot = "";
185
+ targets = (
186
+ 4F87348D1D33807C005F8846 /* ExampleApp */,
187
+ 4F8734A11D33807D005F8846 /* ExampleAppTests */,
188
+ );
189
+ };
190
+ /* End PBXProject section */
191
+
192
+ /* Begin PBXResourcesBuildPhase section */
193
+ 4F87348C1D33807C005F8846 /* Resources */ = {
194
+ isa = PBXResourcesBuildPhase;
195
+ buildActionMask = 2147483647;
196
+ files = (
197
+ 4F87349C1D33807C005F8846 /* LaunchScreen.storyboard in Resources */,
198
+ 4F8734991D33807C005F8846 /* Assets.xcassets in Resources */,
199
+ 4F8734971D33807C005F8846 /* Main.storyboard in Resources */,
200
+ );
201
+ runOnlyForDeploymentPostprocessing = 0;
202
+ };
203
+ 4F8734A01D33807D005F8846 /* Resources */ = {
204
+ isa = PBXResourcesBuildPhase;
205
+ buildActionMask = 2147483647;
206
+ files = (
207
+ );
208
+ runOnlyForDeploymentPostprocessing = 0;
209
+ };
210
+ /* End PBXResourcesBuildPhase section */
211
+
212
+ /* Begin PBXSourcesBuildPhase section */
213
+ 4F87348A1D33807C005F8846 /* Sources */ = {
214
+ isa = PBXSourcesBuildPhase;
215
+ buildActionMask = 2147483647;
216
+ files = (
217
+ 4F8734B21D338095005F8846 /* WidgetService.swift in Sources */,
218
+ 4F8734941D33807C005F8846 /* WidgetViewController.swift in Sources */,
219
+ 4F8734921D33807C005F8846 /* AppDelegate.swift in Sources */,
220
+ 4F8734B41D3380CB005F8846 /* Widget.swift in Sources */,
221
+ );
222
+ runOnlyForDeploymentPostprocessing = 0;
223
+ };
224
+ 4F87349E1D33807D005F8846 /* Sources */ = {
225
+ isa = PBXSourcesBuildPhase;
226
+ buildActionMask = 2147483647;
227
+ files = (
228
+ 4F8734B71D33827C005F8846 /* FakeWidgetService.swift in Sources */,
229
+ 4F8734A71D33807D005F8846 /* WidgetViewControllerTests.swift in Sources */,
230
+ );
231
+ runOnlyForDeploymentPostprocessing = 0;
232
+ };
233
+ /* End PBXSourcesBuildPhase section */
234
+
235
+ /* Begin PBXTargetDependency section */
236
+ 4F8734A41D33807D005F8846 /* PBXTargetDependency */ = {
237
+ isa = PBXTargetDependency;
238
+ target = 4F87348D1D33807C005F8846 /* ExampleApp */;
239
+ targetProxy = 4F8734A31D33807D005F8846 /* PBXContainerItemProxy */;
240
+ };
241
+ /* End PBXTargetDependency section */
242
+
243
+ /* Begin PBXVariantGroup section */
244
+ 4F8734951D33807C005F8846 /* Main.storyboard */ = {
245
+ isa = PBXVariantGroup;
246
+ children = (
247
+ 4F8734961D33807C005F8846 /* Base */,
248
+ );
249
+ name = Main.storyboard;
250
+ sourceTree = "<group>";
251
+ };
252
+ 4F87349A1D33807C005F8846 /* LaunchScreen.storyboard */ = {
253
+ isa = PBXVariantGroup;
254
+ children = (
255
+ 4F87349B1D33807C005F8846 /* Base */,
256
+ );
257
+ name = LaunchScreen.storyboard;
258
+ sourceTree = "<group>";
259
+ };
260
+ /* End PBXVariantGroup section */
261
+
262
+ /* Begin XCBuildConfiguration section */
263
+ 4F8734A91D33807D005F8846 /* Debug */ = {
264
+ isa = XCBuildConfiguration;
265
+ buildSettings = {
266
+ ALWAYS_SEARCH_USER_PATHS = NO;
267
+ CLANG_ANALYZER_NONNULL = YES;
268
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
269
+ CLANG_CXX_LIBRARY = "libc++";
270
+ CLANG_ENABLE_MODULES = YES;
271
+ CLANG_ENABLE_OBJC_ARC = YES;
272
+ CLANG_WARN_BOOL_CONVERSION = YES;
273
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
274
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
275
+ CLANG_WARN_EMPTY_BODY = YES;
276
+ CLANG_WARN_ENUM_CONVERSION = YES;
277
+ CLANG_WARN_INT_CONVERSION = YES;
278
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
279
+ CLANG_WARN_UNREACHABLE_CODE = YES;
280
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
281
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
282
+ COPY_PHASE_STRIP = NO;
283
+ DEBUG_INFORMATION_FORMAT = dwarf;
284
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
285
+ ENABLE_TESTABILITY = YES;
286
+ GCC_C_LANGUAGE_STANDARD = gnu99;
287
+ GCC_DYNAMIC_NO_PIC = NO;
288
+ GCC_NO_COMMON_BLOCKS = YES;
289
+ GCC_OPTIMIZATION_LEVEL = 0;
290
+ GCC_PREPROCESSOR_DEFINITIONS = (
291
+ "DEBUG=1",
292
+ "$(inherited)",
293
+ );
294
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
295
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
296
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
297
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
298
+ GCC_WARN_UNUSED_FUNCTION = YES;
299
+ GCC_WARN_UNUSED_VARIABLE = YES;
300
+ IPHONEOS_DEPLOYMENT_TARGET = 9.3;
301
+ MTL_ENABLE_DEBUG_INFO = YES;
302
+ ONLY_ACTIVE_ARCH = YES;
303
+ SDKROOT = iphoneos;
304
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
305
+ };
306
+ name = Debug;
307
+ };
308
+ 4F8734AA1D33807D005F8846 /* Release */ = {
309
+ isa = XCBuildConfiguration;
310
+ buildSettings = {
311
+ ALWAYS_SEARCH_USER_PATHS = NO;
312
+ CLANG_ANALYZER_NONNULL = YES;
313
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
314
+ CLANG_CXX_LIBRARY = "libc++";
315
+ CLANG_ENABLE_MODULES = YES;
316
+ CLANG_ENABLE_OBJC_ARC = YES;
317
+ CLANG_WARN_BOOL_CONVERSION = YES;
318
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
319
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
320
+ CLANG_WARN_EMPTY_BODY = YES;
321
+ CLANG_WARN_ENUM_CONVERSION = YES;
322
+ CLANG_WARN_INT_CONVERSION = YES;
323
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
324
+ CLANG_WARN_UNREACHABLE_CODE = YES;
325
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
326
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
327
+ COPY_PHASE_STRIP = NO;
328
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
329
+ ENABLE_NS_ASSERTIONS = NO;
330
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
331
+ GCC_C_LANGUAGE_STANDARD = gnu99;
332
+ GCC_NO_COMMON_BLOCKS = YES;
333
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
334
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
335
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
336
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
337
+ GCC_WARN_UNUSED_FUNCTION = YES;
338
+ GCC_WARN_UNUSED_VARIABLE = YES;
339
+ IPHONEOS_DEPLOYMENT_TARGET = 9.3;
340
+ MTL_ENABLE_DEBUG_INFO = NO;
341
+ SDKROOT = iphoneos;
342
+ VALIDATE_PRODUCT = YES;
343
+ };
344
+ name = Release;
345
+ };
346
+ 4F8734AC1D33807D005F8846 /* Debug */ = {
347
+ isa = XCBuildConfiguration;
348
+ buildSettings = {
349
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
350
+ INFOPLIST_FILE = ExampleApp/Info.plist;
351
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
352
+ PRODUCT_BUNDLE_IDENTIFIER = com.github.ExampleApp;
353
+ PRODUCT_NAME = "$(TARGET_NAME)";
354
+ };
355
+ name = Debug;
356
+ };
357
+ 4F8734AD1D33807D005F8846 /* Release */ = {
358
+ isa = XCBuildConfiguration;
359
+ buildSettings = {
360
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
361
+ INFOPLIST_FILE = ExampleApp/Info.plist;
362
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
363
+ PRODUCT_BUNDLE_IDENTIFIER = com.github.ExampleApp;
364
+ PRODUCT_NAME = "$(TARGET_NAME)";
365
+ };
366
+ name = Release;
367
+ };
368
+ 4F8734AF1D33807D005F8846 /* Debug */ = {
369
+ isa = XCBuildConfiguration;
370
+ buildSettings = {
371
+ BUNDLE_LOADER = "$(TEST_HOST)";
372
+ INFOPLIST_FILE = ExampleAppTests/Info.plist;
373
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
374
+ PRODUCT_BUNDLE_IDENTIFIER = com.github.ExampleAppTests;
375
+ PRODUCT_NAME = "$(TARGET_NAME)";
376
+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ExampleApp.app/ExampleApp";
377
+ };
378
+ name = Debug;
379
+ };
380
+ 4F8734B01D33807D005F8846 /* Release */ = {
381
+ isa = XCBuildConfiguration;
382
+ buildSettings = {
383
+ BUNDLE_LOADER = "$(TEST_HOST)";
384
+ INFOPLIST_FILE = ExampleAppTests/Info.plist;
385
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
386
+ PRODUCT_BUNDLE_IDENTIFIER = com.github.ExampleAppTests;
387
+ PRODUCT_NAME = "$(TARGET_NAME)";
388
+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ExampleApp.app/ExampleApp";
389
+ };
390
+ name = Release;
391
+ };
392
+ /* End XCBuildConfiguration section */
393
+
394
+ /* Begin XCConfigurationList section */
395
+ 4F8734891D33807C005F8846 /* Build configuration list for PBXProject "ExampleApp" */ = {
396
+ isa = XCConfigurationList;
397
+ buildConfigurations = (
398
+ 4F8734A91D33807D005F8846 /* Debug */,
399
+ 4F8734AA1D33807D005F8846 /* Release */,
400
+ );
401
+ defaultConfigurationIsVisible = 0;
402
+ defaultConfigurationName = Release;
403
+ };
404
+ 4F8734AB1D33807D005F8846 /* Build configuration list for PBXNativeTarget "ExampleApp" */ = {
405
+ isa = XCConfigurationList;
406
+ buildConfigurations = (
407
+ 4F8734AC1D33807D005F8846 /* Debug */,
408
+ 4F8734AD1D33807D005F8846 /* Release */,
409
+ );
410
+ defaultConfigurationIsVisible = 0;
411
+ };
412
+ 4F8734AE1D33807D005F8846 /* Build configuration list for PBXNativeTarget "ExampleAppTests" */ = {
413
+ isa = XCConfigurationList;
414
+ buildConfigurations = (
415
+ 4F8734AF1D33807D005F8846 /* Debug */,
416
+ 4F8734B01D33807D005F8846 /* Release */,
417
+ );
418
+ defaultConfigurationIsVisible = 0;
419
+ };
420
+ /* End XCConfigurationList section */
421
+ };
422
+ rootObject = 4F8734861D33807C005F8846 /* Project object */;
423
+ }
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:ExampleApp.xcodeproj">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Bucket
3
+ type = "1"
4
+ version = "2.0">
5
+ </Bucket>
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Scheme
3
+ LastUpgradeVersion = "0730"
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 = "4F87348D1D33807C005F8846"
18
+ BuildableName = "ExampleApp.app"
19
+ BlueprintName = "ExampleApp"
20
+ ReferencedContainer = "container:ExampleApp.xcodeproj">
21
+ </BuildableReference>
22
+ </BuildActionEntry>
23
+ </BuildActionEntries>
24
+ </BuildAction>
25
+ <TestAction
26
+ buildConfiguration = "Debug"
27
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29
+ shouldUseLaunchSchemeArgsEnv = "YES">
30
+ <Testables>
31
+ <TestableReference
32
+ skipped = "NO">
33
+ <BuildableReference
34
+ BuildableIdentifier = "primary"
35
+ BlueprintIdentifier = "4F8734A11D33807D005F8846"
36
+ BuildableName = "ExampleAppTests.xctest"
37
+ BlueprintName = "ExampleAppTests"
38
+ ReferencedContainer = "container:ExampleApp.xcodeproj">
39
+ </BuildableReference>
40
+ </TestableReference>
41
+ </Testables>
42
+ <MacroExpansion>
43
+ <BuildableReference
44
+ BuildableIdentifier = "primary"
45
+ BlueprintIdentifier = "4F87348D1D33807C005F8846"
46
+ BuildableName = "ExampleApp.app"
47
+ BlueprintName = "ExampleApp"
48
+ ReferencedContainer = "container:ExampleApp.xcodeproj">
49
+ </BuildableReference>
50
+ </MacroExpansion>
51
+ <AdditionalOptions>
52
+ </AdditionalOptions>
53
+ </TestAction>
54
+ <LaunchAction
55
+ buildConfiguration = "Debug"
56
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
57
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
58
+ launchStyle = "0"
59
+ useCustomWorkingDirectory = "NO"
60
+ ignoresPersistentStateOnLaunch = "NO"
61
+ debugDocumentVersioning = "YES"
62
+ debugServiceExtension = "internal"
63
+ allowLocationSimulation = "YES">
64
+ <BuildableProductRunnable
65
+ runnableDebuggingMode = "0">
66
+ <BuildableReference
67
+ BuildableIdentifier = "primary"
68
+ BlueprintIdentifier = "4F87348D1D33807C005F8846"
69
+ BuildableName = "ExampleApp.app"
70
+ BlueprintName = "ExampleApp"
71
+ ReferencedContainer = "container:ExampleApp.xcodeproj">
72
+ </BuildableReference>
73
+ </BuildableProductRunnable>
74
+ <AdditionalOptions>
75
+ </AdditionalOptions>
76
+ </LaunchAction>
77
+ <ProfileAction
78
+ buildConfiguration = "Release"
79
+ shouldUseLaunchSchemeArgsEnv = "YES"
80
+ savedToolIdentifier = ""
81
+ useCustomWorkingDirectory = "NO"
82
+ debugDocumentVersioning = "YES">
83
+ <BuildableProductRunnable
84
+ runnableDebuggingMode = "0">
85
+ <BuildableReference
86
+ BuildableIdentifier = "primary"
87
+ BlueprintIdentifier = "4F87348D1D33807C005F8846"
88
+ BuildableName = "ExampleApp.app"
89
+ BlueprintName = "ExampleApp"
90
+ ReferencedContainer = "container:ExampleApp.xcodeproj">
91
+ </BuildableReference>
92
+ </BuildableProductRunnable>
93
+ </ProfileAction>
94
+ <AnalyzeAction
95
+ buildConfiguration = "Debug">
96
+ </AnalyzeAction>
97
+ <ArchiveAction
98
+ buildConfiguration = "Release"
99
+ revealArchiveInOrganizer = "YES">
100
+ </ArchiveAction>
101
+ </Scheme>
@@ -0,0 +1,27 @@
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>SchemeUserState</key>
6
+ <dict>
7
+ <key>ExampleApp.xcscheme</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ <key>SuppressBuildableAutocreation</key>
14
+ <dict>
15
+ <key>4F87348D1D33807C005F8846</key>
16
+ <dict>
17
+ <key>primary</key>
18
+ <true/>
19
+ </dict>
20
+ <key>4F8734A11D33807D005F8846</key>
21
+ <dict>
22
+ <key>primary</key>
23
+ <true/>
24
+ </dict>
25
+ </dict>
26
+ </dict>
27
+ </plist>
@@ -0,0 +1,19 @@
1
+ import Foundation
2
+
3
+ @testable import ExampleApp
4
+
5
+ internal class FakeWidgetService: WidgetService {
6
+
7
+ override func fetchWidgets(onlyBlue: Bool) -> [Widget] {
8
+ fetchWidgetsCallCount += 1
9
+ fetchWidgetsArgsForCall.append(onlyBlue)
10
+ return fetchWidgetsReturnValue
11
+ }
12
+
13
+ // MARK: - Fake Helpers
14
+
15
+ var fetchWidgetsCallCount = 0
16
+ var fetchWidgetsArgsForCall = [Bool]()
17
+ var fetchWidgetsReturnValue = [Widget]()
18
+
19
+ }
@@ -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>
@@ -0,0 +1,40 @@
1
+ import XCTest
2
+ @testable import ExampleApp
3
+
4
+ class WidgetViewControllerTests: XCTestCase {
5
+
6
+ var vc: WidgetViewController!
7
+ var fakeWidgetService: FakeWidgetService!
8
+ var expectedWidget: Widget!
9
+
10
+ override func setUp() {
11
+ super.setUp()
12
+ continueAfterFailure = false
13
+
14
+ let storyboard = UIStoryboard(name: "Main", bundle: nil)
15
+ vc = storyboard.instantiateInitialViewController() as! WidgetViewController
16
+
17
+ expectedWidget = Widget(name: "Widgetty", color: "Blue")
18
+ fakeWidgetService = FakeWidgetService()
19
+ fakeWidgetService.fetchWidgetsReturnValue = [expectedWidget]
20
+
21
+ vc.widgetService = fakeWidgetService // Property based injection of fake onto UIViewController
22
+
23
+ vc.beginAppearanceTransition(true, animated: false)
24
+ vc.endAppearanceTransition()
25
+ }
26
+
27
+ func testVerifyWidgetServiceInteraction() {
28
+ XCTAssertEqual(fakeWidgetService.fetchWidgetsCallCount, 1)
29
+
30
+ XCTAssertEqual(fakeWidgetService.fetchWidgetsArgsForCall[0], true)
31
+
32
+ guard let loadedWidgets = vc.widgets else {
33
+ XCTFail("View controller has no widgets")
34
+ return
35
+ }
36
+
37
+ XCTAssertTrue(loadedWidgets[0] == expectedWidget)
38
+ }
39
+
40
+ }
data/README.md CHANGED
@@ -8,7 +8,7 @@ Generate test fakes from Swift code. The fakes allow you to:
8
8
  - Verify what arguments were received
9
9
  - Return a canned value
10
10
 
11
- ## Usage
11
+ ## Creating fakes
12
12
 
13
13
  Pass a Swift file path and the fake will be printed to STDOUT:
14
14
 
@@ -26,6 +26,11 @@ swiftfake ./app/MySwiftClass.swift | pbcopy
26
26
  swiftfake ./app/MySwiftClass.swift > ./test/FakeMySwiftClass.swift
27
27
  ```
28
28
 
29
+ ## Using the fakes
30
+
31
+
32
+
33
+
29
34
  ## Requirements
30
35
 
31
36
  - Ruby 2.1+ (run `ruby -v` to check)
@@ -38,6 +43,7 @@ This gem is still in an alpha state.
38
43
  Roadmap:
39
44
 
40
45
  - Copy across @import statements from source
46
+ - Template overrides
41
47
  - Fake Protocol implementations
42
48
  - Implement Bright Futures support
43
49
  - Handling multiple classes/protocols in the Swift source file
@@ -16,6 +16,10 @@ module Swiftfake
16
16
  "#{swift_class.access} class Fake#{swift_class.name}: #{swift_class.name}"
17
17
  end
18
18
 
19
+ def import_statements
20
+ swift_class.imports.join("\n")
21
+ end
22
+
19
23
  def functions
20
24
  @functions ||= swift_class.functions.map { |f| f.extend(FunctionDecorator) }
21
25
  end
@@ -14,7 +14,8 @@ module Swiftfake
14
14
  SwiftClass.new(
15
15
  name: class_name,
16
16
  access: access_level,
17
- functions: parse_functions
17
+ functions: parse_functions,
18
+ imports: imports
18
19
  )
19
20
  end
20
21
 
@@ -29,6 +30,12 @@ module Swiftfake
29
30
  raw_accessibility.split('.').last unless raw_accessibility.nil?
30
31
  end
31
32
 
33
+ def imports
34
+ source_file
35
+ .split("\n")
36
+ .select{ |line| line.start_with? 'import' }
37
+ end
38
+
32
39
  def first_entity
33
40
  structure_json
34
41
  .fetch("key.substructure", [])
@@ -1,11 +1,12 @@
1
1
  module Swiftfake
2
2
  class SwiftClass
3
- attr_reader :name, :access, :functions
3
+ attr_reader :name, :access, :functions, :imports
4
4
 
5
- def initialize(name:, access:, functions:)
5
+ def initialize(name:, access:, functions:, imports: [])
6
6
  @name = name
7
7
  @access = access
8
8
  @functions = functions
9
+ @imports = imports
9
10
  end
10
11
  end
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module Swiftfake
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/template.erb CHANGED
@@ -1,3 +1,5 @@
1
+ <% unless import_statements.empty? %><%= import_statements %><% end %>
2
+
1
3
  <%= fake_class_signature %> {
2
4
 
3
5
  <% functions.each do |f| -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiftfake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - odlp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,6 +63,23 @@ files:
63
63
  - ".gitignore"
64
64
  - ".rspec"
65
65
  - ".travis.yml"
66
+ - ExampleApp/ExampleApp.xcodeproj/project.pbxproj
67
+ - ExampleApp/ExampleApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata
68
+ - ExampleApp/ExampleApp.xcodeproj/project.xcworkspace/xcuserdata/oli.xcuserdatad/UserInterfaceState.xcuserstate
69
+ - ExampleApp/ExampleApp.xcodeproj/xcuserdata/oli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
70
+ - ExampleApp/ExampleApp.xcodeproj/xcuserdata/oli.xcuserdatad/xcschemes/ExampleApp.xcscheme
71
+ - ExampleApp/ExampleApp.xcodeproj/xcuserdata/oli.xcuserdatad/xcschemes/xcschememanagement.plist
72
+ - ExampleApp/ExampleApp/AppDelegate.swift
73
+ - ExampleApp/ExampleApp/Assets.xcassets/AppIcon.appiconset/Contents.json
74
+ - ExampleApp/ExampleApp/Base.lproj/LaunchScreen.storyboard
75
+ - ExampleApp/ExampleApp/Base.lproj/Main.storyboard
76
+ - ExampleApp/ExampleApp/Info.plist
77
+ - ExampleApp/ExampleApp/Widget.swift
78
+ - ExampleApp/ExampleApp/WidgetService.swift
79
+ - ExampleApp/ExampleApp/WidgetViewController.swift
80
+ - ExampleApp/ExampleAppTests/Fakes/FakeWidgetService.swift
81
+ - ExampleApp/ExampleAppTests/Info.plist
82
+ - ExampleApp/ExampleAppTests/WidgetViewControllerTests.swift
66
83
  - Gemfile
67
84
  - README.md
68
85
  - Rakefile