Skip to content

Commit

Permalink
Added specification describing behaviour when a custom root index is …
Browse files Browse the repository at this point in the history
…provided
  • Loading branch information
Ben Buckley committed Dec 21, 2011
1 parent 756de8a commit b4775f7
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,56 @@
package spec.uk.co.codemonkey.concordion.specLinker;

import static spec.uk.co.codemonkey.concordion.specLinker.SpecTestHelper.createSpec;
import static spec.uk.co.codemonkey.concordion.specLinker.SpecTestHelper.createSpecDirectory;
import static spec.uk.co.codemonkey.concordion.specLinker.SpecTestHelper.exampleSpec;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;
import org.concordion.integration.junit4.ConcordionRunner;
import org.junit.runner.RunWith;

import uk.co.codemonkey.concordion.specLinker.SpecLinker;

@RunWith(ConcordionRunner.class)
public class DefaultIndexTest {

private String fileString;

public void runLinker(String rootIndex) throws Exception {
File dir = createSpecDirectory("example");
exampleSpec(dir, rootIndex, "customRootIndex");
createSpec(dir, "tests/parent.html");
createSpec(dir, "tests/child.html");

String testDir = dir.getCanonicalPath();
new SpecLinker().link(testDir, testDir);

fileString = fileAsString(new File(dir, rootIndex));

}

public boolean isSameIndexFile() throws IOException {
return fileString.contains("customRootIndex");
}

public boolean containsChildLinks() {
return fileString.contains("tests/parent.html");
}


private String fileAsString(File file) throws IOException {
InputStream in = new FileInputStream(file);
try {
return IOUtils.toString(in);
}
finally {
if(in != null) { in.close(); }
}

}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package spec.uk.co.codemonkey.concordion.specLinker;

import static spec.uk.co.codemonkey.concordion.specLinker.SpecTestHelper.createSpec;
import static spec.uk.co.codemonkey.concordion.specLinker.SpecTestHelper.exampleSpec;
import static spec.uk.co.codemonkey.concordion.specLinker.SpecTestHelper.createSpecDirectory;
import static spec.uk.co.codemonkey.concordion.specLinker.SpecTestHelper.docContainsLink;
import static spec.uk.co.codemonkey.concordion.specLinker.SpecTestHelper.withText;
Expand All @@ -23,7 +23,7 @@ public class LinkNamesTest {
@Before
public void createExampleDirectory() throws Exception {
dir = createSpecDirectory("linkNames");
createSpec(dir, INDEX, "index");
exampleSpec(dir, INDEX, "index");
}

public void runLinker() throws Exception {
Expand All @@ -32,7 +32,7 @@ public void runLinker() throws Exception {
}

public void addChild(String name, String title) throws IOException {
createSpec(dir, name, title);
exampleSpec(dir, name, title);
}

public void addChild(String name) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
public class SpecTestHelper {

public static void createSpec(File parent, String child) throws IOException {
createSpec(parent, child, null);
exampleSpec(parent, child, null);
}

public static void createSpec(File parent, String child, String title) throws IOException {
File file = new File(parent, child);
public static void exampleSpec(File parent, String name, String title) throws IOException {
File file = new File(parent, name);
if(!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@
<h1>How do I customise the root index page?</h1>
<p>
<code>SpecLinker</code> will automatically create a root index
page for the top level specifications. To use a different file
as the index page, ensure exists at the root of the <code>SpecLinker</code>
classpath as <code>specLinkerDefaultIndex.html</code>. <i>Note: this is
set to become more user friendly in the next release.</i>
page for the top level specifications. To provide a custom index
page simply ensure <code>index.html</code> exists at the root of
the concordion output directory.
</p>

<!--
<div class="example">
<p>Given a directory <code c:set="#dir">example</code>
with files <code c:set="#index">Example.html</code>
and <code c:set="#child">child/childDetails.html</code></p>
<p>When I run the <code c:execute="runLinker(#dir, #index, #child)">SpecLinker</code></p>
<p>Then <code>Example.html</code> will contain a link to <code c:assertTrue="fileHasLinkTo(#index, #TEXT)">child/childDetails.html</code></p>
<p>Given a custom <code c:set="#index">index.html</code>
already exists in the concordion output directory</p>
<p>When I run the <code c:execute="runLinker(#index)">SpecLinker</code></p>
<p>Then <span c:assertTrue="isSameIndexFile()">the given file</span> will
<span c:assertTrue="containsChildLinks()">contain child links</span></p>
</div>
-->

</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ <h1>Linking specifications together</h1>
naturally arises, how do I navigate them? Concordion provides
breadcrumbs which help navigate back up a tree, but relies
on manual links to provide further details. <code>SpecLinker</code>
expands on breadcrumb format to automatically populate index
pages with links to their children, and highlight these links based
expands on breadcrumb format automatically populating index
pages with links to their children, and highlighting these links based
on the test results.
</p>

Expand Down

0 comments on commit b4775f7

Please sign in to comment.