From 5af3563ad72f139ec8c22c7951516522b472e53f Mon Sep 17 00:00:00 2001 From: Giuseppe Nucifora Date: Mon, 6 Mar 2017 13:42:38 +0100 Subject: [PATCH] - Fix + (NSTimeInterval) timeIntervalFromMinutes:(NSUInteger) minutes --- Example/Podfile.lock | 14 +- .../EXPMatchers+FBSnapshotTest.h | 4 + .../EXPMatchers+FBSnapshotTest.m | 63 ++++++--- .../ExpectaObject+FBSnapshotTest.h | 4 + .../ExpectaObject+FBSnapshotTest.m | 11 ++ Example/Pods/Expecta+Snapshots/README.md | 11 +- .../Local Podspecs/NSDate_Utils.podspec.json | 4 +- Example/Pods/Manifest.lock | 14 +- Example/Pods/Specta/README.md | 121 +++++++++--------- Example/Pods/Specta/Specta/Specta/SPTSpec.m | 3 +- Example/Pods/Specta/Specta/Specta/SpectaDSL.h | 2 +- .../Specta/Specta/Specta/XCTestCase+Specta.m | 5 +- .../Expecta+Snapshots.xcconfig | 1 + .../Expecta+Snapshots/Info.plist | 2 +- .../NSDate_Utils/Info.plist | 2 +- .../Target Support Files/Specta/Info.plist | 2 +- NSDate_Utils.podspec | 2 +- Pod/Classes/NSDate+NSDate_Util.m | 2 + 18 files changed, 166 insertions(+), 101 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 676ca52..4a3332e 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,6 +1,6 @@ PODS: - Expecta (1.0.5) - - Expecta+Snapshots (3.0.0): + - Expecta+Snapshots (3.1.1): - Expecta (~> 1.0) - FBSnapshotTestCase/Core (~> 2.0) - Specta (~> 1.0) @@ -9,8 +9,8 @@ PODS: - FBSnapshotTestCase/Core (2.1.4) - FBSnapshotTestCase/SwiftSupport (2.1.4): - FBSnapshotTestCase/Core - - NSDate_Utils (1.0.5) - - Specta (1.0.5) + - NSDate_Utils (1.0.6) + - Specta (1.0.6) DEPENDENCIES: - Expecta @@ -25,11 +25,11 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Expecta: e1c022fcd33910b6be89c291d2775b3fe27a89fe - Expecta+Snapshots: c343f410c7a6392f3e22e78f94c44b6c0749a516 + Expecta+Snapshots: dcff217eef506dabd6dfdc7864ea2da321fafbb8 FBSnapshotTestCase: '094f9f314decbabe373b87cc339bea235a63e07a' - NSDate_Utils: b0ab72ccec6df25297766bd64b0cd0c124521a45 - Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2 + NSDate_Utils: c7802a1e0f5ef3acaf39bf55806a1caaa0343d2d + Specta: f506f3a8361de16bc0dcf3b17b75e269072ba465 PODFILE CHECKSUM: 5d3cb6429ba8613bec51b3e797c0070e91be6b26 -COCOAPODS: 1.2.0.beta.3 +COCOAPODS: 1.2.0 diff --git a/Example/Pods/Expecta+Snapshots/EXPMatchers+FBSnapshotTest.h b/Example/Pods/Expecta+Snapshots/EXPMatchers+FBSnapshotTest.h index 8392d50..1783da5 100644 --- a/Example/Pods/Expecta+Snapshots/EXPMatchers+FBSnapshotTest.h +++ b/Example/Pods/Expecta+Snapshots/EXPMatchers+FBSnapshotTest.h @@ -1,3 +1,4 @@ +#import #import #import "ExpectaObject+FBSnapshotTest.h" @@ -12,3 +13,6 @@ EXPMatcherInterface(recordSnapshot, (void)); EXPMatcherInterface(haveValidSnapshotNamed, (NSString *snapshot)); EXPMatcherInterface(recordSnapshotNamed, (NSString *snapshot)); + +EXPMatcherInterface(haveValidSnapshotNamedWithTolerance, (NSString *snapshot, CGFloat tolerance)); +EXPMatcherInterface(haveValidSnapshotWithTolerance, (CGFloat tolerance)); diff --git a/Example/Pods/Expecta+Snapshots/EXPMatchers+FBSnapshotTest.m b/Example/Pods/Expecta+Snapshots/EXPMatchers+FBSnapshotTest.m index 1455e4a..571b522 100644 --- a/Example/Pods/Expecta+Snapshots/EXPMatchers+FBSnapshotTest.m +++ b/Example/Pods/Expecta+Snapshots/EXPMatchers+FBSnapshotTest.m @@ -18,14 +18,15 @@ return instance; } -+ (BOOL)compareSnapshotOfViewOrLayer:(id)viewOrLayer snapshot:(NSString *)snapshot testCase:(id)testCase record:(BOOL)record referenceDirectory:(NSString *)referenceDirectory error:(NSError **)error ++ (BOOL)compareSnapshotOfViewOrLayer:(id)viewOrLayer snapshot:(NSString *)snapshot testCase:(id)testCase record:(BOOL)record referenceDirectory:(NSString *)referenceDirectory tolerance:(CGFloat)tolerance error:(NSError **)error { FBSnapshotTestController *snapshotController = [[FBSnapshotTestController alloc] initWithTestClass:[testCase class]]; snapshotController.recordMode = record; snapshotController.referenceImagesDirectory = referenceDirectory; snapshotController.usesDrawViewHierarchyInRect = [Expecta usesDrawViewHierarchyInRect]; - + snapshotController.deviceAgnostic = [Expecta isDeviceAgnostic]; + if (! snapshotController.referenceImagesDirectory) { [NSException raise:@"Missing value for referenceImagesDirectory" format:@"Call [[EXPExpectFBSnapshotTest instance] setReferenceImagesDirectory"]; } @@ -33,7 +34,7 @@ return [snapshotController compareSnapshotOfViewOrLayer:viewOrLayer selector:NSSelectorFromString(snapshot) identifier:nil - tolerance:0 + tolerance:tolerance error:error]; } @@ -79,18 +80,36 @@ void setGlobalReferenceImageDir(char *reference) { NSString *testFileName = [NSString stringWithCString:self.fileName encoding:NSUTF8StringEncoding]; NSArray *pathComponents = [testFileName pathComponents]; - for (NSString *folder in pathComponents) { + NSString *firstFolderFound = nil; + + for (NSString *folder in pathComponents.reverseObjectEnumerator) { if ([folder.lowercaseString rangeOfString:@"tests"].location != NSNotFound) { - NSArray *folderPathComponents = [pathComponents subarrayWithRange:NSMakeRange(0, [pathComponents indexOfObject:folder] + 1)]; - return [NSString stringWithFormat:@"%@/ReferenceImages", [folderPathComponents componentsJoinedByString:@"/"]]; + NSString *referenceImagesPath = [NSString stringWithFormat:@"%@/ReferenceImages", [folderPathComponents componentsJoinedByString:@"/"]]; + if (!firstFolderFound) { + firstFolderFound = referenceImagesPath; + } + + BOOL isDirectory = NO; + BOOL referenceDirExists = [[NSFileManager defaultManager] fileExistsAtPath:referenceImagesPath isDirectory:&isDirectory]; + + // if the folder exists, this is the reference dir for sure + if (referenceDirExists && isDirectory) { + return referenceImagesPath; + } } } + // if a reference folder wasn't found, we should create one + if (firstFolderFound) { + return firstFolderFound; + } + [NSException raise:@"Could not infer reference image folder" format:@"You should provide a reference dir using setGlobalReferenceImageDir(FB_REFERENCE_IMAGE_DIR);"]; return nil; } + @end @@ -114,11 +133,11 @@ NSString *sanitizedTestPath(){ return name; } -EXPMatcherImplementationBegin(haveValidSnapshot, (void)){ +EXPMatcherImplementationBegin(haveValidSnapshotWithTolerance, (CGFloat tolerance)){ __block NSError *error = nil; prerequisite(^BOOL{ - return actual; + return actual != nil; }); @@ -132,7 +151,7 @@ EXPMatcherImplementationBegin(haveValidSnapshot, (void)){ actual = [actual view]; } - return [EXPExpectFBSnapshotTest compareSnapshotOfViewOrLayer:actual snapshot:name testCase:[self testCase] record:NO referenceDirectory:referenceImageDir error:&error]; + return [EXPExpectFBSnapshotTest compareSnapshotOfViewOrLayer:actual snapshot:name testCase:[self testCase] record:NO referenceDirectory:referenceImageDir tolerance:tolerance error:&error]; }); failureMessageForTo(^NSString *{ @@ -149,18 +168,22 @@ EXPMatcherImplementationBegin(haveValidSnapshot, (void)){ } EXPMatcherImplementationEnd +EXPMatcherImplementationBegin(haveValidSnapshot, (void)) { + return self.haveValidSnapshotWithTolerance(0); +} +EXPMatcherImplementationEnd + EXPMatcherImplementationBegin(recordSnapshot, (void)) { __block NSError *error = nil; BOOL actualIsViewLayerOrViewController = ([actual isKindOfClass:UIView.class] || [actual isKindOfClass:CALayer.class] || [actual isKindOfClass:UIViewController.class]); prerequisite(^BOOL{ - return actual && actualIsViewLayerOrViewController; + return actual != nil && actualIsViewLayerOrViewController; }); match(^BOOL{ NSString *referenceImageDir = [self _getDefaultReferenceDirectory]; - // For view controllers do the viewWill/viewDid dance, then pass view through if ([actual isKindOfClass:UIViewController.class]) { @@ -169,7 +192,7 @@ EXPMatcherImplementationBegin(recordSnapshot, (void)) { actual = [actual view]; } - [EXPExpectFBSnapshotTest compareSnapshotOfViewOrLayer:actual snapshot:sanitizedTestPath() testCase:[self testCase] record:YES referenceDirectory:referenceImageDir error:&error]; + [EXPExpectFBSnapshotTest compareSnapshotOfViewOrLayer:actual snapshot:sanitizedTestPath() testCase:[self testCase] record:YES referenceDirectory:referenceImageDir tolerance:0 error:&error]; return NO; }); @@ -198,12 +221,12 @@ EXPMatcherImplementationBegin(recordSnapshot, (void)) { } EXPMatcherImplementationEnd -EXPMatcherImplementationBegin(haveValidSnapshotNamed, (NSString *snapshot)){ +EXPMatcherImplementationBegin(haveValidSnapshotNamedWithTolerance, (NSString *snapshot, CGFloat tolerance)) { BOOL snapshotIsNil = (snapshot == nil); __block NSError *error = nil; prerequisite(^BOOL{ - return actual && !(snapshotIsNil); + return actual != nil && !(snapshotIsNil); }); match(^BOOL{ @@ -214,7 +237,7 @@ EXPMatcherImplementationBegin(haveValidSnapshotNamed, (NSString *snapshot)){ actual = [actual view]; } - return [EXPExpectFBSnapshotTest compareSnapshotOfViewOrLayer:actual snapshot:snapshot testCase:[self testCase] record:NO referenceDirectory:referenceImageDir error:&error]; + return [EXPExpectFBSnapshotTest compareSnapshotOfViewOrLayer:actual snapshot:snapshot testCase:[self testCase] record:NO referenceDirectory:referenceImageDir tolerance:tolerance error:&error]; }); failureMessageForTo(^NSString *{ @@ -232,6 +255,11 @@ EXPMatcherImplementationBegin(haveValidSnapshotNamed, (NSString *snapshot)){ } EXPMatcherImplementationEnd +EXPMatcherImplementationBegin(haveValidSnapshotNamed, (NSString *snapshot)) { + return self.haveValidSnapshotNamedWithTolerance(snapshot, 0); +} +EXPMatcherImplementationEnd + EXPMatcherImplementationBegin(recordSnapshotNamed, (NSString *snapshot)) { BOOL snapshotExists = (snapshot != nil); BOOL actualIsViewLayerOrViewController = ([actual isKindOfClass:UIView.class] || [actual isKindOfClass:CALayer.class] || [actual isKindOfClass:UIViewController.class]); @@ -239,12 +267,11 @@ EXPMatcherImplementationBegin(recordSnapshotNamed, (NSString *snapshot)) { id actualRef = actual; prerequisite(^BOOL{ - return actualRef && snapshotExists && actualIsViewLayerOrViewController; + return actualRef != nil && snapshotExists && actualIsViewLayerOrViewController; }); match(^BOOL{ NSString *referenceImageDir = [self _getDefaultReferenceDirectory]; - // For view controllers do the viewWill/viewDid dance, then pass view through if ([actual isKindOfClass:UIViewController.class]) { [actual beginAppearanceTransition:YES animated:NO]; @@ -252,7 +279,7 @@ EXPMatcherImplementationBegin(recordSnapshotNamed, (NSString *snapshot)) { actual = [actual view]; } - [EXPExpectFBSnapshotTest compareSnapshotOfViewOrLayer:actual snapshot:snapshot testCase:[self testCase] record:YES referenceDirectory:referenceImageDir error:&error]; + [EXPExpectFBSnapshotTest compareSnapshotOfViewOrLayer:actual snapshot:snapshot testCase:[self testCase] record:YES referenceDirectory:referenceImageDir tolerance:0 error:&error]; return NO; }); diff --git a/Example/Pods/Expecta+Snapshots/ExpectaObject+FBSnapshotTest.h b/Example/Pods/Expecta+Snapshots/ExpectaObject+FBSnapshotTest.h index a3feec3..18cdba8 100644 --- a/Example/Pods/Expecta+Snapshots/ExpectaObject+FBSnapshotTest.h +++ b/Example/Pods/Expecta+Snapshots/ExpectaObject+FBSnapshotTest.h @@ -14,4 +14,8 @@ + (BOOL)usesDrawViewHierarchyInRect; ++ (void)setDeviceAgnostic:(BOOL)deviceAgnostic; + ++ (BOOL)isDeviceAgnostic; + @end diff --git a/Example/Pods/Expecta+Snapshots/ExpectaObject+FBSnapshotTest.m b/Example/Pods/Expecta+Snapshots/ExpectaObject+FBSnapshotTest.m index 698447a..2f63baa 100644 --- a/Example/Pods/Expecta+Snapshots/ExpectaObject+FBSnapshotTest.m +++ b/Example/Pods/Expecta+Snapshots/ExpectaObject+FBSnapshotTest.m @@ -22,4 +22,15 @@ static NSString const *kUsesDrawViewHierarchyInRectKey = @"ExpectaObject+FBSnaps return usesDrawViewHierarchyInRect.boolValue; } ++ (void)setDeviceAgnostic:(BOOL)deviceAgnostic +{ + objc_setAssociatedObject(self, @selector(isDeviceAgnostic), @(deviceAgnostic), OBJC_ASSOCIATION_ASSIGN); +} + ++ (BOOL)isDeviceAgnostic +{ + NSNumber *isDeviceAgnostic = objc_getAssociatedObject(self, @selector(isDeviceAgnostic)); + return isDeviceAgnostic.boolValue; +} + @end diff --git a/Example/Pods/Expecta+Snapshots/README.md b/Example/Pods/Expecta+Snapshots/README.md index 07c5265..af161b6 100644 --- a/Example/Pods/Expecta+Snapshots/README.md +++ b/Example/Pods/Expecta+Snapshots/README.md @@ -3,7 +3,7 @@ Expecta Matchers for FBSnapshotTestCase [Expecta](https://github.com/specta/expecta) matchers for [ios-snapshot-test-case](https://github.com/facebook/ios-snapshot-test-case). -[![Build Status](https://travis-ci.org/dblock/ios-snapshot-test-case-expecta.png)](https://travis-ci.org/dblock/ios-snapshot-test-case-expecta) +[![Build Status](https://travis-ci.org/dblock/ios-snapshot-test-case-expecta.svg)](https://travis-ci.org/dblock/ios-snapshot-test-case-expecta) ### Usage @@ -63,6 +63,15 @@ describe(@"test name derived matching", ^{ SpecEnd ``` +### Approximation support + +If for some reason you want to specify a tolerance for your test, you can use either named or unnamed matchers, where the `tolerance` parameter is a `CGFloat` in the interval `[0, 1]` and it represents the minimum ratio of unmatched points by the total number of points in your snapshot. In the example below, a tolerance of `0.01` means our `view` could be up to `1%` different from the reference image. + +``` Objective-C +expect(view).to.haveValidSnapshotWithTolerance(0.01); +expect(view).to.haveValidSnapshotNamedWithTolerance(@"unique snapshot name", 0.01); +``` + ### Sane defaults `EXPMatchers+FBSnapshotTest` will automatically figure out the tests folder, and [add a reference image](https://github.com/dblock/ios-snapshot-test-case-expecta/blob/master/EXPMatchers%2BFBSnapshotTest.m#L84-L85) directory, if you'd like to override this, you should include a `beforeAll` block setting the `setGlobalReferenceImageDir` in each file containing tests. diff --git a/Example/Pods/Local Podspecs/NSDate_Utils.podspec.json b/Example/Pods/Local Podspecs/NSDate_Utils.podspec.json index 1d04080..3453c18 100644 --- a/Example/Pods/Local Podspecs/NSDate_Utils.podspec.json +++ b/Example/Pods/Local Podspecs/NSDate_Utils.podspec.json @@ -1,6 +1,6 @@ { "name": "NSDate_Utils", - "version": "1.0.5", + "version": "1.0.6", "summary": "NSDate_Utils is a NSDate category that helps date managements. For example NSString to NSDate, NSDate to NSString,NSSdate comparisons", "homepage": "https://github.com/giuseppenucifora/NSDate_Utils", "license": "MIT", @@ -9,7 +9,7 @@ }, "source": { "git": "https://github.com/giuseppenucifora/NSDate_Utils.git", - "tag": "1.0.5" + "tag": "1.0.6" }, "platforms": { "ios": "7.0" diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 676ca52..4a3332e 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -1,6 +1,6 @@ PODS: - Expecta (1.0.5) - - Expecta+Snapshots (3.0.0): + - Expecta+Snapshots (3.1.1): - Expecta (~> 1.0) - FBSnapshotTestCase/Core (~> 2.0) - Specta (~> 1.0) @@ -9,8 +9,8 @@ PODS: - FBSnapshotTestCase/Core (2.1.4) - FBSnapshotTestCase/SwiftSupport (2.1.4): - FBSnapshotTestCase/Core - - NSDate_Utils (1.0.5) - - Specta (1.0.5) + - NSDate_Utils (1.0.6) + - Specta (1.0.6) DEPENDENCIES: - Expecta @@ -25,11 +25,11 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Expecta: e1c022fcd33910b6be89c291d2775b3fe27a89fe - Expecta+Snapshots: c343f410c7a6392f3e22e78f94c44b6c0749a516 + Expecta+Snapshots: dcff217eef506dabd6dfdc7864ea2da321fafbb8 FBSnapshotTestCase: '094f9f314decbabe373b87cc339bea235a63e07a' - NSDate_Utils: b0ab72ccec6df25297766bd64b0cd0c124521a45 - Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2 + NSDate_Utils: c7802a1e0f5ef3acaf39bf55806a1caaa0343d2d + Specta: f506f3a8361de16bc0dcf3b17b75e269072ba465 PODFILE CHECKSUM: 5d3cb6429ba8613bec51b3e797c0070e91be6b26 -COCOAPODS: 1.2.0.beta.3 +COCOAPODS: 1.2.0 diff --git a/Example/Pods/Specta/README.md b/Example/Pods/Specta/README.md index 431b121..d9b59e2 100644 --- a/Example/Pods/Specta/README.md +++ b/Example/Pods/Specta/README.md @@ -1,11 +1,7 @@ -# Specta +# Specta [![Build Status](https://travis-ci.org/specta/specta.svg)](https://travis-ci.org/specta/specta) [![Coverage Status](https://coveralls.io/repos/specta/specta/badge.svg)](https://coveralls.io/r/specta/specta) A light-weight TDD / BDD framework for Objective-C. -### Status -[![Build Status](https://travis-ci.org/specta/specta.png)](https://travis-ci.org/specta/specta) -[![Coverage Status](https://coveralls.io/repos/specta/specta/badge.svg)](https://coveralls.io/r/specta/specta) - ## FEATURES * An Objective-C RSpec-like BDD DSL @@ -15,56 +11,7 @@ A light-weight TDD / BDD framework for Objective-C. ## SCREENSHOT -![Specta Screenshot](https://raw.githubusercontent.com/specta/specta/master/misc/specta_screenshot.jpg) - -## SETUP - -Use [CocoaPods](http://github.com/CocoaPods/CocoaPods), [Carthage](https://github.com/carthage/carthage) or [Set up manually](#setting-up-manually) - -### CocoaPods - -1. Add Specta to your project's `Podfile`: - - ```ruby - target :MyApp do - # your app dependencies - end - - target :MyAppTests do - pod 'Specta', '~> 1.0' - # pod 'Expecta', '~> 1.0' # expecta matchers - # pod 'OCMock', '~> 2.2' # OCMock - # pod 'OCHamcrest', '~> 3.0' # hamcrest matchers - # pod 'OCMockito', '~> 1.0' # OCMock - # pod 'LRMocky', '~> 0.9' # LRMocky - end - ``` - -2. Run `pod update` or `pod install` in your project directory. - -### Carthage - -1. Add Specta to your project's `Cartfile.private` - - ``` - github "specta/specta" ~> 1.0 - ``` - -2. Run `carthage update` in your project directory -3. Drag the appropriate `Specta.framework` for your platform (located in Carthage/Build/) into your application’s Xcode project, and add it to your test target(s). -4. If you are building for iOS, a new `Run Script Phase` must be added to copy the framework. The instructions can be found on [Carthage's getting started instructions](https://github.com/carthage/carthage#getting-started) - -### SETTING UP MANUALLY - -1. Clone from Github. -2. Run `rake` in project root to build. -3. Add a "Cocoa/Cocoa Touch Unit Testing Bundle" target if you don't already have one. -4. Copy and add all header files in `Products` folder to the Test target in your Xcode project. -5. For **OS X projects**, copy and add `Specta.framework` in `Products/osx` folder to the test target in your Xcode project. - For **iOS projects**, copy and add `Specta.framework` in `Products/ios` folder to the test target in your Xcode project. - You can alternatively use `libSpecta.a`, if you prefer to add it as a static library for your project. (iOS 7 and below require this) -6. Add `-ObjC` and `-all_load` to the "Other Linker Flags" build setting for the test target in your Xcode project. -7. If you encounter linking issues with `_llvm_*` symbols, ensure your target's "Generate Test Coverage Files" and "Instrument Program Flow" build settings are set to `Yes`. + ## EXAMPLE @@ -156,12 +103,17 @@ SpecEnd * Do `#define SPT_CEDAR_SYNTAX` before importing Specta if you prefer to write `SPEC_BEGIN` and `SPEC_END` instead of `SpecBegin` and `SpecEnd`. * Prepend `f` to your `describe`, `context`, `example`, `it`, and `specify` to set focus on examples or groups. When specs are focused, all unfocused specs are skipped. * To use original XCTest reporter, set an environment variable named `SPECTA_REPORTER_CLASS` to `SPTXCTestReporter` in your test scheme. -* Set an environment variable `SPECTA_NO_SHUFFLE` with value `1` to disable test shuffling. +* Set an environment variable `SPECTA_SHUFFLE` with value `1` to enable test shuffling. * Set an environment variable `SPECTA_SEED` to specify the random seed for test shuffling. -Standard XCTest matchers such as `XCTAssertEqualObjects` and `XCTAssertNil` work, but you probably want to add a nicer matcher framework - [Expecta](http://github.com/specta/expecta/) to your setup. Or if you really prefer, [OCHamcrest](https://github.com/jonreid/OCHamcrest) works fine too. Also, add a mocking framework: [OCMock](http://ocmock.org/). +Standard XCTest matchers such as `XCTAssertEqualObjects` and `XCTAssertNil` work, but you probably want to add a nicer matcher framework - [Expecta](https://github.com/specta/expecta/) to your setup. Or if you really prefer, [OCHamcrest](https://github.com/hamcrest/OCHamcrest) works fine too. Also, add a mocking framework: [OCMock](http://ocmock.org/). -## RUNNING TESTS IN COMMAND LINE +## STATUS + +Specta is considered a done project, there are no plans for _active_ development on the project at the moment aside from ensuring future Xcode compatability. +Therefore it is a stable dependency, but will not be moving into the Swift world. If you are looking for that, we recommend you consider [Quick](https://github.com/quick/quick). + +## RUNNING SPECTA'S TESTS IN COMMAND LINE * Run `rake test` in the cloned folder. @@ -171,6 +123,57 @@ Standard XCTest matchers such as `XCTAssertEqualObjects` and `XCTAssertNil` work * Please prefix instance variable names with a single underscore (`_`). * Please prefix custom classes and functions defined in the global scope with `SPT`. +## Installation + +Use [CocoaPods](https://github.com/CocoaPods/CocoaPods), [Carthage](https://github.com/carthage/carthage) or [Set up manually](#setting-up-manually) + +### CocoaPods + +1. Add Specta to your project's `Podfile`: + +```ruby +target :MyApp do +# your app dependencies + + target :MyAppTests do + inherit! :search_paths + + pod 'Specta', '~> 1.0' + # pod 'Expecta', '~> 1.0' # expecta matchers + # pod 'OCMock', '~> 2.2' # OCMock + # pod 'OCHamcrest', '~> 3.0' # hamcrest matchers + # pod 'OCMockito', '~> 1.0' # OCMock + # pod 'LRMocky', '~> 0.9' # LRMocky + end +end +``` + +2. Run `pod install` in your project directory. + +### Carthage + +1. Add Specta to your project's `Cartfile.private` + + ``` + github "specta/specta" ~> 1.0 + ``` + +2. Run `carthage update` in your project directory +3. Drag the appropriate `Specta.framework` for your platform (located in Carthage/Build/) into your application’s Xcode project, and add it to your test target(s). +4. If you are building for iOS, a new `Run Script Phase` must be added to copy the framework. The instructions can be found on [Carthage's getting started instructions](https://github.com/carthage/carthage#getting-started) + +### SETTING UP MANUALLY + +1. Clone from Github. +2. Run `rake` in project root to build. +3. Add a "Cocoa/Cocoa Touch Unit Testing Bundle" target if you don't already have one. +4. Copy and add all header files in `Products` folder to the Test target in your Xcode project. +5. For **OS X projects**, copy and add `Specta.framework` in `Products/osx` folder to the test target in your Xcode project. + For **iOS projects**, copy and add `Specta.framework` in `Products/ios` folder to the test target in your Xcode project. + You can alternatively use `libSpecta.a`, if you prefer to add it as a static library for your project. (iOS 7 and below require this) +6. Add `-ObjC` and `-all_load` to the "Other Linker Flags" build setting for the test target in your Xcode project. +7. If you encounter linking issues with `_llvm_*` symbols, ensure your target's "Generate Test Coverage Files" and "Instrument Program Flow" build settings are set to `Yes`. + ## LICENSE -Copyright (c) 2012-2015 [Specta Team](https://github.com/specta?tab=members). This software is licensed under the [MIT License](http://github.com/specta/specta/raw/master/LICENSE). +Copyright (c) 2012-2016 [Specta Team](https://github.com/orgs/specta/people). This software is licensed under the [MIT License](http://github.com/specta/specta/raw/master/LICENSE). diff --git a/Example/Pods/Specta/Specta/Specta/SPTSpec.m b/Example/Pods/Specta/Specta/Specta/SPTSpec.m index 35ad313..bda0d3f 100644 --- a/Example/Pods/Specta/Specta/Specta/SPTSpec.m +++ b/Example/Pods/Specta/Specta/Specta/SPTSpec.m @@ -19,7 +19,7 @@ [spec spec]; } @catch (NSException *exception) { - fprintf(stderr, "%s: An exception has occured outside of tests, aborting.\n\n%s (%s) \n", [specName UTF8String], [[exception name] UTF8String], [[exception reason] UTF8String]); + fprintf(stderr, "%s: An exception has occurred outside of tests, aborting.\n\n%s (%s) \n", [specName UTF8String], [[exception name] UTF8String], [[exception reason] UTF8String]); if ([exception respondsToSelector:@selector(callStackSymbols)]) { NSArray *callStackSymbols = [exception callStackSymbols]; if (callStackSymbols) { @@ -145,6 +145,7 @@ example.block(self); } else if (!example.pending) { self.spt_skipped = YES; + NSLog(@"Skipping '%@'", example.name); } [[[NSThread currentThread] threadDictionary] removeObjectForKey:spt_kCurrentSpecKey]; diff --git a/Example/Pods/Specta/Specta/Specta/SpectaDSL.h b/Example/Pods/Specta/Specta/Specta/SpectaDSL.h index 284d4f5..3505862 100644 --- a/Example/Pods/Specta/Specta/Specta/SpectaDSL.h +++ b/Example/Pods/Specta/Specta/Specta/SpectaDSL.h @@ -54,7 +54,7 @@ OBJC_EXTERN void waitUntil(void (^block)(DoneCallback done)); * * @param timeout timeout for this @c block only; does not affect the global * timeout, as @c setAsyncSpecTimeout() does. - * @param ^block runs test code + * @param block runs test code */ OBJC_EXTERN void waitUntilTimeout(NSTimeInterval timeout, void (^block)(DoneCallback done)); diff --git a/Example/Pods/Specta/Specta/Specta/XCTestCase+Specta.m b/Example/Pods/Specta/Specta/Specta/XCTestCase+Specta.m index 4c503ee..ff801a1 100644 --- a/Example/Pods/Specta/Specta/Specta/XCTestCase+Specta.m +++ b/Example/Pods/Specta/Specta/Specta/XCTestCase+Specta.m @@ -42,7 +42,10 @@ [self spt_dequeueFailures]; }; - if ([NSThread isMainThread]) { + BOOL isMainThread = [NSThread isMainThread]; + BOOL isSpectaTest = [self isKindOfClass:[SPTSpec class]]; + + if (!isSpectaTest || isMainThread) { dequeueFailures(); } else { dispatch_sync(dispatch_get_main_queue(), dequeueFailures); diff --git a/Example/Pods/Target Support Files/Expecta+Snapshots/Expecta+Snapshots.xcconfig b/Example/Pods/Target Support Files/Expecta+Snapshots/Expecta+Snapshots.xcconfig index 8b369db..713076a 100644 --- a/Example/Pods/Target Support Files/Expecta+Snapshots/Expecta+Snapshots.xcconfig +++ b/Example/Pods/Target Support Files/Expecta+Snapshots/Expecta+Snapshots.xcconfig @@ -1,4 +1,5 @@ CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Expecta+Snapshots +ENABLE_BITCODE = NO FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" "$PODS_CONFIGURATION_BUILD_DIR/Expecta" "$PODS_CONFIGURATION_BUILD_DIR/FBSnapshotTestCase" "$PODS_CONFIGURATION_BUILD_DIR/Specta" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" diff --git a/Example/Pods/Target Support Files/Expecta+Snapshots/Info.plist b/Example/Pods/Target Support Files/Expecta+Snapshots/Info.plist index 4522675..793d31a 100644 --- a/Example/Pods/Target Support Files/Expecta+Snapshots/Info.plist +++ b/Example/Pods/Target Support Files/Expecta+Snapshots/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.0.0 + 3.1.1 CFBundleSignature ???? CFBundleVersion diff --git a/Example/Pods/Target Support Files/NSDate_Utils/Info.plist b/Example/Pods/Target Support Files/NSDate_Utils/Info.plist index a5730fa..995c8fe 100644 --- a/Example/Pods/Target Support Files/NSDate_Utils/Info.plist +++ b/Example/Pods/Target Support Files/NSDate_Utils/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.5 + 1.0.6 CFBundleSignature ???? CFBundleVersion diff --git a/Example/Pods/Target Support Files/Specta/Info.plist b/Example/Pods/Target Support Files/Specta/Info.plist index a5730fa..995c8fe 100644 --- a/Example/Pods/Target Support Files/Specta/Info.plist +++ b/Example/Pods/Target Support Files/Specta/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.5 + 1.0.6 CFBundleSignature ???? CFBundleVersion diff --git a/NSDate_Utils.podspec b/NSDate_Utils.podspec index 8b181b2..96e930a 100644 --- a/NSDate_Utils.podspec +++ b/NSDate_Utils.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "NSDate_Utils" - s.version = "1.0.5" + s.version = "1.0.6" s.summary = "NSDate_Utils is a NSDate category that helps date managements. For example NSString to NSDate, NSDate to NSString,NSSdate comparisons" # This description is used to generate tags and improve search results. diff --git a/Pod/Classes/NSDate+NSDate_Util.m b/Pod/Classes/NSDate+NSDate_Util.m index f4a59b2..a3aa296 100755 --- a/Pod/Classes/NSDate+NSDate_Util.m +++ b/Pod/Classes/NSDate+NSDate_Util.m @@ -528,7 +528,9 @@ static NSDateFormatter *_displayFormatter = nil; + (NSTimeInterval) timeIntervalFromHours:(NSUInteger) hours { + NSTimeInterval seconds = hours / 60 / 60; + return seconds; }