Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds test project and ruby/cucumber type json output #39

Merged
merged 2 commits into from
Feb 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
CucumberishExample/CucumberishExample.xcworkspace/xcuserdata/*
CucumberishExample/CucumberishExample.xcodeproj/xcuserdata/*
CucumberishExample/Pods/Pods.xcodeproj/xcuserdata/*
CucumberishLibraryTest/CucumberishLibrary.xcodeproj/xcuserdata/*
CucumberishLibraryTest/CucumberishLibrary.xcodeproj/project.xcworkspace/xcuserdata/*

CucumberishExample/DerivedData
CucumberishExample/Build
2 changes: 2 additions & 0 deletions Cucumberish/Core/Models/CCIFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
@property (nonatomic, strong) CCIBackground * background;
@property (nonatomic, strong) CCILocation * location;
@property (nonatomic, copy) NSString * name;
@property (nonatomic, copy) NSString * docDescription;//this property saves the description of the feature from the parsed feature to save it for JSON output
@property (nonatomic, strong) NSArray<CCIScenarioDefinition *> * scenarioDefinitions;
@property (nonatomic, strong) NSArray <NSString *> * tags;
@property (nonatomic, strong, readonly) NSArray <NSDictionary *> * rawTags;//the tags property loses information needed for the JSON output. This preserves the raw tag formatting
-(instancetype)initWithDictionary:(NSDictionary *)dictionary;

-(NSDictionary *)toDictionary;
Expand Down
38 changes: 23 additions & 15 deletions Cucumberish/Core/Models/CCIFeature.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import "CCIFeature.h"

@interface CCIFeature ()
@property (nonatomic, strong) NSArray<NSDictionary *>* rawTags;
@end
@implementation CCIFeature

Expand All @@ -40,21 +41,24 @@ @implementation CCIFeature

-(instancetype)initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];


if(dictionary[@"location"] != nil && ![dictionary[@"location"] isKindOfClass:[NSNull class]]){
self.location = [[CCILocation alloc] initWithDictionary:dictionary[@"location"]];
}

if(dictionary[@"name"] != nil && ![dictionary[@"name"] isKindOfClass:[NSNull class]]){
self.name = dictionary[@"name"];
}

self = [super init];


if(dictionary[@"location"] != nil && ![dictionary[@"location"] isKindOfClass:[NSNull class]]){
self.location = [[CCILocation alloc] initWithDictionary:dictionary[@"location"]];
}

if(dictionary[@"name"] != nil && ![dictionary[@"name"] isKindOfClass:[NSNull class]]){
self.name = dictionary[@"name"];
}
if(dictionary[@"description"] != nil && ![dictionary[@"description"] isKindOfClass:[NSNull class]]){
self.docDescription = dictionary[@"description"];
}
if(dictionary[@"parsedTags"] != nil){
self.tags = dictionary[@"parsedTags"];
}else if(dictionary[@"tags"] != nil && [dictionary[@"tags"] isKindOfClass:[NSArray class]]){
NSArray * tagsDictionaries = dictionary[@"tags"];
[self setRawTags:dictionary[@"tags"]];
NSMutableArray * tagsItems = [NSMutableArray array];
for(NSDictionary * tagDictionary in tagsDictionaries){
NSString * tagName = tagDictionary[@"name"];
Expand Down Expand Up @@ -122,10 +126,14 @@ -(NSDictionary *)toDictionary
if(self.tags.count > 0){
dictionary[@"parsedTags"] = self.tags;
}


return dictionary;

if (self.docDescription != nil)
{
dictionary[@"description"]= self.docDescription;
}


return dictionary;

}

/**
Expand Down
31 changes: 31 additions & 0 deletions Cucumberish/Core/Models/CCIJSONDumper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// CCIJSONDumper.h
// AMBluetooth
//
// Created by ereynolds on 11/11/16.
// Copyright © 2016 Ahmed Ali. All rights reserved.
//

#import <Foundation/Foundation.h>
@class CCIFeature;
@interface CCIJSONDumper : NSObject

/*!
* @author Erik Call Reynolds
* @date 16-11-15 12:11:00
*
* @brief creates the Cucumber JSON Output String similar to the ruby/cucumber JSON output option
*
* @param features The array of features to output as JSON
*
* @return JSON String
*
* @note Omitted the Match Dictionary for each Step definition as it no longer applies in Objective-C
* @note Omitted the Execution Duration of each Step due to the complexity level
*/
+(NSString*)buildJSONOutputString:(NSArray<CCIFeature*>*)features;
+(NSData*)buildJSONOutputData:(NSArray<CCIFeature*>*)features;

+(NSString*)writeJSONToFile:(NSString*)filename
forFeatures:(NSArray<CCIFeature*>*)features;
@end
Loading