Skip to content

Commit

Permalink
Added support for Carthage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed-Ali committed Nov 27, 2016
1 parent fd67120 commit 5deccd5
Show file tree
Hide file tree
Showing 6 changed files with 764 additions and 6 deletions.
6 changes: 6 additions & 0 deletions Cucumberish/Cucumberish.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
*/
@property (nonatomic) NSString * testTargetFolderName;


/**
If Cucumberish is installed with Carthage, set the value of this property to be SRC_ROOT which is the preprocessor macro you defined in your build settings
*/
@property (nonatomic, strong) NSString * testTargetSrcRoot;

/**
Retuans a singleton instance of Cucumberish
Expand Down
14 changes: 8 additions & 6 deletions Cucumberish/Cucumberish.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ - (instancetype)init
self.beforeHocks = [NSMutableArray array];
self.afterHocks = [NSMutableArray array];
self.aroundHocks = [NSMutableArray array];
#ifdef SRC_ROOT
self.testTargetSrcRoot = SRC_ROOT;
//Clean up unwanted /Pods path caused by cocoa pods
if([self.testTargetSrcRoot hasSuffix:@"/Pods"]){
self.testTargetSrcRoot = [self.testTargetSrcRoot stringByReplacingCharactersInRange:NSMakeRange(self.testTargetSrcRoot.length - 5, 5) withString:@""];
}
#endif
return self;
}

Expand Down Expand Up @@ -510,19 +517,14 @@ void executeSteps(XCTestCase * testCase, NSArray * steps, id parentScenario)
{

NSString * targetName = [[Cucumberish instance] testTargetFolderName] ? : [[[Cucumberish instance] containerBundle] infoDictionary][@"CFBundleName"];
NSString * srcRoot = SRC_ROOT;
//Clean up unwanted /Pods path caused by cocoa pods
if([srcRoot hasSuffix:@"/Pods"]){
srcRoot = [srcRoot stringByReplacingCharactersInRange:NSMakeRange(srcRoot.length - 5, 5) withString:@""];
}

for (CCIStep * step in steps) {

@try {
[[CCIStepsManager instance] executeStep:step inTestCase:testCase];
}
@catch (CCIExeption *exception) {
NSString * filePath = [NSString stringWithFormat:@"%@/%@%@", srcRoot, targetName, step.location.filePath];
NSString * filePath = [NSString stringWithFormat:@"%@/%@%@", [Cucumberish instance].testTargetSrcRoot, targetName, step.location.filePath];
[testCase recordFailureWithDescription:exception.reason inFile:filePath atLine:step.location.line expected:YES];
if([parentScenario isKindOfClass:[CCIScenarioDefinition class]]){
CCIScenarioDefinition * scenario = (CCIScenarioDefinition *)parentScenario;
Expand Down
24 changes: 24 additions & 0 deletions CucumberishExample/CucumberishCarthage/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
Loading

0 comments on commit 5deccd5

Please sign in to comment.