Releases: ashfurrow/Nimble-Snapshots
4.4.2
4.4.1
4.4.0
-
Adds support for testing dynamic sizes - @bruno.mazzo
You need the use the new subspec to enjoy this new feature:
pod 'Nimble-Snapshots/DynamicSize'
Then you can use the new
haveValidDynamicSizeSnapshotandrecordDynamicSizeSnapshotmatchers to use it:let sizes = ["SmallSize": CGSize(width: 44, height: 44), "MediumSize": CGSize(width: 88, height: 88), "LargeSize": CGSize(width: 132, height: 132)] // expect(view).to(recordDynamicSizeSnapshot(sizes: sizes)) expect(view).to(haveValidDynamicSizeSnapshot(sizes: sizes)) // You can also just test some sizes: expect(view).to(haveValidDynamicSizeSnapshot(sizes: sizes)) // If you prefer the == syntax, we got you covered too: expect(view) == dynamicSizeSnapshot(sizes: sizes) expect(view) == dynamicSizeSnapshot(sizes: sizes)
By default, the size will be set on the view using the frame property. To change this behavior
you can use theResizeModeenum:public enum ResizeMode { case frame case constrains case block(resizeBlock: (UIView, CGSize)->()) case custom(ViewResizer: ViewResizer) }
To use the enum you can
expect(view) == dynamicSizeSnapshot(sizes: sizes, resizeMode: newResizeMode).
For custom behavior you can useResizeMode.block. The block will be call on every resize. Or you can
implement theViewResizerprotocol and resize yourself.
The custom behavier can be use to record the views too.
For more info on usage, check the dynamic sizes tests.
- Improved failure messages by removing the prefix ", got" - @MP0w
4.3.0
-
Adds support for testing dynamic type - @marcelofabri
You need the use the new subspec to enjoy this new feature:
pod 'Nimble-Snapshots/DynamicType'
Then you can use the new
haveValidDynamicTypeSnapshotandrecordDynamicTypeSnapshotmatchers to use it:// expect(view).to(recordDynamicTypeSnapshot() expect(view).to(haveValidDynamicTypeSnapshot()) // You can also just test some sizes: expect(view).to(haveValidDynamicTypeSnapshot(sizes: [UIContentSizeCategoryExtraLarge])) // If you prefer the == syntax, we got you covered too: expect(view) == dynamicTypeSnapshot() expect(view) == dynamicTypeSnapshot(sizes: [UIContentSizeCategoryExtraLarge])
Note that this will post an
UIContentSizeCategoryDidChangeNotification, so your views/view controllers
need to observe that and update themselves.For more info on usage, check the dynamic type tests.
-
Removes support for Xcode 7.3 and Swift 2.2 - @marcelofabri
4.2.0
4.1.0
4.0.1
4.0.0
-
Nimble-Snapshots does not call
view?.drawViewHierarchyInRect(bounds, afterScreenUpdates: true)on your views by default. - @ortaIf this is something that you need in order to get your snapshots passing, you should look at two options:
-
Adding the view to an existing window, then calling
drawViewHierarchyInRect:afterScreenUpdates:- this
is the technique that is used insideFBSnapshotTestController, which we now expose as an option inrecordSnapshot
andhaveValidSnapshotasusesDrawRectexpect(imageView).to( recordSnapshot(usesDrawRect: true) ) expect(imageView).to( haveValidSnapshot(usesDrawRect: true) )
You can get more info on the technique on this issue
-
Spending time looking in how you can remove Async code from your App. Or look for places where you are relying on a view structure
which isn't set up in your tests. There are a bunch of examples in https://github.com/orta/pragmatic-testing on removing Async.
-
3.0.1
3.0.0
- Calls through to
drawViewHierarchyInRecton every snapshot prior to snapshot being made – @ashfurrow