From 5a19379a0c6e10d2644b28ffcbff01e5c07d00f7 Mon Sep 17 00:00:00 2001 From: qamar-abbas-doordash Date: Fri, 9 Sep 2022 03:30:43 +0500 Subject: [PATCH] Migrated this library from Swift 3 to Swift 5 --- Example/KIF-Quick.xcodeproj/project.pbxproj | 76 ++++++------------- .../xcschemes/KIF-Quick-Example.xcscheme | 28 +++---- Example/KIF-Quick/Base.lproj/Main.storyboard | 32 ++++---- Example/KIF-Quick/ViewController.swift | 10 ++- Example/Podfile.lock | 23 +++--- Example/Tests/SampleSpec.swift | 15 +++- KIF-Quick.podspec | 5 +- KIF-Quick/Classes/KIFSpec.swift | 7 ++ README.md | 17 ++++- 9 files changed, 111 insertions(+), 102 deletions(-) diff --git a/Example/KIF-Quick.xcodeproj/project.pbxproj b/Example/KIF-Quick.xcodeproj/project.pbxproj index 6182936..6d63d4a 100644 --- a/Example/KIF-Quick.xcodeproj/project.pbxproj +++ b/Example/KIF-Quick.xcodeproj/project.pbxproj @@ -169,8 +169,6 @@ 607FACCC1AFB9204008FA782 /* Sources */, 607FACCD1AFB9204008FA782 /* Frameworks */, 607FACCE1AFB9204008FA782 /* Resources */, - 03A233D4BF3FF19D392FA0D1 /* [CP] Embed Pods Frameworks */, - 9A5C481FACFCF47B8913868D /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -190,7 +188,6 @@ 607FACE21AFB9204008FA782 /* Frameworks */, 607FACE31AFB9204008FA782 /* Resources */, 5DA08A1051D2406449BA726D /* [CP] Embed Pods Frameworks */, - 0565EA9316600D7D3228FFFB /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -228,6 +225,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -262,49 +260,26 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 03A233D4BF3FF19D392FA0D1 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KIF-Quick_Example/Pods-KIF-Quick_Example-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - 0565EA9316600D7D3228FFFB /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KIF-Quick_Tests/Pods-KIF-Quick_Tests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; 5DA08A1051D2406449BA726D /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-KIF-Quick_Tests/Pods-KIF-Quick_Tests-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/KIF/KIF.framework", + "${BUILT_PRODUCTS_DIR}/KIF-Quick/KIF_Quick.framework", + "${BUILT_PRODUCTS_DIR}/Quick/Quick.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KIF.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KIF_Quick.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KIF-Quick_Tests/Pods-KIF-Quick_Tests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-KIF-Quick_Tests/Pods-KIF-Quick_Tests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 90B7335B34F07998D3828595 /* [CP] Check Pods Manifest.lock */ = { @@ -313,28 +288,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-KIF-Quick_Example-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; - showEnvVarsInLog = 0; - }; - 9A5C481FACFCF47B8913868D /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KIF-Quick_Example/Pods-KIF-Quick_Example-resources.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; C768C9854FDD1E206A5E0EAC /* [CP] Check Pods Manifest.lock */ = { @@ -343,13 +306,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-KIF-Quick_Tests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -441,7 +407,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.3; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -482,7 +448,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.3; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -501,6 +467,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -514,6 +481,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -530,6 +498,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUNDLE_LOADER)"; }; name = Debug; @@ -543,6 +512,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUNDLE_LOADER)"; }; name = Release; diff --git a/Example/KIF-Quick.xcodeproj/xcshareddata/xcschemes/KIF-Quick-Example.xcscheme b/Example/KIF-Quick.xcodeproj/xcshareddata/xcschemes/KIF-Quick-Example.xcscheme index 7631034..b479b77 100644 --- a/Example/KIF-Quick.xcodeproj/xcshareddata/xcschemes/KIF-Quick-Example.xcscheme +++ b/Example/KIF-Quick.xcodeproj/xcshareddata/xcschemes/KIF-Quick-Example.xcscheme @@ -41,18 +41,6 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "NO"> - - - - - - - - + + + + + + - - - - - - + + - + @@ -21,8 +19,8 @@ - + + + + + + + + + + + + + - + - - - - - diff --git a/Example/KIF-Quick/ViewController.swift b/Example/KIF-Quick/ViewController.swift index d247189..b4207ea 100644 --- a/Example/KIF-Quick/ViewController.swift +++ b/Example/KIF-Quick/ViewController.swift @@ -1,7 +1,15 @@ import UIKit class ViewController: UIViewController { + @IBOutlet var textField: UITextField! + override func viewDidLoad() { + super.viewDidLoad() + } @IBAction func onTap(_ button: UIButton) { - button.setTitle("Thank you!", for: .normal) + guard let text = textField.text, !text.isEmpty else { + button.setTitle("Tap Me", for: .normal) + return + } + button.setTitle(text, for: .normal) } } diff --git a/Example/Podfile.lock b/Example/Podfile.lock index bd9dc28..b57a0dd 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,24 +1,29 @@ PODS: - - KIF (3.5.1): - - KIF/Core (= 3.5.1) + - KIF (3.8.7): + - KIF/Core (= 3.8.7) - KIF-Quick (1.1.0): - KIF (~> 3.0) - - Quick (~> 1.0) - - KIF/Core (3.5.1) - - Quick (1.0.0) + - Quick (~> 1.3.2) + - KIF/Core (3.8.7) + - Quick (1.3.4) DEPENDENCIES: - KIF-Quick (from `../`) +SPEC REPOS: + trunk: + - KIF + - Quick + EXTERNAL SOURCES: KIF-Quick: :path: "../" SPEC CHECKSUMS: - KIF: 082eb65279e51c3092923802849eb796a04982ab - KIF-Quick: d2b9cd7d28405983adf61d5b582165226aca93b7 - Quick: 8024e4a47e6cc03a9d5245ef0948264fc6d27cff + KIF: 779cdbca106633b94ecee7b036537490ebdbd9de + KIF-Quick: 504e4c62294ac0b4cee6419bfb832f6af3eaf1e6 + Quick: f4f7f063c524394c73ed93ac70983c609805d481 PODFILE CHECKSUM: 48447a2c9dab6d7233a99da1a7a9670158e4eb0e -COCOAPODS: 1.1.1 +COCOAPODS: 1.11.3 diff --git a/Example/Tests/SampleSpec.swift b/Example/Tests/SampleSpec.swift index 254567e..3bbc742 100644 --- a/Example/Tests/SampleSpec.swift +++ b/Example/Tests/SampleSpec.swift @@ -5,18 +5,25 @@ class SampleSpec: KIFSpec { override func spec() { describe("example app") { context("main view") { - - it("should have a button") { + it("should have necessary views") { viewTester().usingLabel("Tap Me").waitForView() + viewTester().usingLabel("text_field").waitForView() + } + context("inject data to view") { + it("should allow data injection") { + viewTester().usingLabel("text_field").replaceText("Test Message") + } } - context("tap") { it("should be grateful") { viewTester().usingLabel("Tap Me").tap() - viewTester().usingLabel("Thank you!").waitForView() + viewTester().usingLabel("Test Message").waitForView() } } } } } } + + + diff --git a/KIF-Quick.podspec b/KIF-Quick.podspec index 317505a..cb9c9b9 100644 --- a/KIF-Quick.podspec +++ b/KIF-Quick.podspec @@ -13,9 +13,10 @@ Write Quick specs to drive KIF actors through user interface actions. s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'Paul Zabelin' => 'paulz@doordash.com' } s.source = { :git => 'https://github.com/doordash/KIF-Quick.git', :tag => s.version.to_s } - s.platform = :ios, '8.0' + s.platform = :ios, '13.0' + s.swift_version = '5.0' s.source_files = 'KIF-Quick/Classes' s.framework = 'XCTest' s.dependency 'KIF', '~> 3.0' - s.dependency 'Quick', '~> 1.0' + s.dependency 'Quick', '~> 1.3.2' end diff --git a/KIF-Quick/Classes/KIFSpec.swift b/KIF-Quick/Classes/KIFSpec.swift index 4afc5e1..86e395b 100644 --- a/KIF-Quick/Classes/KIFSpec.swift +++ b/KIF-Quick/Classes/KIFSpec.swift @@ -76,3 +76,10 @@ open class KIFSpec: QuickSpec { KIFSpec.currentKIFActorDelegate = self } } + +public extension KIFUIViewTestActor { + func replaceText(_ text: String) { + clearText() + enterText(text) + } +} diff --git a/README.md b/README.md index 37f1c6e..b015fa5 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,19 @@ class MainViewSpec: KIFSpec { override func spec() { describe("example app") { context("main view") { + it("should have necessary views") { + viewTester().usingLabel("Tap Me").waitForView() + viewTester().usingLabel("text_field").waitForView() + } + context("inject data to view") { + it("should allow data injection") { + viewTester().usingLabel("text_field").replaceText("Test Message") + } + } context("tap") { - it("should change to Thank you") { + it("should be grateful") { viewTester().usingLabel("Tap Me").tap() - viewTester().usingLabel("Thank you!").waitForView() + viewTester().usingLabel("Test Message").waitForView() } } } @@ -69,7 +78,7 @@ Test Suite KIF-Quick_Tests.xctest started SampleSpec ✓ example_app__main_view__should_have_a_button (0.003 seconds) ✓ example_app__main_view__tap__should_be_grateful (0.581 seconds) - Executed 2 tests, with 0 failures (0 unexpected) in 0.584 (0.586) seconds + Executed 2 tests, with 0 failures (0 unexpected) in 0.584 (0.586) seconds ``` where nested Quick contexts concatenated to give full KIF test name. This allows to pinpoint location of possible failures when they happen and have readable English like sentenses describing the functionality. @@ -106,7 +115,7 @@ https://github.com/doordash/KIF-Quick/graphs/contributors KIF-Quick is available under the MIT license. See the LICENSE file for more info. -[swift-badge]: https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat +[swift-badge]: https://img.shields.io/badge/Swift-5.0-orange.svg?style=flat [swift-url]: https://swift.org [travis-badge]: http://img.shields.io/travis/doordash/KIF-Quick.svg?style=flat [travis-url]: https://travis-ci.org/doordash/KIF-Quick