From 2c085156145d555280079ff8c1442b1cc3d80b77 Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Mon, 29 Oct 2018 18:04:58 +0100 Subject: [PATCH 01/10] Remove unnecessary reference to circle.yml file --- Example/SpecTools.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Example/SpecTools.xcodeproj/project.pbxproj b/Example/SpecTools.xcodeproj/project.pbxproj index acc8d03..a3a9eb9 100644 --- a/Example/SpecTools.xcodeproj/project.pbxproj +++ b/Example/SpecTools.xcodeproj/project.pbxproj @@ -12,7 +12,6 @@ 15074DEA1F6443D400E06BD0 /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15074DE91F6443D400E06BD0 /* TableViewController.swift */; }; 15074DEF1F667F0F00E06BD0 /* TableViewControllerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15074DEE1F667F0F00E06BD0 /* TableViewControllerSpec.swift */; }; 15074DF21F6687B400E06BD0 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15074DF11F6687B400E06BD0 /* TableViewCell.swift */; }; - 15F9BA181F94FF1D00245DF2 /* circle.yml in Resources */ = {isa = PBXBuildFile; fileRef = 15F9BA171F94FF1D00245DF2 /* circle.yml */; }; 40E0CC079E7C8FE96ED5C342 /* Pods_TVExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 46141C4B85516DCBD9FA4DC0 /* Pods_TVExample.framework */; }; 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; @@ -58,7 +57,6 @@ 1581B2C91F57711D00DDDA6C /* generate_docs.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = generate_docs.sh; path = ../generate_docs.sh; sourceTree = ""; }; 15F9BA131F94FB3500245DF2 /* install.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = install.sh; path = ../Scripts/install.sh; sourceTree = ""; }; 15F9BA141F94FB3500245DF2 /* build.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = build.sh; path = ../Scripts/build.sh; sourceTree = ""; }; - 15F9BA171F94FF1D00245DF2 /* circle.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = circle.yml; path = ../circle.yml; sourceTree = ""; }; 1D5CA6E801DB8A91D3E70DE6 /* Pods_TVExampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TVExampleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 25476FCE33DB8F6A74FDBAAD /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 4025987761D8603D7A3EF403 /* Pods_SpecToolsExampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SpecToolsExampleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -156,7 +154,6 @@ 1581B2C81F57710600DDDA6C /* Scripts */ = { isa = PBXGroup; children = ( - 15F9BA171F94FF1D00245DF2 /* circle.yml */, 15F9BA141F94FB3500245DF2 /* build.sh */, 15F9BA131F94FB3500245DF2 /* install.sh */, 1581B2C91F57711D00DDDA6C /* generate_docs.sh */, @@ -432,7 +429,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 15F9BA181F94FF1D00245DF2 /* circle.yml in Resources */, 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, ); From d26b2a9650234952b15122f343910331aef6bb9e Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Tue, 30 Oct 2018 08:21:18 +0100 Subject: [PATCH 02/10] Add LabeledView & SwipeView to example project --- Example/SpecTools.xcodeproj/project.pbxproj | 8 +++ Example/SpecTools/LabeledView.swift | 50 +++++++++++++ Example/SpecTools/SwipeView.swift | 77 +++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 Example/SpecTools/LabeledView.swift create mode 100644 Example/SpecTools/SwipeView.swift diff --git a/Example/SpecTools.xcodeproj/project.pbxproj b/Example/SpecTools.xcodeproj/project.pbxproj index a3a9eb9..46c743b 100644 --- a/Example/SpecTools.xcodeproj/project.pbxproj +++ b/Example/SpecTools.xcodeproj/project.pbxproj @@ -19,6 +19,8 @@ 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 9742DFBD958C41A0D4A320A7 /* Pods_SpecToolsExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA48DE5F6072FA17B587A4CF /* Pods_SpecToolsExample.framework */; }; C65796F10C08144A51ED4CD8 /* Pods_TVExampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D5CA6E801DB8A91D3E70DE6 /* Pods_TVExampleTests.framework */; }; + DA62C52F3E9A07FA2E6034DA /* SwipeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA6621D12D0DCFD3C5921A21 /* SwipeView.swift */; }; + DA674C49DCD23F74F6B91984 /* LabeledView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA6F41B96D384A3274587E76 /* LabeledView.swift */; }; F230246CE764371409137DF7 /* Pods_SpecToolsExampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4025987761D8603D7A3EF403 /* Pods_SpecToolsExampleTests.framework */; }; F4A8DD811FAB3C3A00237CF6 /* CollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A8DD801FAB3C3A00237CF6 /* CollectionViewController.swift */; }; F4A8DD851FAB3FA000237CF6 /* CollectionViewControllerSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A8DD841FAB3FA000237CF6 /* CollectionViewControllerSpecs.swift */; }; @@ -78,6 +80,8 @@ CEB96607FEDF79B741ECC275 /* SpecTools.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SpecTools.podspec; path = ../SpecTools.podspec; sourceTree = ""; }; D1BC6C635B933789988F6829 /* Pods-SpecToolsExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SpecToolsExampleTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-SpecToolsExampleTests/Pods-SpecToolsExampleTests.release.xcconfig"; sourceTree = ""; }; DA48DE5F6072FA17B587A4CF /* Pods_SpecToolsExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SpecToolsExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DA6621D12D0DCFD3C5921A21 /* SwipeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeView.swift; sourceTree = ""; }; + DA6F41B96D384A3274587E76 /* LabeledView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabeledView.swift; sourceTree = ""; }; DB1653D35AA1B0DA36A7E500 /* Pods-SpecTools_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SpecTools_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-SpecTools_Tests/Pods-SpecTools_Tests.release.xcconfig"; sourceTree = ""; }; DFB0C922BA6451420392BB90 /* Pods-TVExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TVExampleTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TVExampleTests/Pods-TVExampleTests.release.xcconfig"; sourceTree = ""; }; E0880E6B85859025B2200B60 /* Pods-TVExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TVExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-TVExample/Pods-TVExample.release.xcconfig"; sourceTree = ""; }; @@ -147,6 +151,8 @@ isa = PBXGroup; children = ( 15074DF11F6687B400E06BD0 /* TableViewCell.swift */, + DA6621D12D0DCFD3C5921A21 /* SwipeView.swift */, + DA6F41B96D384A3274587E76 /* LabeledView.swift */, ); name = View; sourceTree = ""; @@ -628,6 +634,8 @@ 15074DEA1F6443D400E06BD0 /* TableViewController.swift in Sources */, 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, F4A8DD811FAB3C3A00237CF6 /* CollectionViewController.swift in Sources */, + DA62C52F3E9A07FA2E6034DA /* SwipeView.swift in Sources */, + DA674C49DCD23F74F6B91984 /* LabeledView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Example/SpecTools/LabeledView.swift b/Example/SpecTools/LabeledView.swift new file mode 100644 index 0000000..bfa20be --- /dev/null +++ b/Example/SpecTools/LabeledView.swift @@ -0,0 +1,50 @@ +import SnapKit +import UIKit + +class LabeledView: UIView { + + let label: UILabel = Subviews.label + + init() { + super.init(frame: .zero) + + addSubviews() + setUpLayout() + } + + // MARK: - Subviews + + private func addSubviews() { + addSubview(label) + } + + // MARK: - Layout + + private func setUpLayout() { + label.snp.makeConstraints { + $0.top.trailing.lessThanOrEqualToSuperview() + $0.bottom.leading.lessThanOrEqualToSuperview() + $0.center.equalToSuperview() + } + } + + // MARK: - Required initializer + + required init?(coder _: NSCoder) { return nil } + +} + +private extension LabeledView { + + enum Subviews { + static var label: UILabel { + let label = UILabel(frame: .zero) + label.textColor = .white + label.font = UIFont.systemFont(ofSize: 15.0, weight: .bold) + label.textAlignment = .center + + return label + } + } + +} diff --git a/Example/SpecTools/SwipeView.swift b/Example/SpecTools/SwipeView.swift new file mode 100644 index 0000000..0066a6a --- /dev/null +++ b/Example/SpecTools/SwipeView.swift @@ -0,0 +1,77 @@ +import UIKit +import SnapKit + +class SwipeView: UIView { + + let upView: UIView = Subviews.view(color: .green, text: "UP") + let leftView: UIView = Subviews.view(color: .red, text: "LEFT") + let rightView: UIView = Subviews.view(color: .blue, text: "RIGHT") + let downView: UIView = Subviews.view(color: .gray, text: "DOWN") + + init() { + super.init(frame: .zero) + + setUpSelf() + addSubviews() + setupLayout() + } + + private func setUpSelf() { + backgroundColor = .white + } + + // MARK: Subviews + + private let stackView: UIStackView = Subviews.stackView + + private func addSubviews() { + [upView, leftView, rightView, downView].forEach { + stackView.addArrangedSubview($0) + } + + addSubview(stackView) + } + + // MARK: Layout + + private func setupLayout() { + stackView.snp.makeConstraints { + $0.edges.equalToSuperview() + } + + [upView, leftView, rightView, downView].forEach { view in + view.snp.makeConstraints { + $0.width.equalToSuperview() + } + } + } + + // MARK: - Required initializer + + required init?(coder _: NSCoder) { return nil } + +} + +private extension SwipeView { + + enum Subviews { + static func view(color: UIColor, text: String) -> LabeledView { + let view = LabeledView() + view.backgroundColor = color + view.label.text = text + + return view + } + + static var stackView: UIStackView { + let stackView = UIStackView(frame: .zero) + stackView.axis = .vertical + stackView.alignment = .center + stackView.distribution = .fillEqually + stackView.spacing = 5 + + return stackView + } + } + +} From 518169fbd259d9ebe183c66757a02122ec1be117 Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Tue, 30 Oct 2018 09:30:40 +0100 Subject: [PATCH 03/10] Add support for UISwipeGestureRecognizer --- Example/Podfile.lock | 4 +- .../Local Podspecs/SpecTools.podspec.json | 4 +- Example/Pods/Manifest.lock | 4 +- .../SpecTools-iOS/Info.plist | 2 +- .../SpecTools-tvOS/Info.plist | 2 +- Example/SpecTools.xcodeproj/project.pbxproj | 14 +- Example/SpecTools/SwipeViewController.swift | 65 +++++++++ .../SwipeViewControllerSpec.swift | 132 ++++++++++++++++++ SpecTools.podspec | 2 +- .../Action/Action+UIGestureRecognizer.swift | 44 ++++-- 10 files changed, 246 insertions(+), 27 deletions(-) create mode 100644 Example/SpecTools/SwipeViewController.swift create mode 100644 Example/SpecToolsExampleTests/SwipeViewControllerSpec.swift diff --git a/Example/Podfile.lock b/Example/Podfile.lock index e927eab..0895461 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -2,7 +2,7 @@ PODS: - Nimble (7.3.1) - Quick (1.3.2) - SnapKit (4.2.0) - - SpecTools (1.0.3) + - SpecTools (1.2.0) DEPENDENCIES: - Nimble @@ -24,7 +24,7 @@ SPEC CHECKSUMS: Nimble: 04f732da099ea4d153122aec8c2a88fd0c7219ae Quick: 2623cb30d7a7f41ca62f684f679586558f483d46 SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a - SpecTools: 1215af4f3b7e8e61484a1cdb5e1fb775fa2428bc + SpecTools: 379345b4fcee92e578817ff0aeb0c2099865d52a PODFILE CHECKSUM: 75022a650debfd62f749637ced8ed249be1a9563 diff --git a/Example/Pods/Local Podspecs/SpecTools.podspec.json b/Example/Pods/Local Podspecs/SpecTools.podspec.json index 8926b6f..cf3dff4 100644 --- a/Example/Pods/Local Podspecs/SpecTools.podspec.json +++ b/Example/Pods/Local Podspecs/SpecTools.podspec.json @@ -1,6 +1,6 @@ { "name": "SpecTools", - "version": "1.0.3", + "version": "1.2.0", "summary": "Library that helps you write less code when testing your iOS apps.", "description": "Write less test code, this library contains a set of tools that are split in a few categories which have very specific helper functionality. All these are only available to their relevant elements.", "homepage": "https://github.com/manGoweb/SpecTools", @@ -13,7 +13,7 @@ }, "source": { "git": "https://github.com/manGoweb/SpecTools.git", - "tag": "1.0.3" + "tag": "1.2.0" }, "social_media_url": "https://twitter.com/rafiki270", "platforms": { diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index e927eab..0895461 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -2,7 +2,7 @@ PODS: - Nimble (7.3.1) - Quick (1.3.2) - SnapKit (4.2.0) - - SpecTools (1.0.3) + - SpecTools (1.2.0) DEPENDENCIES: - Nimble @@ -24,7 +24,7 @@ SPEC CHECKSUMS: Nimble: 04f732da099ea4d153122aec8c2a88fd0c7219ae Quick: 2623cb30d7a7f41ca62f684f679586558f483d46 SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a - SpecTools: 1215af4f3b7e8e61484a1cdb5e1fb775fa2428bc + SpecTools: 379345b4fcee92e578817ff0aeb0c2099865d52a PODFILE CHECKSUM: 75022a650debfd62f749637ced8ed249be1a9563 diff --git a/Example/Pods/Target Support Files/SpecTools-iOS/Info.plist b/Example/Pods/Target Support Files/SpecTools-iOS/Info.plist index 10ad18b..2a9158a 100644 --- a/Example/Pods/Target Support Files/SpecTools-iOS/Info.plist +++ b/Example/Pods/Target Support Files/SpecTools-iOS/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.3 + 1.2.0 CFBundleSignature ???? CFBundleVersion diff --git a/Example/Pods/Target Support Files/SpecTools-tvOS/Info.plist b/Example/Pods/Target Support Files/SpecTools-tvOS/Info.plist index 10ad18b..2a9158a 100644 --- a/Example/Pods/Target Support Files/SpecTools-tvOS/Info.plist +++ b/Example/Pods/Target Support Files/SpecTools-tvOS/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.3 + 1.2.0 CFBundleSignature ???? CFBundleVersion diff --git a/Example/SpecTools.xcodeproj/project.pbxproj b/Example/SpecTools.xcodeproj/project.pbxproj index 46c743b..e45d16b 100644 --- a/Example/SpecTools.xcodeproj/project.pbxproj +++ b/Example/SpecTools.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 15074DEF1F667F0F00E06BD0 /* TableViewControllerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15074DEE1F667F0F00E06BD0 /* TableViewControllerSpec.swift */; }; 15074DF21F6687B400E06BD0 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15074DF11F6687B400E06BD0 /* TableViewCell.swift */; }; 40E0CC079E7C8FE96ED5C342 /* Pods_TVExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 46141C4B85516DCBD9FA4DC0 /* Pods_TVExample.framework */; }; + 4EEB39D421882998004D9295 /* SwipeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EEB39D321882998004D9295 /* SwipeViewController.swift */; }; 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; @@ -21,6 +22,7 @@ C65796F10C08144A51ED4CD8 /* Pods_TVExampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D5CA6E801DB8A91D3E70DE6 /* Pods_TVExampleTests.framework */; }; DA62C52F3E9A07FA2E6034DA /* SwipeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA6621D12D0DCFD3C5921A21 /* SwipeView.swift */; }; DA674C49DCD23F74F6B91984 /* LabeledView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA6F41B96D384A3274587E76 /* LabeledView.swift */; }; + DA6C851CF48875F2E30AD9F7 /* SwipeViewControllerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA68C9608FD96EFF171ED130 /* SwipeViewControllerSpec.swift */; }; F230246CE764371409137DF7 /* Pods_SpecToolsExampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4025987761D8603D7A3EF403 /* Pods_SpecToolsExampleTests.framework */; }; F4A8DD811FAB3C3A00237CF6 /* CollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A8DD801FAB3C3A00237CF6 /* CollectionViewController.swift */; }; F4A8DD851FAB3FA000237CF6 /* CollectionViewControllerSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A8DD841FAB3FA000237CF6 /* CollectionViewControllerSpecs.swift */; }; @@ -63,6 +65,7 @@ 25476FCE33DB8F6A74FDBAAD /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 4025987761D8603D7A3EF403 /* Pods_SpecToolsExampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SpecToolsExampleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 46141C4B85516DCBD9FA4DC0 /* Pods_TVExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TVExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 4EEB39D321882998004D9295 /* SwipeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwipeViewController.swift; sourceTree = ""; }; 573468F956F5B1FC134B10EA /* Pods-TVExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TVExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TVExample/Pods-TVExample.debug.xcconfig"; sourceTree = ""; }; 607FACD01AFB9204008FA782 /* SpecToolsExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SpecToolsExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -77,10 +80,11 @@ A4924F5F25B255B44D41CD79 /* Pods-SpecToolsExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SpecToolsExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-SpecToolsExample/Pods-SpecToolsExample.release.xcconfig"; sourceTree = ""; }; ACE67D9AE3CBE275C0B5F91A /* Pods-SpecTools_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SpecTools_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-SpecTools_Example/Pods-SpecTools_Example.release.xcconfig"; sourceTree = ""; }; B7CF033E9DE2320B8E03AF79 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; - CEB96607FEDF79B741ECC275 /* SpecTools.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SpecTools.podspec; path = ../SpecTools.podspec; sourceTree = ""; }; + CEB96607FEDF79B741ECC275 /* SpecTools.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SpecTools.podspec; path = ../SpecTools.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; D1BC6C635B933789988F6829 /* Pods-SpecToolsExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SpecToolsExampleTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-SpecToolsExampleTests/Pods-SpecToolsExampleTests.release.xcconfig"; sourceTree = ""; }; DA48DE5F6072FA17B587A4CF /* Pods_SpecToolsExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SpecToolsExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; DA6621D12D0DCFD3C5921A21 /* SwipeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeView.swift; sourceTree = ""; }; + DA68C9608FD96EFF171ED130 /* SwipeViewControllerSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeViewControllerSpec.swift; sourceTree = ""; }; DA6F41B96D384A3274587E76 /* LabeledView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabeledView.swift; sourceTree = ""; }; DB1653D35AA1B0DA36A7E500 /* Pods-SpecTools_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SpecTools_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-SpecTools_Tests/Pods-SpecTools_Tests.release.xcconfig"; sourceTree = ""; }; DFB0C922BA6451420392BB90 /* Pods-TVExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TVExampleTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TVExampleTests/Pods-TVExampleTests.release.xcconfig"; sourceTree = ""; }; @@ -139,9 +143,10 @@ isa = PBXGroup; children = ( 1504FD4C1F50C6520000D7FA /* BasicSpec.swift */, - 1504FD4D1F50C6520000D7FA /* ViewControllerSpec.swift */, - 15074DEE1F667F0F00E06BD0 /* TableViewControllerSpec.swift */, F4A8DD841FAB3FA000237CF6 /* CollectionViewControllerSpecs.swift */, + DA68C9608FD96EFF171ED130 /* SwipeViewControllerSpec.swift */, + 15074DEE1F667F0F00E06BD0 /* TableViewControllerSpec.swift */, + 1504FD4D1F50C6520000D7FA /* ViewControllerSpec.swift */, 1504FD441F50C5E10000D7FA /* Info.plist */, ); path = SpecToolsExampleTests; @@ -173,6 +178,7 @@ 607FACD71AFB9204008FA782 /* ViewController.swift */, 15074DE91F6443D400E06BD0 /* TableViewController.swift */, F4A8DD801FAB3C3A00237CF6 /* CollectionViewController.swift */, + 4EEB39D321882998004D9295 /* SwipeViewController.swift */, ); name = "View controllers"; sourceTree = ""; @@ -622,6 +628,7 @@ 15074DEF1F667F0F00E06BD0 /* TableViewControllerSpec.swift in Sources */, 1504FD4E1F50C6520000D7FA /* BasicSpec.swift in Sources */, F4A8DD851FAB3FA000237CF6 /* CollectionViewControllerSpecs.swift in Sources */, + DA6C851CF48875F2E30AD9F7 /* SwipeViewControllerSpec.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -634,6 +641,7 @@ 15074DEA1F6443D400E06BD0 /* TableViewController.swift in Sources */, 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, F4A8DD811FAB3C3A00237CF6 /* CollectionViewController.swift in Sources */, + 4EEB39D421882998004D9295 /* SwipeViewController.swift in Sources */, DA62C52F3E9A07FA2E6034DA /* SwipeView.swift in Sources */, DA674C49DCD23F74F6B91984 /* LabeledView.swift in Sources */, ); diff --git a/Example/SpecTools/SwipeViewController.swift b/Example/SpecTools/SwipeViewController.swift new file mode 100644 index 0000000..728d8f2 --- /dev/null +++ b/Example/SpecTools/SwipeViewController.swift @@ -0,0 +1,65 @@ +import UIKit + +class SwipeViewController: UIViewController { + + var didSwipeUp: (() -> Void)? + var didSwipeLeft: (() -> Void)? + var didSwipeRight: (() -> Void)? + var didSwipeDown: (() -> Void)? + + var swipeView: SwipeView { return view as! SwipeView } + + // MARK: - Lifecycle + + override func loadView() { + view = SwipeView() + } + + override func viewDidLoad() { + super.viewDidLoad() + + setUpSwipeGestures() + } + + // MARK: - Private + + private func setUpSwipeGestures() { + setUpSwipeGesture(direction: .up, action: #selector(swipedUp), in: swipeView.upView) + setUpSwipeGesture(direction: .left, action: #selector(swipedLeft), in: swipeView.leftView) + setUpSwipeGesture(direction: .right, action: #selector(swipedRight), in: swipeView.rightView) + setUpSwipeGesture(direction: .down, action: #selector(swipedDown), in: swipeView.downView) + } + + // MARK: Actions + + private func setUpSwipeGesture(direction: UISwipeGestureRecognizer.Direction, action: Selector?, in view: UIView) { + let swipeGesture = UISwipeGestureRecognizer(target: self, action: action) + swipeGesture.direction = direction + view.addGestureRecognizer(swipeGesture) + } + + @objc + private func swipedUp() { + print("SWIPED UP") + didSwipeUp?() + } + + @objc + private func swipedLeft() { + print("SWIPED LEFT") + didSwipeLeft?() + } + + @objc + private func swipedRight() { + print("SWIPED RIGHT") + didSwipeRight?() + } + + @objc + private func swipedDown() { + print("SWIPED DOWN") + didSwipeDown?() + } + +} diff --git a/Example/SpecToolsExampleTests/SwipeViewControllerSpec.swift b/Example/SpecToolsExampleTests/SwipeViewControllerSpec.swift new file mode 100644 index 0000000..183b7eb --- /dev/null +++ b/Example/SpecToolsExampleTests/SwipeViewControllerSpec.swift @@ -0,0 +1,132 @@ +@testable import SpecToolsExample +import Nimble +import Quick +import SpecTools + +class SwipeViewControllerSpec: QuickSpec { + + override func spec() { + describe("SwipeViewController") { + var subject: SwipeViewController! + + beforeEach { + subject = SwipeViewController(nibName: nil, bundle: nil) + } + + afterEach { + subject = nil + } + + describe("view is loaded") { + beforeEach { + _ = subject.view + } + + describe("callbacks are configured") { + var swipedUpCount: Int = 0 + var swipedLeftCount: Int = 0 + var swipedRightCount: Int = 0 + var swipedDownCount: Int = 0 + + beforeEach { + subject.didSwipeUp = { swipedUpCount += 1 } + subject.didSwipeLeft = { swipedLeftCount += 1 } + subject.didSwipeRight = { swipedRightCount += 1 } + subject.didSwipeDown = { swipedDownCount += 1 } + } + + afterEach { + swipedUpCount = 0 + swipedLeftCount = 0 + swipedRightCount = 0 + swipedDownCount = 0 + + subject.didSwipeUp = nil + subject.didSwipeLeft = nil + subject.didSwipeRight = nil + subject.didSwipeDown = nil + } + + describe("when swipe up on upView") { + beforeEach { + subject.swipeView.upView.spec.action.triggerSwipe(direction: .up) + } + + it("should trigger didSwipeUp callback once") { + expect(swipedUpCount) == 1 + expect(swipedLeftCount) == 0 + expect(swipedRightCount) == 0 + expect(swipedDownCount) == 0 + } + } + + describe("when swipe left on leftView") { + beforeEach { + subject.swipeView.leftView.spec.action.triggerSwipe(direction: .left) + } + + it("should trigger didSwipeLeft callback once") { + expect(swipedUpCount) == 0 + expect(swipedLeftCount) == 1 + expect(swipedRightCount) == 0 + expect(swipedDownCount) == 0 + } + } + + describe("when swipe right on rightView") { + beforeEach { + subject.swipeView.rightView.spec.action.triggerSwipe(direction: .right) + } + + it("should trigger didSwipeRight callback once") { + expect(swipedUpCount) == 0 + expect(swipedLeftCount) == 0 + expect(swipedRightCount) == 1 + expect(swipedDownCount) == 0 + } + } + + describe("when swipe down on downView for the first time") { + beforeEach { + subject.swipeView.downView.spec.action.triggerSwipe(direction: .down) + } + + it("should trigger didSwipeDown callback once") { + expect(swipedUpCount) == 0 + expect(swipedLeftCount) == 0 + expect(swipedRightCount) == 0 + expect(swipedDownCount) == 1 + } + + describe("when swipe down on downView for the second time") { + beforeEach { + subject.swipeView.downView.spec.action.triggerSwipe(direction: .down) + } + + it("should trigger didSwipeDown callback for the second time") { + expect(swipedUpCount) == 0 + expect(swipedLeftCount) == 0 + expect(swipedRightCount) == 0 + expect(swipedDownCount) == 2 + } + } + } + + describe("when swipe up on downView") { + beforeEach { + subject.swipeView.downView.spec.action.triggerSwipe(direction: .up) + } + + it("should NOT trigger any callback") { + expect(swipedUpCount) == 0 + expect(swipedLeftCount) == 0 + expect(swipedRightCount) == 0 + expect(swipedDownCount) == 0 + } + } + } + } + } + } + +} diff --git a/SpecTools.podspec b/SpecTools.podspec index 450c369..3e63fef 100644 --- a/SpecTools.podspec +++ b/SpecTools.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'SpecTools' - s.version = '1.1.0' + s.version = '1.2.0' s.summary = 'Library that helps you write less code when testing your iOS apps.' s.description = 'Write less test code, this library contains a set of tools that are split in a few categories which have very specific helper functionality. All these are only available to their relevant elements.' diff --git a/SpecTools/Classes/Action/Action+UIGestureRecognizer.swift b/SpecTools/Classes/Action/Action+UIGestureRecognizer.swift index 6d6f305..db68504 100644 --- a/SpecTools/Classes/Action/Action+UIGestureRecognizer.swift +++ b/SpecTools/Classes/Action/Action+UIGestureRecognizer.swift @@ -13,11 +13,11 @@ public typealias TargetActionInfo = [(target: AnyObject, action: Selector)] #if os(iOS) - + extension Action where T: UIView { - + // MARK: UIView - + /// Simulate tap on a gesture recognizer /// - Parameter taps: Number of taps /// - Parameter touches: Number of touches @@ -33,38 +33,52 @@ public typealias TargetActionInfo = [(target: AnyObject, action: Selector)] } return self } - + + /// Simulate swipe on a gesture recognizer + /// - Parameter direction: Specify swipe direction: .up, .left, .right, .down + @discardableResult public func triggerSwipe(direction: UISwipeGestureRecognizer.Direction) -> Action { + guard element.isUserInteractionEnabled else { + fatalError("User interactions are disabled. Gesture recognizer can't be used.") + } + let recognizers = element.spec.find.all(gestureRecognizersOfType: UISwipeGestureRecognizer.self) + for recognizer in recognizers where recognizer.direction == direction { + recognizer.spec.action.execute() + } + + return self + } + } - - + + extension Action where T: UIGestureRecognizer { - + // MARK: UIGestureRecognizer - + /// Returns all actions and selectors for a gesture recognizer /// This method uses private API's and will most likely cause your app to be rejected if used outside of your test target /// - Returns: [(target: AnyObject, action: Selector)] Array of action/selector tuples public func getTargetInfo() -> TargetActionInfo { var targetsInfo: TargetActionInfo = [] - + if let targets = element.value(forKeyPath: "_targets") as? [NSObject] { for target in targets { // Getting selector by parsing the description string of a UIGestureRecognizerTarget let selectorString = String.init(describing: target).components(separatedBy: ", ").first!.replacingOccurrences(of: "(action=", with: "") let selector = NSSelectorFromString(selectorString) - + // Getting target from iVars let targetActionPairClass: AnyClass = NSClassFromString("UIGestureRecognizerTarget")! let targetIvar: Ivar = class_getInstanceVariable(targetActionPairClass, "_target")! let targetObject: AnyObject = object_getIvar(target, targetIvar) as AnyObject - + targetsInfo.append((target: targetObject, action: selector)) } } - + return targetsInfo } - + /// Executes all targets on a specific gesture recognizer @discardableResult public func execute() -> Action { let targetsInfo = element.spec.action.getTargetInfo() @@ -73,7 +87,7 @@ public typealias TargetActionInfo = [(target: AnyObject, action: Selector)] } return self } - + } - + #endif From 509705f0a802119eeabe016dfccc7b0e24266cbf Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Tue, 30 Oct 2018 09:32:01 +0100 Subject: [PATCH 04/10] Update swift to 4.2 in .swift-version file --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 5186d07..bf77d54 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.0 +4.2 From 02887e72b57dface5b5fa5712b2904b4b18e9018 Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Tue, 30 Oct 2018 09:34:06 +0100 Subject: [PATCH 05/10] Update README.md according to API changes --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 24a3e1d..e6ea68e 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,11 @@ view.spec.action.triggerTap() view.spec.action.triggerTap(taps: 3, touches: 2) ``` ------ +Simulate swipe on a view with UISwipeGestureRecognizer(s) +```Swift +view.spec.action.triggerSwipe(direction: .up) +``` +------ Simulate tap on a UITableView cell ```Swift tableView.spec.action.tap(row: 6) From e892b5fe2e8162e67c7201bd342cfc5edc0b017b Mon Sep 17 00:00:00 2001 From: Ondrej Rafaj Date: Tue, 30 Oct 2018 09:41:07 +0000 Subject: [PATCH 06/10] not breaking change so only up with a version number --- SpecTools.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpecTools.podspec b/SpecTools.podspec index 3e63fef..c1e7851 100644 --- a/SpecTools.podspec +++ b/SpecTools.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'SpecTools' - s.version = '1.2.0' + s.version = '1.1.1' s.summary = 'Library that helps you write less code when testing your iOS apps.' s.description = 'Write less test code, this library contains a set of tools that are split in a few categories which have very specific helper functionality. All these are only available to their relevant elements.' From 29abd7f48e588701b72e49a7a8b25bc2777bf06f Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Tue, 30 Oct 2018 10:49:22 +0100 Subject: [PATCH 07/10] Update all usages after changing version from 1.2.0 to 1.1.1 --- Example/Podfile.lock | 4 ++-- Example/Pods/Local Podspecs/SpecTools.podspec.json | 4 ++-- Example/Pods/Manifest.lock | 4 ++-- Example/Pods/Target Support Files/SpecTools-iOS/Info.plist | 2 +- Example/Pods/Target Support Files/SpecTools-tvOS/Info.plist | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 0895461..817a504 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -2,7 +2,7 @@ PODS: - Nimble (7.3.1) - Quick (1.3.2) - SnapKit (4.2.0) - - SpecTools (1.2.0) + - SpecTools (1.1.1) DEPENDENCIES: - Nimble @@ -24,7 +24,7 @@ SPEC CHECKSUMS: Nimble: 04f732da099ea4d153122aec8c2a88fd0c7219ae Quick: 2623cb30d7a7f41ca62f684f679586558f483d46 SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a - SpecTools: 379345b4fcee92e578817ff0aeb0c2099865d52a + SpecTools: 76f96eba2e12f3f9d374ac6b75ce38da97b6ad66 PODFILE CHECKSUM: 75022a650debfd62f749637ced8ed249be1a9563 diff --git a/Example/Pods/Local Podspecs/SpecTools.podspec.json b/Example/Pods/Local Podspecs/SpecTools.podspec.json index cf3dff4..56d3e85 100644 --- a/Example/Pods/Local Podspecs/SpecTools.podspec.json +++ b/Example/Pods/Local Podspecs/SpecTools.podspec.json @@ -1,6 +1,6 @@ { "name": "SpecTools", - "version": "1.2.0", + "version": "1.1.1", "summary": "Library that helps you write less code when testing your iOS apps.", "description": "Write less test code, this library contains a set of tools that are split in a few categories which have very specific helper functionality. All these are only available to their relevant elements.", "homepage": "https://github.com/manGoweb/SpecTools", @@ -13,7 +13,7 @@ }, "source": { "git": "https://github.com/manGoweb/SpecTools.git", - "tag": "1.2.0" + "tag": "1.1.1" }, "social_media_url": "https://twitter.com/rafiki270", "platforms": { diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 0895461..817a504 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -2,7 +2,7 @@ PODS: - Nimble (7.3.1) - Quick (1.3.2) - SnapKit (4.2.0) - - SpecTools (1.2.0) + - SpecTools (1.1.1) DEPENDENCIES: - Nimble @@ -24,7 +24,7 @@ SPEC CHECKSUMS: Nimble: 04f732da099ea4d153122aec8c2a88fd0c7219ae Quick: 2623cb30d7a7f41ca62f684f679586558f483d46 SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a - SpecTools: 379345b4fcee92e578817ff0aeb0c2099865d52a + SpecTools: 76f96eba2e12f3f9d374ac6b75ce38da97b6ad66 PODFILE CHECKSUM: 75022a650debfd62f749637ced8ed249be1a9563 diff --git a/Example/Pods/Target Support Files/SpecTools-iOS/Info.plist b/Example/Pods/Target Support Files/SpecTools-iOS/Info.plist index 2a9158a..d60f138 100644 --- a/Example/Pods/Target Support Files/SpecTools-iOS/Info.plist +++ b/Example/Pods/Target Support Files/SpecTools-iOS/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.2.0 + 1.1.1 CFBundleSignature ???? CFBundleVersion diff --git a/Example/Pods/Target Support Files/SpecTools-tvOS/Info.plist b/Example/Pods/Target Support Files/SpecTools-tvOS/Info.plist index 2a9158a..d60f138 100644 --- a/Example/Pods/Target Support Files/SpecTools-tvOS/Info.plist +++ b/Example/Pods/Target Support Files/SpecTools-tvOS/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.2.0 + 1.1.1 CFBundleSignature ???? CFBundleVersion From 80c4bd879883beaae95ee1af5d7672ac359ae1a9 Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Tue, 30 Oct 2018 10:51:33 +0100 Subject: [PATCH 08/10] Update README.md --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e6ea68e..c1076d8 100644 --- a/README.md +++ b/README.md @@ -170,11 +170,6 @@ view.spec.action.triggerTap() view.spec.action.triggerTap(taps: 3, touches: 2) ``` ------ -Simulate swipe on a view with UISwipeGestureRecognizer(s) -```Swift -view.spec.action.triggerSwipe(direction: .up) -``` ------- Simulate tap on a UITableView cell ```Swift tableView.spec.action.tap(row: 6) @@ -189,6 +184,14 @@ collectionView.spec.action.tap(item: 3) collectionView.spec.action.tap(item: 2, section: 1) ``` +#### Simulating swipes + +Simulate swipe on a view with UISwipeGestureRecognizer(s) +```Swift +view.spec.action.triggerSwipe(direction: .up) +``` +------ + #### Executing gesture recognizers (not available on tvOS) Execute action on any UIGestureRecognizer From 991f67bbcc2314bb83f86e63d2c51e3ef460f6ed Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Tue, 30 Oct 2018 10:59:44 +0100 Subject: [PATCH 09/10] Remove File.swift --- File.swift | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 File.swift diff --git a/File.swift b/File.swift deleted file mode 100644 index a7b4810..0000000 --- a/File.swift +++ /dev/null @@ -1,9 +0,0 @@ -// -// File.swift -// Pods -// -// Created by Ondrej Rafaj on 25/08/2017. -// -// - -import Foundation From 39396704c355ad9a672a33196a534561d4c4320f Mon Sep 17 00:00:00 2001 From: Mateusz Szklarek Date: Tue, 30 Oct 2018 11:04:06 +0100 Subject: [PATCH 10/10] Update README.md with new contributors --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c1076d8..2d75844 100644 --- a/README.md +++ b/README.md @@ -496,8 +496,9 @@ viewController.spec.prepare.assignMockNavigationController() ## Contributors - Jonathan Augele, jona2k5@yahoo.com - - David Harris, davidaharris@outlook.com +- Karol Kozub, karol.kozub@gmail.com +- Mateusz Szklarek, mateusz.szklarek@icloud.com ## License