summaryrefslogtreecommitdiffstats
path: root/third_party/ocmock/OCMock/OCMockObjectHamcrestTests.mm
blob: 8059deb8014b19cf5b60436cf818990a1988693e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//---------------------------------------------------------------------------------------
//  $Id: OCMockObjectTests.m 21 2008-01-24 18:59:39Z erik $
//  Copyright (c) 2004-2008 by Mulle Kybernetik. See License file for details.
//---------------------------------------------------------------------------------------

#import <OCMock/OCMock.h>
#import "OCMockObjectHamcrestTests.h"

#define HC_SHORTHAND
#import <hamcrest/hamcrest.h>


@implementation OCMockObjectHamcrestTests

- (void)testAcceptsStubbedMethodWithHamcrestConstraint
{
	id mock = [OCMockObject mockForClass:[NSString class]];
	[[mock stub] hasSuffix:(id)startsWith(@"foo")];
	[mock hasSuffix:@"foobar"];
}


- (void)testRejectsUnstubbedMethodWithHamcrestConstraint
{
	id mock = [OCMockObject mockForClass:[NSString class]];
	[[mock stub] hasSuffix:(id)anyOf(equalTo(@"foo"), equalTo(@"bar"), NULL)];
	STAssertThrows([mock hasSuffix:@"foobar"], @"Should have raised an exception.");
}


@end