Skip to content

Commit

Permalink
Merge pull request #319 from wordpress-mobile/move-from-specta-to-quick
Browse files Browse the repository at this point in the history
Rewrite one test to move away from Specta
  • Loading branch information
crazytonyli authored Nov 14, 2022
2 parents b8058f6 + bea05fa commit 346953e
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 162 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ _None._

- Add this changelog entry about changelog itself [#317]
- Remove FormatterKit [#320]
- Move away from Specta, use Quick instead [#319]
3 changes: 1 addition & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ target 'WordPressSharedTests' do
pod 'OHHTTPStubs', '~> 9.0'
pod 'OHHTTPStubs/Swift', '~> 9.0'
pod 'OCMock', '~> 3.4'
pod 'Specta', '1.0.7'
pod 'Expecta', '1.0.6'
pod 'Quick', '~> 6.0'
end
14 changes: 5 additions & 9 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ PODS:
- CocoaLumberjack (3.7.0):
- CocoaLumberjack/Core (= 3.7.0)
- CocoaLumberjack/Core (3.7.0)
- Expecta (1.0.6)
- FormatterKit/Resources (1.8.2)
- FormatterKit/TimeIntervalFormatter (1.8.2):
- FormatterKit/Resources
Expand All @@ -22,34 +21,31 @@ PODS:
- OHHTTPStubs/OHPathHelpers (9.1.0)
- OHHTTPStubs/Swift (9.1.0):
- OHHTTPStubs/Default
- Specta (1.0.7)
- Quick (6.0.0)

DEPENDENCIES:
- CocoaLumberjack (~> 3.4)
- Expecta (= 1.0.6)
- FormatterKit/TimeIntervalFormatter (= 1.8.2)
- OCMock (~> 3.4)
- OHHTTPStubs (~> 9.0)
- OHHTTPStubs/Swift (~> 9.0)
- Specta (= 1.0.7)
- Quick (~> 6.0)

SPEC REPOS:
trunk:
- CocoaLumberjack
- Expecta
- FormatterKit
- OCMock
- OHHTTPStubs
- Specta
- Quick

SPEC CHECKSUMS:
CocoaLumberjack: e8955b9d337ac307103b0a34fd141c32f27e53c5
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
FormatterKit: 4b8f29acc9b872d5d12a63efb560661e8f2e1b98
OCMock: 29f6e52085b4e7d9b075cbf03ed7c3112f82f934
OHHTTPStubs: 90eac6d8f2c18317baeca36698523dc67c513831
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66
Quick: 4d5ab9e81f0a632cbf9bc4f3069b55e5eeb175df

PODFILE CHECKSUM: ace859cfebf0a7a9ce551e216483b641cd360251
PODFILE CHECKSUM: 3fc995dfb0ac66f4b9354243efa5e70275914622

COCOAPODS: 1.11.3
14 changes: 6 additions & 8 deletions WordPressShared.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
2EB9C57E3BFEDA1676FE857C /* Pods_WordPressShared.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AE15A6EE80D7766A21B83BF5 /* Pods_WordPressShared.framework */; };
32E1BFD524A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */; };
3F338B76289BE0F90014ADC5 /* BuildkiteTestCollector in Frameworks */ = {isa = PBXBuildFile; productRef = 3F338B75289BE0F90014ADC5 /* BuildkiteTestCollector */; };
4A2B7D132919E294007E5917 /* WPAnalyticsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A2B7D122919E294007E5917 /* WPAnalyticsTests.swift */; };
740B23CC1F17F1FF00067A2A /* DisplayableImageHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 740B23CA1F17F1FF00067A2A /* DisplayableImageHelper.h */; settings = {ATTRIBUTES = (Public, ); }; };
740B23CD1F17F1FF00067A2A /* DisplayableImageHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 740B23CB1F17F1FF00067A2A /* DisplayableImageHelper.m */; };
740B23CF1F17F28E00067A2A /* DisplayableImageHelperTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 740B23CE1F17F28E00067A2A /* DisplayableImageHelperTest.m */; };
Expand Down Expand Up @@ -87,7 +88,6 @@
E157E126239527700051AE41 /* Secret.swift in Sources */ = {isa = PBXBuildFile; fileRef = E157E125239527700051AE41 /* Secret.swift */; };
E157E128239527AD0051AE41 /* SecretTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E157E127239527AD0051AE41 /* SecretTests.swift */; };
E18EABEA1F0E2C6800BFCB0B /* TestAnalyticsTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = E18EABE81F0E2C6800BFCB0B /* TestAnalyticsTracker.m */; };
E18EABEB1F0E2C6800BFCB0B /* WPAnalyticsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E18EABE91F0E2C6800BFCB0B /* WPAnalyticsTests.m */; };
E1A444281F063CAB00F6AA8A /* WPAnalytics.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A444261F063CAB00F6AA8A /* WPAnalytics.h */; settings = {ATTRIBUTES = (Public, ); }; };
E1A444291F063CAB00F6AA8A /* WPAnalytics.m in Sources */ = {isa = PBXBuildFile; fileRef = E1A444271F063CAB00F6AA8A /* WPAnalytics.m */; };
F106FA61226FA72E00706DE4 /* StringURLValidationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F19847DD226F92EA0004A8BC /* StringURLValidationTests.swift */; };
Expand Down Expand Up @@ -122,6 +122,7 @@
32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WPStyleGuide+SerifFonts.swift"; sourceTree = "<group>"; };
405129D7901B7D4AD3B46442 /* Pods-WordPressShared.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressShared.release-internal.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressShared/Pods-WordPressShared.release-internal.xcconfig"; sourceTree = "<group>"; };
47629DF6D2C813279CBF93C4 /* Pods_WordPressSharedTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WordPressSharedTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4A2B7D122919E294007E5917 /* WPAnalyticsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WPAnalyticsTests.swift; sourceTree = "<group>"; };
5AC1280B7CDCD44A2F3A20AC /* Pods-WordPressShared.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressShared.release-alpha.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressShared/Pods-WordPressShared.release-alpha.xcconfig"; sourceTree = "<group>"; };
5B7FC757233F785AA7F785E7 /* Pods-WordPressShared.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressShared.release.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressShared/Pods-WordPressShared.release.xcconfig"; sourceTree = "<group>"; };
716C92B0CD72E5CD8250C04E /* Pods-WordPressSharedTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressSharedTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressSharedTests/Pods-WordPressSharedTests.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -211,7 +212,6 @@
E157E127239527AD0051AE41 /* SecretTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretTests.swift; sourceTree = "<group>"; };
E18EABE71F0E2C6800BFCB0B /* TestAnalyticsTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestAnalyticsTracker.h; sourceTree = "<group>"; };
E18EABE81F0E2C6800BFCB0B /* TestAnalyticsTracker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestAnalyticsTracker.m; sourceTree = "<group>"; };
E18EABE91F0E2C6800BFCB0B /* WPAnalyticsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WPAnalyticsTests.m; sourceTree = "<group>"; };
E1A444261F063CAB00F6AA8A /* WPAnalytics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WPAnalytics.h; sourceTree = "<group>"; };
E1A444271F063CAB00F6AA8A /* WPAnalytics.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WPAnalytics.m; sourceTree = "<group>"; };
E5A4545AEF641B125A2ABA89 /* Pods-WordPressShared.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressShared.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressShared/Pods-WordPressShared.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -378,7 +378,7 @@
F1C83C1123E20F7000A8CCF1 /* StringStripGutenbergContentForExcerptTests.swift */,
E18EABE71F0E2C6800BFCB0B /* TestAnalyticsTracker.h */,
E18EABE81F0E2C6800BFCB0B /* TestAnalyticsTracker.m */,
E18EABE91F0E2C6800BFCB0B /* WPAnalyticsTests.m */,
4A2B7D122919E294007E5917 /* WPAnalyticsTests.swift */,
827070911ECA4E1D00155CBF /* WPImageSourceTest.m */,
93A73ABE1EE9DDB000C0F2F9 /* WPMapFilterReduceTest.m */,
8270708F1ECA4E1C00155CBF /* WordPressSharedTests-Bridging-Header.h */,
Expand Down Expand Up @@ -672,19 +672,17 @@
"${PODS_ROOT}/Target Support Files/Pods-WordPressSharedTests/Pods-WordPressSharedTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/CocoaLumberjack/CocoaLumberjack.framework",
"${BUILT_PRODUCTS_DIR}/FormatterKit/FormatterKit.framework",
"${BUILT_PRODUCTS_DIR}/Expecta/Expecta.framework",
"${BUILT_PRODUCTS_DIR}/OCMock/OCMock.framework",
"${BUILT_PRODUCTS_DIR}/OHHTTPStubs/OHHTTPStubs.framework",
"${BUILT_PRODUCTS_DIR}/Specta/Specta.framework",
"${BUILT_PRODUCTS_DIR}/Quick/Quick.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CocoaLumberjack.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FormatterKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OCMock.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OHHTTPStubs.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Specta.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -763,9 +761,9 @@
E157E128239527AD0051AE41 /* SecretTests.swift in Sources */,
740B23CF1F17F28E00067A2A /* DisplayableImageHelperTest.m in Sources */,
F1C83C0C23E205D900A8CCF1 /* NSStringSummaryTests.swift in Sources */,
E18EABEB1F0E2C6800BFCB0B /* WPAnalyticsTests.m in Sources */,
7430C9DD1F1934190051B8E6 /* RichContentFormatterTests.swift in Sources */,
B5393FDC206D6169007BF9D4 /* EmailFormatValidatorTests.swift in Sources */,
4A2B7D132919E294007E5917 /* WPAnalyticsTests.swift in Sources */,
748710AC1F06C465008095AB /* StringHelperTests.swift in Sources */,
9A1329DF22170BE2009EE02A /* NSDateHelperTest.swift in Sources */,
);
Expand Down
10 changes: 10 additions & 0 deletions WordPressSharedTests/TestAnalyticsTracker.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#import <Foundation/Foundation.h>
#import "WPAnalytics.h"

NS_ASSUME_NONNULL_BEGIN

@interface TestAnalyticsTracker : NSObject<WPAnalyticsTracker>

- (void)track:(WPAnalyticsStat)stat;
Expand All @@ -11,3 +13,11 @@
- (void)refreshMetadata;

@end

typedef void (^WPAnalyticsMethodBehaviorInvocation)(id<WPAnalyticsTracker>);

FOUNDATION_EXTERN void WPAnalyticsTestVerifyUnregistered(WPAnalyticsMethodBehaviorInvocation invocation);
FOUNDATION_EXTERN void WPAnalyticsTestVerifyRegistered(WPAnalyticsMethodBehaviorInvocation invocation);
FOUNDATION_EXTERN void WPAnalyticsTestVerifyMultipleTrackers(WPAnalyticsMethodBehaviorInvocation invocation);

NS_ASSUME_NONNULL_END
30 changes: 30 additions & 0 deletions WordPressSharedTests/TestAnalyticsTracker.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#import "TestAnalyticsTracker.h"

#import <OCMock/OCMock.h>

@implementation TestAnalyticsTracker

- (void)track:(WPAnalyticsStat)stat
Expand Down Expand Up @@ -38,3 +40,31 @@ - (void)trackString:(NSString *)event withProperties:(NSDictionary *)properties


@end

void WPAnalyticsTestVerifyUnregistered(WPAnalyticsMethodBehaviorInvocation invocation) {
id trackerMock = OCMStrictClassMock([TestAnalyticsTracker class]);
id expectation = [trackerMock reject];
invocation(expectation);
[trackerMock verify];
}

void WPAnalyticsTestVerifyRegistered(WPAnalyticsMethodBehaviorInvocation invocation) {
id trackerMock = OCMStrictClassMock([TestAnalyticsTracker class]);
id expectation = [trackerMock expect];
invocation(expectation);
invocation(trackerMock);
[trackerMock verify];
}

void WPAnalyticsTestVerifyMultipleTrackers(WPAnalyticsMethodBehaviorInvocation invocation) {
id trackerMock = OCMStrictClassMock([TestAnalyticsTracker class]);
id trackerMock2 = OCMStrictClassMock([TestAnalyticsTracker class]);
id expectation = [trackerMock expect];
id expectation2 = [trackerMock2 expect];
invocation(expectation);
invocation(expectation2);
invocation(trackerMock);
invocation(trackerMock2);
[trackerMock verify];
[trackerMock2 verify];
}
143 changes: 0 additions & 143 deletions WordPressSharedTests/WPAnalyticsTests.m

This file was deleted.

Loading

0 comments on commit 346953e

Please sign in to comment.