Nimble matchers for FBSnapshotTestCase. Highly derivative of Expecta Matchers for FBSnapshotTestCase.
This project, naturally, relies on FBSnapshotTestCase. However, due to some strange errors I was getting with a CocoaPods-installed version of that library, I've had to resort to using git submodules.
So add your submodules for Quick, Nimble, and FBSnapshotTestCase, as well as a final one for this repository.
git submodule add [email protected]:Quick/Quick.git submodules/Quick
git submodule add [email protected]:Quick/Nimble.git submodules/Nimble
git submodule add [email protected]:facebook/ios-snapshot-test-case.git submodules/FBSnapshotTestCase
git submodule add [email protected]:AshFurrow/Nimble-Snapshots.git submodules/Nimble-Snapshots
git submodule init
git submodule update
Now follow the instructions for adding Quick and Nimble to your Xcode project. That's the easy part. You'll need to drag the following files into your project's test target.
FBSnapshotTestCase.h
FBSnapshotTestCase.m
FBSnapshotTestController.h
FBSnapshotTestController.m
UIImage+Compare.h
UIImage+Compare.m
UIImage+Diff.h
UIImage+Diff.m
Finally, drag in the HaveValidSnapshot.swift
file from this repo. Since it
relies on some Objective-C code in the FBSnapshotTestCase library, you'll need
to add the following line to an Objective-C bridging header.
#import "FBSnapshotTestController.h"
Alrighty! We're all set. Your tests will look something like the following.
import Quick
import Nimble
import UIKit
class MySpec: QuickSpec {
override func spec() {
describe("in some context", { () -> () in
it("has valid snapshot") {
let view = ... // some view you want to test
expect(view).to(haveValidSnapshot())
}
});
}
}
If you have any questions or run into any trouble, feel free to open an issue on this repo.