Skip to content

Instantly share code, notes, and snippets.

@keokilee
Created October 14, 2014 02:48
Show Gist options
  • Save keokilee/74b6035f7c446b281452 to your computer and use it in GitHub Desktop.
Save keokilee/74b6035f7c446b281452 to your computer and use it in GitHub Desktop.
Kiwi Mocks and Stubs
#import <Kiwi/Kiwi.h>
#import “ViewController.h”
#import “AFHTTPRequestOperationManager.h”
SPEC_BEGIN(MocksControllerSpec)
describe(@”ViewController”, ^{
let(controller, ^{return [[UIStoryboard storyboardWithName:@”Main” bundle:nil] instantiateViewControllerWithIdentifier:@”ViewController”];
let(mockManager, ^{return [AFHTTPRequestOperationManager mock];});
beforeEach(^{
[AFHTTPRequestOperationManager stub:@selector(manager) andReturn:mockManager];
});
it(@”fetches using the data.honolulu.gov endpoint”, ^{
KWCaptureSpy *spy = [mockManager captureArgument:@selector(GET:parameters:success:failure☺ atIndex:0];
[controller loadView];
[controller viewDidLoad];
[[[spy argument] should] equal:@”http://data.honolulu.gov/resource/a96q-gyhq.json"];
});
});
SPEC_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment