Skip to content

Commit

Permalink
fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
rmpestano committed Jun 30, 2015
1 parent 066c981 commit 4105655
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Feature: Cukedoctor Main
|Duration
|Status
12+^|*<<One passing scenario, one failing scenario>>*
12+^|*<<One-passing-scenario--one-failing-scenario>>*
|1
|1
|2
Expand All @@ -59,6 +59,7 @@ Feature: Cukedoctor Main
== *Features*
[[One-passing-scenario--one-failing-scenario, One passing scenario, one failing scenario]]
=== *One passing scenario, one failing scenario*
==== Scenario: Passing
Expand Down Expand Up @@ -124,7 +125,7 @@ features/one_passing_one_failing.feature:10:in Given this step fails'
|Duration
|Status
12+^|*<<An embed data directly feature>>*
12+^|*<<An-embed-data-directly-feature>>*
|3
|0
|3
Expand All @@ -138,7 +139,7 @@ features/one_passing_one_failing.feature:10:in Given this step fails'
|000ms
|[green]#*passed*#
12+^|*<<An outline feature>>*
12+^|*<<An-outline-feature>>*
|0
|1
|1
Expand All @@ -152,7 +153,7 @@ features/one_passing_one_failing.feature:10:in Given this step fails'
|000ms
|[red]#*failed*#
12+^|*<<One passing scenario, one failing scenario>>*
12+^|*<<One-passing-scenario--one-failing-scenario>>*
|1
|1
|2
Expand All @@ -166,7 +167,7 @@ features/one_passing_one_failing.feature:10:in Given this step fails'
|010ms
|[red]#*failed*#
12+^|*<<Sample test>>*
12+^|*<<Sample-test>>*
|1
|2
|3
Expand All @@ -185,6 +186,7 @@ features/one_passing_one_failing.feature:10:in Given this step fails'
== *Features*
[[An-embed-data-directly-feature, An embed data directly feature]]
=== *An embed data directly feature*
==== Scenario: scenario 1
Expand All @@ -204,6 +206,7 @@ Given ::
I embed data directly icon:thumbs-up[role="green",title="Passed"] [small right]#(000ms)#
****
[[An-outline-feature, An outline feature]]
=== *An outline feature*
==== Scenario Outline: outline
Expand All @@ -228,6 +231,7 @@ Given ::
this step <status> icon:thumbs-down[role="blue",title="Missing"]
****
[[One-passing-scenario--one-failing-scenario, One passing scenario, one failing scenario]]
=== *One passing scenario, one failing scenario*
==== Scenario: Passing
Expand All @@ -250,6 +254,7 @@ IMPORTANT: (RuntimeError)
features/one_passing_one_failing.feature:10:in Given this step fails'
****
[[Sample-test, Sample test]]
=== *Sample test*
****
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ public interface CukedoctorReporter {
CukedoctorReporter saveDocumentation();

CukedoctorReporter renderScenarioExamples(Scenario scenario);

String renderFeatureSectionId(Feature feature);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.File;
import java.util.List;

import static com.github.cukedoctor.util.Assert.*;
import static com.github.cukedoctor.util.Constants.Markup.*;
import static com.github.cukedoctor.util.Constants.Atributes.*;
import static com.github.cukedoctor.util.Constants.newLine;
Expand Down Expand Up @@ -133,7 +134,7 @@ public CukedoctorReporterImpl renderSummary() {

for (Feature feature : features) {
writer.write(newLine());
writer.write("12+^" + tableCol(), "*<<", feature.getName(), ">>*", newLine());
writer.write("12+^" + tableCol(), "*<<", feature.getName().replaceAll(" ","-").replaceAll(",","-"), ">>*", newLine());
StepResults stepResults = feature.getStepResults();
ScenarioResults scenarioResults = feature.getScenarioResults();

Expand Down Expand Up @@ -194,6 +195,7 @@ public CukedoctorReporterImpl renderTotalsRow() {
}

public CukedoctorReporterImpl renderFeature(Feature feature) {
writer.write(renderFeatureSectionId(feature),newLine());
writer.write(H3(bold(feature.getName())), newLine(), newLine());
if (feature.getDescription() != null && !"".equals(feature.getDescription().trim())) {
writer.write("****", newLine()).
Expand All @@ -207,6 +209,14 @@ public CukedoctorReporterImpl renderFeature(Feature feature) {
return this;
}

public String renderFeatureSectionId(Feature feature) {
if(isNull(feature) || not(hasText(feature.getName()))){
return "";
}
return "[[" + feature.getName().replaceAll(" ","-").replaceAll(",","-") +
", " + feature.getName()+"]]";
}

public CukedoctorReporterImpl renderFeatureScenarios(Feature feature) {
for (Scenario scenario : feature.getScenarios()) {
writer.write(H4(scenario.getKeyword()), ": ", scenario.getName(), newLine());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package com.github.cukedoctor.util;

import java.io.Serializable;
import java.util.Collection;
import java.util.Map;

/**
* Created by rafael-pestano on 26/06/2015.
*/
public class Assert implements Serializable {

private Assert() {

}

/**
* @return TRUE assertion when given objects is not null, FALSE otherwise
*/
public static boolean notNull(Object object) {

return object != null;
}

/**
* @return TRUE assertion when given objects is null, FALSE otherwise
*/
public static boolean isNull(Object object) {

return object == null;
}

/**
* just negates the assertion
*/
public static boolean not(boolean assertion) {

return !assertion;
}

/**
* @return TRUE when given text has any character, FALSE otherwise
*/
public static boolean hasText(String text) {
if (notNull(text) && text.trim().length() > 0) {
return true;
}
return false;
}

/**
* @return TRUE when given text contains the given substring, FALSE
* otherwise
*/
public static boolean contains(String textToSearch, String substring) {
if (notNull(textToSearch) && textToSearch.contains(substring)) {
return true;
}
return false;
}

/**
* @return TRUE when given array has elements; that is, it must not be
* {@code null} and must have at least one element. FALSE otherwise
*/
public static boolean notEmpty(Object[] array) {
if (array == null || array.length == 0) {
return false;
}
for (Object element : array) {
if (element != null) {
return true;
}
}
return false;
}

/**
* @return TRUE when given collection has elements; that is, it must not be
* {@code null} and must have at least one element. @return FALSE otherwise
*/
public static boolean notEmpty(Collection<?> collection) {
if (notNull(collection) && !collection.isEmpty()) {
return true;
} else {
return false;
}
}


/**
* @return TRUE if given Map has entries; that is, it must not be {@code null}
* and must have at least one entry. Queue FALSE otherwise
*/
public static boolean notEmpty(Map<?, ?> map) {
if (map == null) {
return false;
}
if (hasElements(map.entrySet().toArray())) {
return true;
}
return false;
}

/**
* Assert that an array has no null elements. Note: Does not complain if the
* array is empty!
*
* <pre class="code">
* Assert.noNullElements(array, &quot;The array must have non-null elements&quot;);
* </pre>
*
* @param array the array
*/
/**
* @return TRUE when given array has no null elements; FALSE otherwise
*/
public static boolean notNull(Object[] array) {
if (array != null) {
for (Object element : array) {
if (element == null) {
return false;
}
}
}
return true;
}

/**
* TRUE when given array has at least one not null element; FALSE
* otherwise
*/
public static boolean hasElements(Object[] array) {
if (hasElements(array)) {
return true;
} else {
return false;
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ public void shouldNotProcessStepsForInvalidFeature(){
invalidFeature.setName("name");
invalidFeature.processSteps();
}

}
Loading

0 comments on commit 4105655

Please sign in to comment.