Permalink
Browse files

added support for context, xcontext, xdescribe and xit

  • Loading branch information...
petejkim committed Oct 31, 2010
1 parent c7f6126 commit 8b7cdbf5a9ac750f55d76609a107ca54f47f5c86
Showing with 41 additions and 0 deletions.
  1. +16 −0 Source/CDRSpec.m
  2. +4 −0 Source/Headers/CDRSpec.h
  3. +21 −0 Spec/SpecSpec.m
View
@@ -31,6 +31,22 @@ void fail(NSString *reason) {
[[CDRSpecFailure specFailureWithReason:[NSString stringWithFormat:@"Failure: %@", reason]] raise];
}
+void context(NSString *text, CDRSpecBlock block) {
+ describe(text, block);
+}
+
+void xcontext(NSString *text, CDRSpecBlock block) {
+ it(text, PENDING);
+}
+
+void xdescribe(NSString *text, CDRSpecBlock block) {
+ it(text, PENDING);
+}
+
+void xit(NSString *text, CDRSpecBlock block) {
+ it(text, PENDING);
+}
+
@implementation CDRSpec
@synthesize currentGroup = currentGroup_, rootGroup = rootGroup_;
View
@@ -17,6 +17,10 @@ void beforeEach(CDRSpecBlock);
void afterEach(CDRSpecBlock);
void it(NSString *, CDRSpecBlock);
void fail(NSString *);
+void context(NSString *, CDRSpecBlock);
+void xcontext(NSString *, CDRSpecBlock);
+void xdescribe(NSString *, CDRSpecBlock);
+void xit(NSString *, CDRSpecBlock);
#ifdef __cplusplus
}
#endif
View
@@ -54,12 +54,33 @@ void expectFailure(CDRSpecBlock block) {
});
});
+ context(@"a nested spec (context)", ^ {
+ beforeEach(^ {
+ // NSLog(@"=====================> I should run only before the nested specs.");
+ });
+
+ afterEach(^ {
+ // NSLog(@"=====================> I should run only after the nested specs.");
+ });
+
+ it(@"should also run", ^ {
+ // NSLog(@"=====================> Nested spec");
+ });
+
+ it(@"should also also run", ^ {
+ // NSLog(@"=====================> Another nested spec");
+ });
+ });
+
it(@"should run", ^ {
// NSLog(@"=====================> Spec");
});
it(@"should be pending", PENDING);
it(@"should also be pending", nil);
+ xit(@"should also be pending (xit)", ^{});
+ xcontext(@"xcontexted specs should be pending", ^{});
+ xdescribe(@"xdescribed specs should be pending", ^{});
});
describe(@"The spec failure exception", ^{

0 comments on commit 8b7cdbf

Please sign in to comment.