Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

Commit

Permalink
Added examples that uses a @dynamic property (reference issue 34)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeredpath committed Jun 30, 2011
1 parent debf48e commit 3bd4e40
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Classes/Cruiser.h
Expand Up @@ -17,7 +17,6 @@
Engine *engine;
NSArray *fighters;
}

#pragma mark -
#pragma mark Initializing

Expand All @@ -31,9 +30,9 @@

@property (nonatomic, readonly) NSString *callsign;
@property (nonatomic, retain) Engine *engine;
@property (nonatomic, readonly) NSString *classification;

+ (NSString *)classification;

- (NSUInteger)crewComplement;

#pragma mark -
Expand Down
5 changes: 5 additions & 0 deletions Classes/Cruiser.m
Expand Up @@ -41,11 +41,16 @@ - (void)dealloc {

@synthesize callsign;
@synthesize engine;
@dynamic classification;

+ (NSString *)classification {
return @"Capital Ship";
}

- (NSString *)classification {
return [[self class] classification];
}

- (NSUInteger)crewComplement {
return 1010;
}
Expand Down
14 changes: 14 additions & 0 deletions Examples/ExampleSpec.m
Expand Up @@ -83,6 +83,20 @@
it(@"should have fighters (using custom matcher)", ^{
[[cruiser should] haveFighters];
});

it(@"should work with @dynamic properties", ^{
[[cruiser.classification should] equal:@"Capital Ship"];
});

it(@"should allow @dynamic properties to be stubbed with message pattern", ^{
[[cruiser stubAndReturn:@"Galaxy Class Ship"] classification];
[[cruiser.classification should] equal:@"Galaxy Class Ship"];
});

it(@"should allow @dynamic properties to be stubbed with API", ^{
[cruiser stub:@selector(classification) andReturn:@"Galaxy Class Ship"];
[[cruiser.classification should] equal:@"Galaxy Class Ship"];
});
});
});

Expand Down

0 comments on commit 3bd4e40

Please sign in to comment.