|
10 | 10 | #include <Specta/Specta.h>
|
11 | 11 | #include <Expecta/Expecta.h>
|
12 | 12 | #include <Expecta+Snapshots/EXPMatchers+FBSnapshotTest.h>
|
| 13 | +#import <FBSnapshotTestCase/FBSnapshotTestCasePlatform.h> |
13 | 14 |
|
14 | 15 | #include "FBExampleView.h"
|
15 | 16 | #import "FBViewController.h"
|
|
191 | 192 | }).to.raise(@"Nil was passed into haveValidSnapshot. snapshots_with_a_view_controller_Raises_when_a_nil_is_passed_in");
|
192 | 193 | });
|
193 | 194 | });
|
| 195 | + |
| 196 | + describe(@"device agnostic", ^{ |
| 197 | + |
| 198 | + __block FBViewController *controller; |
| 199 | + |
| 200 | + before(^{ |
| 201 | + controller = [[FBRedViewController alloc] init]; |
| 202 | + controller.view.frame = frame; |
| 203 | + [Expecta setDeviceAgnostic:TRUE]; |
| 204 | + }); |
| 205 | + |
| 206 | + after(^{ |
| 207 | + [Expecta setDeviceAgnostic:FALSE]; |
| 208 | + }); |
| 209 | + |
| 210 | + describe(@"recording", ^{ |
| 211 | + |
| 212 | + it(@"named", ^{ |
| 213 | + expect(controller).toNot.recordSnapshotNamed(@"view controller 1"); |
| 214 | + expect(controller.viewWillAppearCalled).to.beTruthy(); |
| 215 | + expect(controller.viewDidAppearCalled).to.beTruthy(); |
| 216 | + NSString *imageName = [[fileManager contentsOfDirectoryAtPath:imagesDirectory error:nil] firstObject]; |
| 217 | + NSString *expectedImageName = FBDeviceAgnosticNormalizedFileName(@"view controller 1"); |
| 218 | + expect(imageName).to.contain(expectedImageName); |
| 219 | + }); |
| 220 | + |
| 221 | + it(@"unnamed", ^{ |
| 222 | + expect(controller).toNot.recordSnapshot(); |
| 223 | + expect(controller.viewWillAppearCalled).to.beTruthy(); |
| 224 | + expect(controller.viewDidAppearCalled).to.beTruthy(); |
| 225 | + NSString *imageName = [[fileManager contentsOfDirectoryAtPath:imagesDirectory error:nil] firstObject]; |
| 226 | + NSString *expectedImageName = FBDeviceAgnosticNormalizedFileName(@"snapshots_device_agnostic_recording_unnamed"); |
| 227 | + expect(imageName).to.contain(expectedImageName); |
| 228 | + }); |
| 229 | + |
| 230 | + }); |
| 231 | + |
| 232 | + describe(@"unnamed", ^{ |
| 233 | + |
| 234 | + describe(@"named", ^{ |
| 235 | + |
| 236 | + it(@"matches view controller", ^{ |
| 237 | + expect(controller).toNot.recordSnapshotNamed(@"view controller 2"); |
| 238 | + |
| 239 | + FBViewController *newVC = [[FBRedViewController alloc] init]; |
| 240 | + newVC.view.frame = frame; |
| 241 | + expect(newVC).to.haveValidSnapshotNamed(@"view controller 2"); |
| 242 | + expect(newVC.viewWillAppearCalled).to.beTruthy(); |
| 243 | + expect(newVC.viewDidAppearCalled).to.beTruthy(); |
| 244 | + }); |
| 245 | + |
| 246 | + }); |
| 247 | + |
| 248 | + it(@"matches view controller", ^{ |
| 249 | + expect(controller).toNot.recordSnapshot(); |
| 250 | + |
| 251 | + FBViewController *newVC = [[FBRedViewController alloc] init]; |
| 252 | + newVC.view.frame = frame; |
| 253 | + expect(newVC).to.haveValidSnapshot(); |
| 254 | + expect(newVC.viewWillAppearCalled).to.beTruthy(); |
| 255 | + expect(newVC.viewDidAppearCalled).to.beTruthy(); |
| 256 | + }); |
| 257 | + |
| 258 | + }); |
| 259 | + |
| 260 | + }); |
194 | 261 | });
|
195 | 262 |
|
196 | 263 | SpecEnd
|
|
0 commit comments