From 45636986fa41bb57409f543d7b6549b8a8de937d Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 23 May 2017 02:15:47 +0400 Subject: [PATCH] Initial Sparkle setup (#37) --- .gitignore | 3 ++ CHANGELOG.md | 1 + FBSnapshotsViewer.xcodeproj/project.pbxproj | 18 ++++++++-- .../Extensions/SUUpdater+Updater.swift | 16 +++++++++ FBSnapshotsViewer/Info.plist | 6 +++- .../Menu/MenuModuleInterface.swift | 1 + .../Menu/Presenter/MenuPresenter.swift | 9 ++++- .../Menu/User Interface/MenuController.swift | 4 +++ .../User Interface/MenuStatusItemMenu.swift | 8 ++++- FBSnapshotsViewer/Protocols/Updater.swift | 13 +++++++ FBSnapshotsViewer/dsa_pub.pem | 36 +++++++++++++++++++ .../MenuControllerSpec.swift | 20 +++++++++++ .../MenuPresenterSpec.swift | 14 +++++++- .../MenuStatusItemMenuSpec.swift | 15 ++++++++ Podfile | 1 + Podfile.lock | 5 ++- .../AutoMockable.generated.swift | 20 +++++++++++ 17 files changed, 183 insertions(+), 7 deletions(-) create mode 100644 FBSnapshotsViewer/Extensions/SUUpdater+Updater.swift create mode 100644 FBSnapshotsViewer/Protocols/Updater.swift create mode 100644 FBSnapshotsViewer/dsa_pub.pem diff --git a/.gitignore b/.gitignore index 1a58daf..0ba3af3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # OS X .DS_Store +# Sparkle +dsa_priv.pem + Design # Xcode diff --git a/CHANGELOG.md b/CHANGELOG.md index 8547eba..15649b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 0.5.0 (Next) * Your contribution here. +* [#37](https://github.com/Antondomashnev/FBSnapshotsViewer/pull/37): Add AppCode snapshot testing support - [@antondomashnev](https://github.com/antondomashnev). ### 0.4.0 (21.05.2017) diff --git a/FBSnapshotsViewer.xcodeproj/project.pbxproj b/FBSnapshotsViewer.xcodeproj/project.pbxproj index 17bed0e..cdfdfb8 100644 --- a/FBSnapshotsViewer.xcodeproj/project.pbxproj +++ b/FBSnapshotsViewer.xcodeproj/project.pbxproj @@ -42,6 +42,8 @@ 6D3000471EBFBE86005B6103 /* PreferencesWireframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D3000461EBFBE86005B6103 /* PreferencesWireframe.swift */; }; 6D3000491EBFBE97005B6103 /* PreferencesModuleInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D3000481EBFBE97005B6103 /* PreferencesModuleInterface.swift */; }; 6D30004B1EBFBECA005B6103 /* PreferencesPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D30004A1EBFBECA005B6103 /* PreferencesPresenter.swift */; }; + 6D3003B21ED20B13000CCAC8 /* Updater.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D3003B11ED20B13000CCAC8 /* Updater.swift */; }; + 6D3003B41ED20B36000CCAC8 /* SUUpdater+Updater.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D3003B31ED20B36000CCAC8 /* SUUpdater+Updater.swift */; }; 6D33A9D21EB4D38D0089AEDD /* ApplicationSnapshotTestResultListenerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D33A9D11EB4D38D0089AEDD /* ApplicationSnapshotTestResultListenerSpec.swift */; }; 6D33A9D41EB4DAF60089AEDD /* AutoHashable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D33A9D31EB4DAF60089AEDD /* AutoHashable.swift */; }; 6D33A9D61EB4DB650089AEDD /* AutoHashable.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D33A9D51EB4DB650089AEDD /* AutoHashable.generated.swift */; }; @@ -119,6 +121,7 @@ 6DF15B751E662CBD00DFA181 /* TestResultsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DF15B741E662CBD00DFA181 /* TestResultsController.swift */; }; 6DF15B771E662CCC00DFA181 /* TestResultsUserInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DF15B761E662CCC00DFA181 /* TestResultsUserInterface.swift */; }; 6DF15B7A1E662E0500DFA181 /* TestResultsWireframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DF15B791E662E0500DFA181 /* TestResultsWireframe.swift */; }; + 6DF7ED851ED3880800A54C54 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 6DF7ED841ED3880800A54C54 /* dsa_pub.pem */; }; 8CDDC590BF4FDD5C704BD750 /* Pods_FBSnapshotsViewer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CDDF30470ECABA40C67FCA8 /* Pods_FBSnapshotsViewer.framework */; }; 9ECFB3D932C1A604705C3060 /* Pods_FBSnapshotsViewerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6AB66AD06A529A00E998FD8B /* Pods_FBSnapshotsViewerTests.framework */; }; /* End PBXBuildFile section */ @@ -171,6 +174,8 @@ 6D3000461EBFBE86005B6103 /* PreferencesWireframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesWireframe.swift; sourceTree = ""; }; 6D3000481EBFBE97005B6103 /* PreferencesModuleInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesModuleInterface.swift; sourceTree = ""; }; 6D30004A1EBFBECA005B6103 /* PreferencesPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesPresenter.swift; sourceTree = ""; }; + 6D3003B11ED20B13000CCAC8 /* Updater.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Updater.swift; sourceTree = ""; }; + 6D3003B31ED20B36000CCAC8 /* SUUpdater+Updater.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SUUpdater+Updater.swift"; sourceTree = ""; }; 6D33A9D11EB4D38D0089AEDD /* ApplicationSnapshotTestResultListenerSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplicationSnapshotTestResultListenerSpec.swift; sourceTree = ""; }; 6D33A9D31EB4DAF60089AEDD /* AutoHashable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutoHashable.swift; sourceTree = ""; }; 6D33A9D51EB4DB650089AEDD /* AutoHashable.generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutoHashable.generated.swift; sourceTree = ""; }; @@ -252,6 +257,7 @@ 6DF15B741E662CBD00DFA181 /* TestResultsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestResultsController.swift; sourceTree = ""; }; 6DF15B761E662CCC00DFA181 /* TestResultsUserInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestResultsUserInterface.swift; sourceTree = ""; }; 6DF15B791E662E0500DFA181 /* TestResultsWireframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestResultsWireframe.swift; sourceTree = ""; }; + 6DF7ED841ED3880800A54C54 /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = ""; }; 9EACAED9B9A9448DDC8DDF8F /* Pods-FBSnapshotsViewerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FBSnapshotsViewerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-FBSnapshotsViewerTests/Pods-FBSnapshotsViewerTests.release.xcconfig"; sourceTree = ""; }; B17C48E1D2FE2D15D9563E9C /* Pods-FBSnapshotsViewer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FBSnapshotsViewer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FBSnapshotsViewer/Pods-FBSnapshotsViewer.debug.xcconfig"; sourceTree = ""; }; E5BEA4ED9D938AA805237841 /* Pods-FBSnapshotsViewer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FBSnapshotsViewer.release.xcconfig"; path = "Pods/Target Support Files/Pods-FBSnapshotsViewer/Pods-FBSnapshotsViewer.release.xcconfig"; sourceTree = ""; }; @@ -421,6 +427,7 @@ 6D4724C01E3E9F2400F38161 /* Assets.xcassets */, 6D4724C21E3E9F2400F38161 /* Main.storyboard */, 6D4724C51E3E9F2400F38161 /* Info.plist */, + 6DF7ED841ED3880800A54C54 /* dsa_pub.pem */, ); path = FBSnapshotsViewer; sourceTree = ""; @@ -531,6 +538,7 @@ 6D8362761E79422D000794AE /* AutoMockable.swift */, 6D8BD71E1EB13949004928F7 /* Application.swift */, 6D789CDD1EC3B6CC00EEF7EE /* AutoCases.swift */, + 6D3003B11ED20B13000CCAC8 /* Updater.swift */, ); path = Protocols; sourceTree = ""; @@ -539,6 +547,7 @@ isa = PBXGroup; children = ( 6D8BF2BC1ED0B78700C368D1 /* String+HTML.swift */, + 6D3003B31ED20B36000CCAC8 /* SUUpdater+Updater.swift */, ); path = Extensions; sourceTree = ""; @@ -768,6 +777,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 6DF7ED851ED3880800A54C54 /* dsa_pub.pem in Resources */, 6D4724C11E3E9F2400F38161 /* Assets.xcassets in Resources */, 6D848C571E68D0C90000FC1E /* TestResultCell.xib in Resources */, 6D4724C41E3E9F2400F38161 /* Main.storyboard in Resources */, @@ -948,6 +958,7 @@ 6D33A9D61EB4DB650089AEDD /* AutoHashable.generated.swift in Sources */, 6D7D78FE1EAFF2430001C1A0 /* SnapshotTestResultFactory.swift in Sources */, 6D789CDA1EC3B38C00EEF7EE /* DerivedDataFolderType.swift in Sources */, + 6D3003B41ED20B36000CCAC8 /* SUUpdater+Updater.swift in Sources */, 6DF15B7A1E662E0500DFA181 /* TestResultsWireframe.swift in Sources */, 6D0AF6B21EC50B6300F9A410 /* AppProcessInfo.swift in Sources */, 6D65C6301E62F3AB00733118 /* ApplicationSnapshotTestResultListener.swift in Sources */, @@ -972,6 +983,7 @@ 6DA1BF981E7755110017D47B /* Colors.swift in Sources */, 6D789CE61EC3BFA900EEF7EE /* Configuration.swift in Sources */, 6DBD99DB1E7AB3D400E1714E /* FileWatcherFactory.swift in Sources */, + 6D3003B21ED20B13000CCAC8 /* Updater.swift in Sources */, 6D33A9D41EB4DAF60089AEDD /* AutoHashable.swift in Sources */, 6DDFBDA61E64E53D00DFC0A4 /* MenuStatusItemMenu.swift in Sources */, 6DE347751E47D8CE004147DF /* MenuController.swift in Sources */, @@ -1149,6 +1161,7 @@ CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = XZ2J8VAMV6; + GCC_GENERATE_TEST_COVERAGE_FILES = YES; INFOPLIST_FILE = FBSnapshotsViewer/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; OTHER_CODE_SIGN_FLAGS = "--deep"; @@ -1169,13 +1182,14 @@ CODE_SIGN_IDENTITY = "Developer ID Application"; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = XZ2J8VAMV6; + GCC_GENERATE_TEST_COVERAGE_FILES = YES; INFOPLIST_FILE = FBSnapshotsViewer/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; OTHER_CODE_SIGN_FLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.antondomashnev.FBSnapshotsViewer; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE = "1554e469-0170-445a-8d37-edc1e783edf6"; - PROVISIONING_PROFILE_SPECIFIER = "mac_production_ com.antondomashnev.FBSnapshotsView"; + PROVISIONING_PROFILE = "a27fb3d0-5018-48f4-aa1a-5c52a85c926e"; + PROVISIONING_PROFILE_SPECIFIER = mac_production_com.antondomashnev.FBSnapshotsView; SWIFT_VERSION = 3.0; }; name = Release; diff --git a/FBSnapshotsViewer/Extensions/SUUpdater+Updater.swift b/FBSnapshotsViewer/Extensions/SUUpdater+Updater.swift new file mode 100644 index 0000000..2198dd4 --- /dev/null +++ b/FBSnapshotsViewer/Extensions/SUUpdater+Updater.swift @@ -0,0 +1,16 @@ +// +// SUUpdater+Updater.swift +// FBSnapshotsViewer +// +// Created by Anton Domashnev on 21.05.17. +// Copyright © 2017 Anton Domashnev. All rights reserved. +// + +import Foundation +import Sparkle + +extension SUUpdater: Updater { + func checkForUpdates() { + self.checkForUpdates(nil) + } +} diff --git a/FBSnapshotsViewer/Info.plist b/FBSnapshotsViewer/Info.plist index 8631ccf..dae4507 100644 --- a/FBSnapshotsViewer/Info.plist +++ b/FBSnapshotsViewer/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 0.5.0 CFBundleVersion - 1 + 3 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement @@ -30,5 +30,9 @@ Main NSPrincipalClass NSApplication + SUFeedURL + https://whispering-savannah-78358.herokuapp.com/FBSnapshotsViewer/appcast.xml + SUPublicDSAKeyFile + dsa_pub.pem diff --git a/FBSnapshotsViewer/Menu/MenuModuleInterface.swift b/FBSnapshotsViewer/Menu/MenuModuleInterface.swift index 2e66203..09f1c80 100644 --- a/FBSnapshotsViewer/Menu/MenuModuleInterface.swift +++ b/FBSnapshotsViewer/Menu/MenuModuleInterface.swift @@ -13,5 +13,6 @@ protocol MenuModuleInterface: class, AutoMockable { func showTestResults() func showPreferences() func showApplicationMenu() + func checkForUpdates() func quit() } diff --git a/FBSnapshotsViewer/Menu/Presenter/MenuPresenter.swift b/FBSnapshotsViewer/Menu/Presenter/MenuPresenter.swift index 18336c8..73c0461 100644 --- a/FBSnapshotsViewer/Menu/Presenter/MenuPresenter.swift +++ b/FBSnapshotsViewer/Menu/Presenter/MenuPresenter.swift @@ -7,22 +7,29 @@ // import Cocoa +import Sparkle class MenuPresenter { fileprivate let application: Application + fileprivate let updater: Updater let configuration: Configuration var wireframe: MenuWireframe? var interactor: MenuInteractorInput? weak var userInterface: MenuUserInterface? - init(configuration: Configuration = Configuration.default(), application: Application = NSApp) { + init(configuration: Configuration = Configuration.default(), application: Application = NSApp, updater: Updater = SUUpdater.shared()) { self.application = application self.configuration = configuration + self.updater = updater } } // MARK: - MenuModuleInterface extension MenuPresenter: MenuModuleInterface { + func checkForUpdates() { + updater.checkForUpdates() + } + func showTestResults() { guard let testResults = interactor?.foundTestResults, !testResults.isEmpty else { return diff --git a/FBSnapshotsViewer/Menu/User Interface/MenuController.swift b/FBSnapshotsViewer/Menu/User Interface/MenuController.swift index ed6b1a4..487c525 100644 --- a/FBSnapshotsViewer/Menu/User Interface/MenuController.swift +++ b/FBSnapshotsViewer/Menu/User Interface/MenuController.swift @@ -63,4 +63,8 @@ extension MenuController: MenuStatusItemMenuTarget { func menuStatusItemMenu(_ menu: NSMenu, preferencesItemClicked: NSMenuItem) { eventHandler?.showPreferences() } + + func menuStatusItemMenu(_ menu: NSMenu, checkForUpdatesItemClicked: NSMenuItem) { + eventHandler?.checkForUpdates() + } } diff --git a/FBSnapshotsViewer/Menu/User Interface/MenuStatusItemMenu.swift b/FBSnapshotsViewer/Menu/User Interface/MenuStatusItemMenu.swift index 3b08793..b54e7c9 100644 --- a/FBSnapshotsViewer/Menu/User Interface/MenuStatusItemMenu.swift +++ b/FBSnapshotsViewer/Menu/User Interface/MenuStatusItemMenu.swift @@ -11,6 +11,7 @@ import Cocoa protocol MenuStatusItemMenuTarget: class { func menuStatusItemMenu(_ menu: NSMenu, quitItemClicked: NSMenuItem) func menuStatusItemMenu(_ menu: NSMenu, preferencesItemClicked: NSMenuItem) + func menuStatusItemMenu(_ menu: NSMenu, checkForUpdatesItemClicked: NSMenuItem) } class MenuStatusItemMenu: NSMenu { @@ -31,7 +32,8 @@ class MenuStatusItemMenu: NSMenu { func buildUp() { let quitItem = NSMenuItem(title: "Quit", action: #selector(quitItemClicked(sender:)), keyEquivalent: "Q") let preferencesItem = NSMenuItem(title: "Preferences", action: #selector(preferencesItemClicked(sender:)), keyEquivalent: "P") - let items = [preferencesItem, quitItem] + let checkForUpdates = NSMenuItem(title: "Check for Updates", action: #selector(checkForUpdatesItemClicked(sender:)), keyEquivalent: "U") + let items = [preferencesItem, checkForUpdates, quitItem] for item in items { item.target = self addItem(item) @@ -47,4 +49,8 @@ class MenuStatusItemMenu: NSMenu { @objc func quitItemClicked(sender: NSMenuItem) { target?.menuStatusItemMenu(self, quitItemClicked: sender) } + + @objc func checkForUpdatesItemClicked(sender: NSMenuItem) { + target?.menuStatusItemMenu(self, checkForUpdatesItemClicked: sender) + } } diff --git a/FBSnapshotsViewer/Protocols/Updater.swift b/FBSnapshotsViewer/Protocols/Updater.swift new file mode 100644 index 0000000..235d228 --- /dev/null +++ b/FBSnapshotsViewer/Protocols/Updater.swift @@ -0,0 +1,13 @@ +// +// Updater.swift +// FBSnapshotsViewer +// +// Created by Anton Domashnev on 21.05.17. +// Copyright © 2017 Anton Domashnev. All rights reserved. +// + +import Foundation + +protocol Updater: AutoMockable { + func checkForUpdates() +} diff --git a/FBSnapshotsViewer/dsa_pub.pem b/FBSnapshotsViewer/dsa_pub.pem new file mode 100644 index 0000000..e0f232c --- /dev/null +++ b/FBSnapshotsViewer/dsa_pub.pem @@ -0,0 +1,36 @@ +-----BEGIN PUBLIC KEY----- +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 +o1fwsl3Dbje2UrNoLRJW +-----END PUBLIC KEY----- diff --git a/FBSnapshotsViewerTests/MenuControllerSpec.swift b/FBSnapshotsViewerTests/MenuControllerSpec.swift index 4832ce6..6c01c30 100644 --- a/FBSnapshotsViewerTests/MenuControllerSpec.swift +++ b/FBSnapshotsViewerTests/MenuControllerSpec.swift @@ -87,6 +87,26 @@ class MenuControllerSpec: QuickSpec { } } + describe("menuStatusItemMenu.preferencesItemClicked") { + beforeEach { + menuController.menuStatusItemMenu(NSMenu(), preferencesItemClicked: NSMenuItem()) + } + + it("quits") { + expect(eventHandler.showPreferencesCalled).to(beTrue()) + } + } + + describe("menuStatusItemMenu.checkForUpdatesItemClicked") { + beforeEach { + menuController.menuStatusItemMenu(NSMenu(), checkForUpdatesItemClicked: NSMenuItem()) + } + + it("quits") { + expect(eventHandler.checkForUpdatesCalled).to(beTrue()) + } + } + describe(".handleIconMouseEvent") { context("when rightMouseUp") { beforeEach { diff --git a/FBSnapshotsViewerTests/MenuPresenterSpec.swift b/FBSnapshotsViewerTests/MenuPresenterSpec.swift index b1e3fe0..7434065 100644 --- a/FBSnapshotsViewerTests/MenuPresenterSpec.swift +++ b/FBSnapshotsViewerTests/MenuPresenterSpec.swift @@ -34,20 +34,32 @@ class MenuPresenterSpec: QuickSpec { var presenter: MenuPresenter! var interactor: MenuInteractorInputMock! var wireframe: MenuPresenter_MockMenuWireframe! + var updater: UpdaterMock! beforeEach { + updater = UpdaterMock() derivedDataFolder = DerivedDataFolder.xcodeCustom(path: "Users/antondomashnev/Library/Xcode/temporaryFolder") configuration = FBSnapshotsViewer.Configuration(derivedDataFolder: derivedDataFolder) application = ApplicationMock() wireframe = MenuPresenter_MockMenuWireframe() interactor = MenuInteractorInputMock() - presenter = MenuPresenter(configuration: configuration, application: application) + presenter = MenuPresenter(configuration: configuration, application: application, updater: updater) userInterface = MenuUserInterfaceMock() presenter.userInterface = userInterface presenter.interactor = interactor presenter.wireframe = wireframe } + describe(".checkForUpdates") { + beforeEach { + presenter.checkForUpdates() + } + + it("checks for updaters") { + expect(updater.checkForUpdatesCalled).to(beTrue()) + } + } + describe(".showPreferences") { beforeEach { presenter.showPreferences() diff --git a/FBSnapshotsViewerTests/MenuStatusItemMenuSpec.swift b/FBSnapshotsViewerTests/MenuStatusItemMenuSpec.swift index cefdf6a..10effae 100644 --- a/FBSnapshotsViewerTests/MenuStatusItemMenuSpec.swift +++ b/FBSnapshotsViewerTests/MenuStatusItemMenuSpec.swift @@ -21,6 +21,11 @@ class MenuStatusItemMenu_MockMenuStatusItemMenuTarget: MenuStatusItemMenuTarget func menuStatusItemMenu(_ menu: NSMenu, preferencesItemClicked: NSMenuItem) { menuStatusItemMenuPreferencesItemClickedCalled = true } + + var menuStatusItemMenuCheckForUpdatesItemClickedCalled: Bool = false + func menuStatusItemMenu(_ menu: NSMenu, checkForUpdatesItemClicked: NSMenuItem) { + menuStatusItemMenuCheckForUpdatesItemClickedCalled = true + } } class MenuStatusItemMenuSpec: QuickSpec { @@ -43,6 +48,16 @@ class MenuStatusItemMenuSpec: QuickSpec { } } + describe(".checkForUpdatesItemClicked") { + beforeEach { + itemMenu.checkForUpdatesItemClicked(sender: NSMenuItem(title: "Check for Updates", action: nil, keyEquivalent: "U")) + } + + it("notifies target") { + expect(target.menuStatusItemMenuCheckForUpdatesItemClickedCalled).to(beTrue()) + } + } + describe(".quitItemClicked") { beforeEach { itemMenu.quitItemClicked(sender: NSMenuItem(title: "Quit", action: nil, keyEquivalent: "Q")) diff --git a/Podfile b/Podfile index 6d66352..aff2705 100644 --- a/Podfile +++ b/Podfile @@ -7,6 +7,7 @@ target 'FBSnapshotsViewer' do pod 'Sourcery', '~> 0.5' pod 'SwiftGen', '~> 4.2' pod 'SwiftLint', '~> 0.16' + pod 'Sparkle', '~> 1.17' target 'FBSnapshotsViewerTests' do inherit! :search_paths pod 'Quick', '~> 1.0' diff --git a/Podfile.lock b/Podfile.lock index ff4ffbf..4b626f1 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -3,6 +3,7 @@ PODS: - Nimble (6.1.0) - Quick (1.1.0) - Sourcery (0.6.0) + - Sparkle (1.17.0) - SwiftGen (4.2.1) - SwiftLint (0.18.1) @@ -11,6 +12,7 @@ DEPENDENCIES: - Nimble (~> 6.0) - Quick (~> 1.0) - Sourcery (~> 0.5) + - Sparkle (~> 1.17) - SwiftGen (~> 4.2) - SwiftLint (~> 0.16) @@ -19,9 +21,10 @@ SPEC CHECKSUMS: Nimble: c53e6903fee94041b90ded74f135820437d8bf59 Quick: dafc587e21eed9f4cab3249b9f9015b0b7a7f71d Sourcery: b3a93fcdf9c256feeb16e85f4d1bbf46baa42464 + Sparkle: ccfb47699feea7b40b51cf3176f69404e5b1da6c SwiftGen: 2ba2a88fc6130b96e38e2baa0029e4bd222ffd85 SwiftLint: b467d08f5b25dc3b3cfed243d8e1b74b91714c67 -PODFILE CHECKSUM: 5d4b37143080129c1708e4b2f45da77b74d4d90e +PODFILE CHECKSUM: 034b6075c300cb474339b98158a1dd8b42b6b3c6 COCOAPODS: 1.2.1 diff --git a/Vendor/Sourcery/CodeGenerated/AutoMockable.generated.swift b/Vendor/Sourcery/CodeGenerated/AutoMockable.generated.swift index 77c96f5..adccfef 100644 --- a/Vendor/Sourcery/CodeGenerated/AutoMockable.generated.swift +++ b/Vendor/Sourcery/CodeGenerated/AutoMockable.generated.swift @@ -173,6 +173,14 @@ class MenuModuleInterfaceMock: MenuModuleInterface { showApplicationMenuCalled = true } + //MARK: - checkForUpdates + + var checkForUpdatesCalled = false + + func checkForUpdates() { + + checkForUpdatesCalled = true + } //MARK: - quit var quitCalled = false @@ -379,3 +387,15 @@ class TestResultsUserInterfaceMock: TestResultsUserInterface { showReceivedTestResults = testResults } } +class UpdaterMock: Updater { + + + //MARK: - checkForUpdates + + var checkForUpdatesCalled = false + + func checkForUpdates() { + + checkForUpdatesCalled = true + } +}