Simple way to identify whats different between 2 instances.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 996c2d6 Feb 27, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Configs initial Oct 18, 2017
Difference.xcodeproj feat: remove assertion files for now Oct 18, 2017
Resources initial Oct 18, 2017
Sources Merge pull request #6 from mr-v/collection_and_enum_fixes Feb 27, 2018
Tests Merge pull request #6 from mr-v/collection_and_enum_fixes Feb 27, 2018
.gitignore initial Oct 18, 2017
.swift-version initial Oct 18, 2017
Difference.podspec podspec version bump Dec 19, 2017
LICENSE initial Oct 18, 2017
Package.swift initial Oct 18, 2017
README.md Update quick matcher in readme Nov 21, 2017
circle.yml initial Oct 18, 2017

README.md

CircleCI Version License Platform

Difference

Better way to identify what's different between 2 instances.

Have you ever written tests? Usually they use equality asserts, e.g. XCTAssertEqual, what happens if the objects aren't equal? Xcode throws a wall of text at you:

This forces you to manually scan the text and try to figure out exactly whats wrong, what if instead you could just learn which property is different?

Installation

CocoaPods

Add pod 'Difference' to your Podfile.

Carthage

Add github "krzysztofzablocki/Difference" to your Cartfile.

Using lldb

Just write the following to see the difference between 2 instances:

po dumpDiff(expected, received)

Integrate with XCTest

Just add this to your test target:

public func AssertEqual<T: Equatable>(_ expected: T, _ received: T, file: StaticString = #file, line: UInt = #line) {
    XCTAssertTrue(expected == received, "Found difference for " + diff(expected, received).joined(separator: ", "), file: file, line: line)
}

Integrate with Quick

Just add this to your test target:

public func equalDiff<T: Equatable>(_ expectedValue: T?) -> Predicate<T> {
    return Predicate.define { actualExpression in
        let receivedValue = try actualExpression.evaluate()

        if receivedValue == nil {
            var message = ExpectationMessage.fail("")
            if let expectedValue = expectedValue {
                message = ExpectationMessage.expectedCustomValueTo("equal <\(expectedValue)>", "nil")
            }
            return PredicateResult(status: .fail, message: message)
        }
        if expectedValue == nil {
            return PredicateResult(status: .fail, message: ExpectationMessage.fail("").appendedBeNilHint())
        }

        return PredicateResult(bool: receivedValue == expectedValue, message: ExpectationMessage.fail("Found difference for " + diff(expectedValue, receivedValue).joined(separator: ", ")))
    }
}