Commit 7aa5c0e
Changed files (1)
MovieLibraryTests
MovieLibraryTests/MovieLibrarySpec.m
@@ -7,24 +7,32 @@
@end
@interface MovieLibrary : NSObject
-+(MovieLibrary*)initialize;
+@property (strong, nonatomic) NSMutableArray *items;
-(void)add:(Movie*)movie;
-(int)total_movies;
-(BOOL)includes:(Movie*)movie;
@end
@implementation MovieLibrary
+-(id)init
+{
+ self = [super init];
+ if(self) {
+ _items = [[NSMutableArray alloc]init];
+ }
+ return self;
+}
-(void)add:(Movie*)movie
{
- //[movies addObject:movie];
+ [_items addObject:movie];
}
-(int)total_movies
{
- return 1;
+ return [_items count];
}
-(BOOL)includes:(Movie*)movie
{
- return true;
+ return [_items containsObject:movie];
}
@end
@@ -36,24 +44,32 @@ describe(@"MovieLibrary", ^{
__block id sut = nil;
__block id brave = nil;
__block id monsters_inc = nil;
+ __block id blah = nil;
beforeAll(^{
sut = [[MovieLibrary alloc]init];
brave = [Movie new];
monsters_inc = [Movie new];
+ blah = [Movie new];
[sut add:brave];
[sut add:monsters_inc];
});
it(@"should indicate the corrent number of movies", ^{
int result = [sut total_movies];
- [[theValue(result) should] equal:theValue(1)];
+ [[theValue(result) should] equal:theValue(2)];
});
it(@"should include each movie", ^{
[[theValue([sut includes:brave]) should] equal:theValue(true)];
[[theValue([sut includes:monsters_inc]) should] equal:theValue(true)];
});
+
+ context(@"when a movie is not in the library", ^{
+ it(@"should return false", ^{
+ [[theValue([sut includes:blah]) should] equal:theValue(false)];
+ });
+ });
});
});