Skip to content

Instantly share code, notes, and snippets.

@kylef kylef/Mocta.md forked from orta/Mocta.md
Last active Aug 29, 2015

Embed
What would you like to do?

Getting a Mocta object

NSUserDefaults<Mocta> *defaults = [Mocta objectWithClass:[NSUserDefaults class]];
id< UITableViewDelegate , MoctaStub> delegate = [Mocta objectWithProtocol:@protocol(UITableViewDelegate)];

Expectations

Expectations are ran on dealloc, so I don't have to do it manually.

object.expect( @selector(method:) )
object.expect( @selector(method:) ).matching(BOOL ^(id self, id argument) { return [argument isEqualToNumber:@YES]; } )

object.reject( @selector(method:) )

Stubbing

object.stub(@selector(method:)).with( NSNumber * ^(id self, id argument) { return @YES } );
object.stub(@selector(method:)).with( NSNumber * ^(id self, id argument) { return @"string" } );
object.stub(@selector(method:)).returning(@YES);

object.stub(@selector(method:)).callOriginal().replaceWith( ^{ return @(YES)} );

MyClass.class.stub(@selector(method:))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.