Skip to content
Browse files

Initial commit

  • Loading branch information...
0 parents commit cdfad334e376db910ad4213a30238217d23b1e2a @casademora casademora committed Jul 27, 2010
15 .gitignore
@@ -0,0 +1,15 @@
+.DS_Store
+*.swp
+*~.nib
+
+build/
+
+*.pbxuser
+*.perspective
+*.perspectivev3
+
+.hg
+.hgtags
+
+*.mode1v3
+*.mode2v3
27 NSArray+Shoulda.h
@@ -0,0 +1,27 @@
+//
+// NSArray+Shoulda.h
+// Headlights
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+//#import <Cocoa/Cocoa.h>
+#import "ObjectiveShoulda.h"
+
+@interface NSArray (Shoulda)
+
+- (void) shouldContain:(id)expectedObject withReason:(NSString *)reason;
+- (void) shouldBeEmptyWithReason:(NSString *)reason;
+- (void) shouldNotBeEmptyWithReason:(NSString *)reason;
+- (NSNumber *) itemCount;
+
+@end
+
+@interface NSArray (SimpleShoulda)
+
+- (void) shouldContain:(id)expectedObject;
+- (void) shouldBeEmpty;
+- (void) shouldNotBeEmpty;
+
+@end
64 NSArray+Shoulda.m
@@ -0,0 +1,64 @@
+//
+// NSArray+Shoulda.m
+// Headlights
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "NSArray+Shoulda.h"
+
+
+@implementation NSArray (Shoulda)
+
+- (void) shouldContain:(id)expectedObject withReason:(NSString *)reason
+{
+ [self runTestCase:(TestBlock)^{
+ return expectedObject != nil && [self containsObject:expectedObject];
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should contain %@", self, expectedObject];
+ } andReason:reason];
+}
+
+- (void) shouldBeEmptyWithReason:(NSString *)reason;
+{
+ [self runTestCase:(TestBlock)^{
+ return [self count] == 0;
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should be empty", self];
+ } andReason:reason];
+}
+
+- (void) shouldNotBeEmptyWithReason:(NSString *)reason;
+{
+ [self runTestCase:(TestBlock)^{
+ return [self count] > 0;
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should NOT be empty", self];
+ } andReason:reason];
+}
+
+- (NSNumber *) itemCount
+{
+ return [NSNumber numberWithInt:[self count]];
+}
+
+@end
+
+@implementation NSArray (SimpleShoulda)
+
+- (void) shouldContain:(id)expectedObject;
+{
+ [self shouldContain:expectedObject withReason:@""];
+}
+
+- (void) shouldBeEmpty;
+{
+ [self shouldBeEmptyWithReason:@""];
+}
+
+- (void) shouldNotBeEmpty;
+{
+ [self shouldNotBeEmptyWithReason:@""];
+}
+@end
23 NSDate+Shoulda.h
@@ -0,0 +1,23 @@
+//
+// NSDate+Shoulda.h
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "ObjectiveShoulda.h"
+
+
+
+@interface NSDate (Shoulda)
+
+- (void) shouldBeSameAs:(NSDate *)expected withDescription:(NSString *)reason;
+
+@end
+
+@interface NSDate (SimpleShoulda)
+
+- (void) shouldBeSameAs:(NSDate *)expected;
+
+@end
+
30 NSDate+Shoulda.m
@@ -0,0 +1,30 @@
+//
+// NSDate+Shoulda.m
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "NSDate+Shoulda.h"
+
+
+@implementation NSDate (Shoulda)
+
+- (void) shouldBeSameAs:(NSDate *)expected withDescription:(NSString *)reason
+{
+ [self runTestCase:(TestBlock)^{
+ return [self isEqualToDate:expected];
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"'%@' should be the same date as '%@'", self, expected];
+ } andReason:reason];
+}
+
+@end
+@implementation NSDate (SimpleShoulda)
+
+- (void) shouldBeSameAs:(NSDate *)expected
+{
+ [self shouldBeSameAs:expected withDescription:@""];
+}
+
+@end
16 NSDictionary+Shoulda.h
@@ -0,0 +1,16 @@
+//
+// NSDictionary+Shoulda.h
+// Freshpod
+//
+// Created by Saul Mora on 7/26/10.
+// Copyright (c) 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "ObjectiveShoulda.h"
+
+@interface NSDictionary (Shoulda)
+
+- (void) shouldBeEmpty;
+
+@end
13 NSDictionary+Shoulda.m
@@ -0,0 +1,13 @@
+//
+// NSDictionary+Shoulda.m
+// Freshpod
+//
+// Created by Saul Mora on 7/26/10.
+// Copyright (c) 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "NSDictionary+Shoulda.h"
+
+@implementation NSDictionary (Shoulda)
+
+@end
14 NSManagedObject+Shoulda.h
@@ -0,0 +1,14 @@
+//
+// NSManagedObject+Shoulda.h
+// Headlights
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "ObjectiveShoulda.h"
+
+
+@interface NSManagedObject (Shoulda)
+
+@end
14 NSManagedObject+Shoulda.m
@@ -0,0 +1,14 @@
+//
+// NSManagedObject+Shoulda.m
+// Headlights
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "NSManagedObject+Shoulda.h"
+
+
+@implementation NSManagedObject (Shoulda)
+
+@end
24 NSNumber+Shoulda.h
@@ -0,0 +1,24 @@
+//
+// NSNumber+Shoulda.h
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "ObjectiveShoulda.h"
+
+
+
+@interface NSNumber (Shoulda)
+
+- (void) shouldBeEqualToValue:(NSInteger)expected withReason:(NSString *)reason;
+- (void) shouldBeEqualToDoubleValue:(double)expected withReason:(NSString *)reason;
+
+@end;
+
+@interface NSNumber(SimpleShoulda)
+
+- (void) shouldBeEqualToValue:(NSInteger)expected;
+- (void) shouldBeEqualToDoubleValue:(double)expected;
+
+@end
47 NSNumber+Shoulda.m
@@ -0,0 +1,47 @@
+//
+// NSNumber+Shoulda.m
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "NSNumber+Shoulda.h"
+
+
+
+
+@implementation NSNumber (Shoulda)
+
+- (void) shouldBeEqualToValue:(NSInteger)expected withReason:(NSString *)reason
+{
+ [self runTestCase:(TestBlock)^{
+ return [self integerValue] == expected;
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should == %d", self, expected];
+ } andReason:reason];
+}
+
+- (void) shouldBeEqualToDoubleValue:(double)expected withReason:(NSString *)reason
+{
+ [self runTestCase:(TestBlock)^{
+ return [self doubleValue] == expected;
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should == %f", self, expected];
+ } andReason:reason];
+}
+
+@end
+
+@implementation NSNumber (SimpleShoulda)
+
+- (void) shouldBeEqualToValue:(NSInteger)expected
+{
+ [self shouldBeEqualToValue:expected withReason:@""];
+}
+
+- (void) shouldBeEqualToDoubleValue:(double)expected
+{
+ [self shouldBeEqualToDoubleValue:expected withReason:@""];
+}
+
+@end
60 NSObject+Shoulda.h
@@ -0,0 +1,60 @@
+//
+// NSObject+Shoulda.h
+//
+// Created by Saul Mora on 3/11/10.
+// Copyright 2010 Magical Panda Software, LLC All rights reserved.
+//
+
+#import "ObjectiveShoulda.h"
+
+@interface NSObject (Shoulda)
+
++ (void) object:(id)actual shouldBe:(id)expected withDescription:(NSString *)reason;
++ (void) object:(id)actual shouldNotBe:(id)expected withDescription:(NSString *)reason;
+
+- (void) shouldBeNilWithDescription:(NSString *)reason;
+- (void) shouldNotBeNilWithDescription:(NSString *)reason;
+
+- (void) shouldBeTrueWithDescription:(NSString *)reason;
+- (void) shouldBeFalseWithDescription:(NSString *)reason;
+
+- (void) shouldBeEqualTo:(id)expected withDescription:(NSString *)reason;
+- (void) shouldNotBeEqualTo:(id)expected withDescription:(NSString *)reason;
+
+- (void) shouldThrowException:(NSException *)expectedException withDescription:(NSString *)reason;
+- (void) shouldThrowExceptionNamed:(NSString *)exceptionName withDescription:(NSString *)reason;
+
+- (void) shouldRespondToSelector:(SEL)expectedSelector withDescription:(NSString *)reason;
+- (void) shouldNotRespondToSelector:(SEL)selector withDescription:(NSString *)reason;
+
++ (void) shouldImplementProtocol:(Protocol *)expectedProtocol;
+
+@end
+
+@interface NSObject (SimpleShoulda)
+
++ (void) shouldBeNil:(id)actual;
++ (void) shouldNotBeNil:(id)actual;
+
++ (void) object:(id)actual shouldBe:(id)expected;
++ (void) object:(id)actual shouldNotBe:(id)expected;
+
+- (void) shouldBeNil;
+- (void) shouldNotBeNil;
+
+- (void) shouldBeTrue;
+- (void) shouldBeFalse;
+
+- (void) shouldBeEqualTo:(id)expected;
+
+
+- (void) shouldThrowException:(NSException *)expectedException;
+- (void) shouldThrowExceptionNamed:(NSString *)exceptionName;
+
+- (void) shouldRespondToSelector:(SEL)expectedSelector;
+- (void) shouldNotRespondToSelector:(SEL)selector;
+
++ (void) shouldImplementProtocol:(Protocol *)expectedProtocol;
+
+@end
+
188 NSObject+Shoulda.m
@@ -0,0 +1,188 @@
+//
+// NSObject+Shoulda.m
+//
+// Created by Saul Mora on 3/11/10.
+// Copyright 2010 Magical Panda Software, LLC All rights reserved.
+//
+
+#import "NSObject+Shoulda.h"
+
+@implementation NSObject (Shoulda)
+
++ (void) object:(id)actual shouldBe:(id)expected withDescription:(NSString *)reason
+{
+ GHAssertEquals(actual, expected, reason);
+}
+
++ (void) object:(id)actual shouldNotBe:(id)expected withDescription:(NSString *)reason
+{
+ GHAssertNotEquals(actual, expected, reason);
+}
+
+- (void) shouldNotBeNilWithDescription:(NSString *)reason
+{
+ [self runTestCase:(TestBlock)^{
+ return self != nil;
+ }
+ withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"((%@) should != nil)", [self description]];
+ } andReason:reason];
+}
+
+- (void) shouldBeNilWithDescription:(NSString *)reason
+{
+ [self runTestCase:(TestBlock)^ {
+ return self == nil;
+ }
+ withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"(%@) should == nil", [self description]];
+ } andReason:reason];
+}
+
+- (void) shouldBeTrueWithDescription:(NSString *)reason;
+{
+ [self runTestCase:(TestBlock)^ {
+ return [[NSNumber numberWithBool:YES] isEqualToNumber:(NSNumber *)self];
+ }
+ withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should == YES", [self description]];
+ } andReason:reason];
+}
+
+- (void) shouldBeFalseWithDescription:(NSString *)reason;
+{
+ [self runTestCase:(TestBlock)^ {
+ return [[NSNumber numberWithBool:NO] isEqualToNumber:(NSNumber *)self];
+ }
+ withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should == NO", [self description]];
+ } andReason:reason];
+}
+
+- (void) shouldBeEqualTo:(id)expected withDescription:(NSString *)reason;
+{
+ [self runTestCase:(TestBlock)^ {
+ return [expected isEqual:self];
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should == %@", [self description], [expected description]];
+ } andReason:reason];
+}
+
+
+- (void) shouldNotBeEqualTo:(id)expected withDescription:(NSString *)reason;
+{
+ [[NSException exceptionWithName:@"Not Yet implemented" reason:@"Fix Me!" userInfo:nil] raise];
+}
+
+- (void) shouldThrowException:(NSException *)expectedException withDescription:(NSString *)reason;
+{
+ [[NSException exceptionWithName:@"Not Yet implemented" reason:@"Fix Me!" userInfo:nil] raise];
+}
+
+- (void) shouldThrowExceptionNamed:(NSString *)exceptionName withDescription:(NSString *)reason;
+{
+ [[NSException exceptionWithName:@"Not Yet implemented" reason:@"Fix Me!" userInfo:nil] raise];
+}
+
+- (void) shouldRespondToSelector:(SEL)expectedSelector withDescription:(NSString *)reason
+{
+ [self runTestCase:(TestBlock)^{
+ return [self respondsToSelector:expectedSelector];
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"'%@' should respond to selector '%@'", self, NSStringFromSelector(expectedSelector)];
+ } andReason:reason];
+}
+
+- (void) shouldNotRespondToSelector:(SEL)selector withDescription:(NSString *)reason
+{
+ [self runTestCase:(TestBlock)^{
+ return ![self respondsToSelector:selector];
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"'%@' should NOT respond to selector '%@'", self, NSStringFromSelector(selector)];
+ } andReason:reason];
+}
+
++ (void) shouldImplementProtocol:(Protocol *)expectedProtocol withDescription:(NSString *)reason
+{
+ [self runTestCase:(TestBlock)^{
+ return [self conformsToProtocol:expectedProtocol];
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"'%@' should implement protocol '%@'", NSStringFromClass(self), NSStringFromProtocol(expectedProtocol)];
+ } andReason:reason];
+}
+
+@end
+
+
+@implementation NSObject (SimpleShoulda)
+
++ (void) shouldBeNil:(id)actual
+{
+ [NSObject object:actual shouldBe:nil];
+}
+
++ (void) shouldNotBeNil:(id)actual
+{
+ [NSObject object:actual shouldNotBe:nil];
+}
+
++ (void) object:(id)actual shouldBe:(id)expected
+{
+ [NSObject object:actual shouldBe:expected withDescription:@""];
+}
+
++ (void) object:(id)actual shouldNotBe:(id)expected;
+{
+ [NSObject object:actual shouldNotBe:expected withDescription:@""];
+}
+
+- (void) shouldBeNil
+{
+ [self shouldBeNilWithDescription:@""];
+}
+
+- (void) shouldNotBeNil
+{
+ [self shouldNotBeNilWithDescription:@""];
+}
+
+- (void) shouldBeTrue
+{
+ [self shouldBeTrueWithDescription:@""];
+}
+
+- (void) shouldBeFalse
+{
+ [self shouldBeFalseWithDescription:@""];
+}
+
+- (void) shouldBeEqualTo:(id)expected
+{
+ [self shouldBeEqualTo:expected withDescription:@""];
+}
+
+- (void) shouldThrowException:(NSException *)expectedException
+{
+ [self shouldThrowException:expectedException withDescription:@""];
+}
+
+- (void) shouldThrowExceptionNamed:(NSString *)exceptionName
+{
+ [self shouldThrowExceptionNamed:exceptionName withDescription:@""];
+}
+
+- (void) shouldRespondToSelector:(SEL)expectedSelector
+{
+ [self shouldRespondToSelector:expectedSelector withDescription:@""];
+}
+
+- (void) shouldNotRespondToSelector:(SEL)selector
+{
+ [self shouldNotRespondToSelector:selector withDescription:@""];
+}
+
++ (void) shouldImplementProtocol:(Protocol *)expectedProtocol
+{
+ [self shouldImplementProtocol:expectedProtocol withDescription:@""];
+}
+@end
26 NSSet+Shoulda.h
@@ -0,0 +1,26 @@
+//
+// NSSet+Shoulda.h
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "ObjectiveShoulda.h"
+
+
+@interface NSSet (Shoulda)
+
+- (void) shouldContain:(id)expectedObject withReason:(NSString *)reason;
+- (void) shouldBeEmptyWithReason:(NSString *)reason;
+- (void) shouldNotBeEmptyWithReason:(NSString *)reason;
+- (NSNumber *) itemCount;
+
+@end
+
+@interface NSSet (SimpleShoulda)
+
+- (void) shouldContain:(id)expectedObject;
+- (void) shouldBeEmpty;
+- (void) shouldNotBeEmpty;
+
+@end
65 NSSet+Shoulda.m
@@ -0,0 +1,65 @@
+//
+// NSSet+Shoulda.m
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "NSSet+Shoulda.h"
+
+
+
+@implementation NSSet (Shoulda)
+
+- (void) shouldContain:(id)expectedObject withReason:(NSString *)reason
+{
+ [self runTestCase:(TestBlock)^{
+ return expectedObject != nil && [self containsObject:expectedObject];
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should contain %@", self, expectedObject];
+ } andReason:reason];
+}
+
+- (void) shouldBeEmptyWithReason:(NSString *)reason;
+{
+ [self runTestCase:(TestBlock)^{
+ return [self count] == 0;
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should be empty", self];
+ } andReason:reason];
+}
+
+- (void) shouldNotBeEmptyWithReason:(NSString *)reason;
+{
+ [self runTestCase:(TestBlock)^{
+ return [self count] > 0;
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"%@ should NOT be empty", self];
+ } andReason:reason];
+}
+
+- (NSNumber *) itemCount
+{
+ return [NSNumber numberWithInt:[self count]];
+}
+
+@end
+
+@implementation NSSet (SimpleShoulda)
+
+- (void) shouldContain:(id)expectedObject;
+{
+ [self shouldContain:expectedObject withReason:@""];
+}
+
+- (void) shouldBeEmpty;
+{
+ [self shouldBeEmptyWithReason:@""];
+}
+
+- (void) shouldNotBeEmpty;
+{
+ [self shouldNotBeEmptyWithReason:@""];
+}
+
+@end
27 NSString+Shoulda.h
@@ -0,0 +1,27 @@
+//
+// NSString+Shoulda.h
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "ObjectiveShoulda.h"
+
+
+@interface NSString (Shoulda)
+
+- (void) shouldBeEqualToString:(NSString *)expected withDescription:(NSString *)reason;
+- (void) shouldNotBeEqualToString:(NSString *)notExpected withDescription:(NSString *)reason;
+- (void) shouldBeEqualToCString:(char *)expected withDescription:(NSString *)reason;
+- (void) shouldNotBeEqualToCString:(char *)notExpected withDescription:(NSString *)reason;
+
+@end
+
+@interface NSString (SimpleShoulda)
+
+- (void) shouldBeEqualToString:(NSString *)expected;
+- (void) shouldNotBeEqualToString:(NSString *)notExpected;
+- (void) shouldBeEqualToCString:(char *)expected;
+- (void) shouldNotBeEqualToCString:(char *)notExpected;
+
+@end
67 NSString+Shoulda.m
@@ -0,0 +1,67 @@
+//
+// NSString+Shoulda.m
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "NSString+Shoulda.h"
+
+
+
+@implementation NSString (Shoulda)
+
+- (void) shouldBeEqualToString:(NSString *)expected withDescription:(NSString *)reason;
+{
+ [self runTestCase:(TestBlock)^{
+ return [self isEqualToString:expected];
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"'%@' should be equal to '%@'", self, expected];
+ } andReason:reason];
+}
+
+- (void) shouldNotBeEqualToString:(NSString *)notExpected withDescription:(NSString *)reason;
+{
+ [self runTestCase:(TestBlock)^{
+ return ![self isEqualToString:notExpected];
+ } withDescription:(ExpressionBlock)^{
+ return [NSString stringWithFormat:@"'%@' should NOT be equal to '%@'", self, notExpected];
+ } andReason:reason];
+}
+
+- (void) shouldBeEqualToCString:(char *)expected withDescription:(NSString *)reason;
+{
+ [[NSException exceptionWithName:@"Not Yet implemented" reason:@"Fix Me!" userInfo:nil] raise];
+}
+
+- (void) shouldNotBeEqualToCString:(char *)notExpected withDescription:(NSString *)reason;
+{
+ [[NSException exceptionWithName:@"Not Yet implemented" reason:@"Fix Me!" userInfo:nil] raise];
+}
+
+@end
+
+
+@implementation NSString (SimpleShoulda)
+
+- (void) shouldBeEqualToString:(NSString *)expected
+{
+ [self shouldBeEqualToString:expected withDescription:@""];
+}
+
+- (void) shouldNotBeEqualToString:(NSString *)notExpected
+{
+ [self shouldNotBeEqualToString:notExpected withDescription:@""];
+}
+
+- (void) shouldBeEqualToCString:(char *)expected
+{
+ [self shouldBeEqualToCString:expected withDescription:@""];
+}
+
+- (void) shouldNotBeEqualToCString:(char *)notExpected
+{
+ [self shouldNotBeEqualToCString:notExpected withDescription:@""];
+}
+
+@end
22 ObjectiveShoulda.h
@@ -0,0 +1,22 @@
+//
+// ObjectiveShoulda.h
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+//#ifndef TARGET_IPHONE_OS
+//#import <Cocoa/Cocoa.h>
+//#endif
+#import "GHUnit.h"
+
+typedef BOOL (^TestBlock)();
+typedef NSString* (^ExpressionBlock)();
+
+@interface NSObject (ShouldaTestBlock)
+
+- (void) failWithException:(NSException *)exception;
+- (void) runTestCase:(TestBlock)testBlock withDescription:(ExpressionBlock)description andReason:(NSString *)reason;
+- (void) runTestCase:(TestBlock)block withDescription:(ExpressionBlock)description;
+
+@end
51 ObjectiveShoulda.m
@@ -0,0 +1,51 @@
+//
+// ObjectiveShoulda.m
+//
+// Created by Saul Mora on 7/4/10.
+// Copyright 2010 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "ObjectiveShoulda.h"
+
+
+
+@implementation NSObject (ObjectiveShoulda)
+
+
+- (void) failWithException:(NSException *)exception
+{
+ [exception raise];
+}
+
+- (void) runTestCase:(TestBlock)testBlock withDescription:(ExpressionBlock)description andReason:(NSString *)reason
+{
+ do
+ {
+ @try
+ {
+ if (testBlock()) return;
+
+ [self failWithException:[NSException ghu_failureInCondition: description()
+ isTrue: NO
+ inFile: [NSString stringWithUTF8String:__FILE__]
+ atLine: __LINE__
+ withDescription: reason]];
+ }
+ @catch (id anException)
+ {
+ [self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"%@ failed with exception", description()]
+ exception:anException
+ inFile:[NSString stringWithUTF8String:__FILE__]
+ atLine:__LINE__
+ withDescription:reason]];
+ }
+
+ } while (0);
+}
+
+- (void) runTestCase:(TestBlock)block withDescription:(ExpressionBlock)description
+{
+ [self runTestCase:block withDescription:description andReason:@""];
+}
+
+@end

0 comments on commit cdfad33

Please sign in to comment.
Something went wrong with that request. Please try again.