Skip to content

Commit

Permalink
Merge branch 'master' of github.com:silversonicaxel/gherkin-detailer
Browse files Browse the repository at this point in the history
  • Loading branch information
silversonicaxel committed Feb 19, 2019
2 parents ec8e48a + 0451159 commit 8be6bd6
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 109 deletions.
8 changes: 4 additions & 4 deletions docs/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ language: node_js
node_js:
- 10.12
script:
- yarn run lint
- yarn run test
- yarn run test-coverage
- yarn lint
- yarn test
- yarn test-coverage
after_success:
- yarn run coveralls
- yarn coveralls
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.1.0 (2019)
## 1.1.0 (February 18, 2019)

### Documentation, Upgrade of libraries, Improvements

Expand Down
21 changes: 17 additions & 4 deletions docs/GLOSSARY.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@



<link rel="prev" href="./" />
<link rel="prev" href="EXAMPLE.html" />


</head>
Expand Down Expand Up @@ -100,7 +100,20 @@

</li>

<li class="chapter active" data-level="1.2" data-path="GLOSSARY.html">
<li class="chapter " data-level="1.2" data-path="EXAMPLE.html">

<a href="EXAMPLE.html">


Examples

</a>



</li>

<li class="chapter active" data-level="1.3" data-path="GLOSSARY.html">

<a href="GLOSSARY.html">

Expand Down Expand Up @@ -198,7 +211,7 @@ <h1 class="search-results-title">No results matching "<span class='search-query'



<a href="./" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Introduction">
<a href="EXAMPLE.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Examples">
<i class="fa fa-angle-left"></i>
</a>

Expand All @@ -210,7 +223,7 @@ <h1 class="search-results-title">No results matching "<span class='search-query'
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Glossary","level":"1.2","depth":1,"previous":{"title":"Introduction","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"GLOSSARY.md","mtime":"2019-02-18T18:52:52.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-02-18T19:04:03.267Z"},"basePath":".","book":{"language":""}});
gitbook.page.hasChanged({"page":{"title":"Glossary","level":"1.3","depth":1,"previous":{"title":"Examples","level":"1.2","depth":1,"path":"EXAMPLE.md","ref":"EXAMPLE.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"GLOSSARY.md","mtime":"2019-02-19T08:21:18.389Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-02-19T08:22:30.982Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
Expand Down
43 changes: 32 additions & 11 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">


<link rel="next" href="GLOSSARY.html" />
<link rel="next" href="EXAMPLE.html" />



Expand Down Expand Up @@ -100,7 +100,20 @@

</li>

<li class="chapter " data-level="1.2" data-path="GLOSSARY.html">
<li class="chapter " data-level="1.2" data-path="EXAMPLE.html">

<a href="EXAMPLE.html">


Examples

</a>



</li>

<li class="chapter " data-level="1.3" data-path="GLOSSARY.html">

<a href="GLOSSARY.html">

Expand Down Expand Up @@ -162,15 +175,20 @@ <h1>
<a href="https://coveralls.io/github/silversonicaxel/gherkin-detailer?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/silversonicaxel/gherkin-detailer/badge.svg?branch=master" alt="Coverage Status"></a></p>
<h1 id="gherkin-detailer">gherkin-detailer</h1>
<p><a href="GLOSSARY.html#gherkin" class="glossary-term" title="Gherkin is the language that Cucumber uses to define test cases.">gherkin</a>-detailer is a tool that checks the <a href="GLOSSARY.html#gherkin" class="glossary-term" title="Gherkin is the language that Cucumber uses to define test cases.">gherkin</a> files included in you project and list them, highlighting some of their details.</p>
<h2 id="documentation">Documentation</h2>
<ul>
<li><a href="SUMMARY.md">Summary</a></li>
<li><a href="https://silversonicaxel.gitbook.io/gherkin-detailer/" target="_blank">Gitbook</a></li>
</ul>
<h2 id="introduction">Introduction</h2>
<p><a href="GLOSSARY.html#gherkin" class="glossary-term" title="Gherkin is the language that Cucumber uses to define test cases.">gherkin</a>-detailer is a tool that generates HTML reports related to the gherkins that are part of the project you are working on. Currently there are six sections available:</p>
<ul>
<li>Files list</li>
<li>Features list</li>
<li>Scenarios list</li>
<li>States list</li>
<li>Actions list</li>
<li>Outcomes list</li>
<li>Files list (containing the entire list of all the detailed scenarios)</li>
<li>Features list (containing the simple list of all the features)</li>
<li>Scenarios list (containing the simple list of all the scenarios)</li>
<li>States list (containing the simple list of all the <strong>given</strong> - states)</li>
<li>Actions list (containing the simple list of all the <strong>when</strong> - actions)</li>
<li>Outcomes list (containing the simple list of all the <strong>then</strong> - outcomes)</li>
</ul>
<h2 id="requirements">Requirements</h2>
<ul>
Expand All @@ -196,6 +214,9 @@ <h2 id="usage">Usage</h2>
<p>To customize the analysis folder, set this up:</p>
<pre><code class="lang-bash"><span class="hljs-string">&quot;gherkin-detailer&quot;</span>: <span class="hljs-string">&quot;gherkin-detailer -a &apos;./src/&apos;&quot;</span>
</code></pre>
<p>To customize the output folder, set this up:</p>
<pre><code class="lang-bash"><span class="hljs-string">&quot;gherkin-detailer&quot;</span>: <span class="hljs-string">&quot;gherkin-detailer -o &apos;./report/&apos;&quot;</span>
</code></pre>
<p>Then the <code>gherkin-detailer</code> can be executed in order to have a gherkins report created in a default folder <code>./report/gherkin-detailer/</code></p>
<pre><code class="lang-bash">$ npm run gherkin-detailer

Expand All @@ -211,11 +232,11 @@ <h2 id="help">Help</h2>

-v, --version Output the version number
<span class="hljs-_">-a</span>, --analysis [analysis] Select folder to analyse
-o, --output [output] Select folder to output
-h, --help Output usage information
</code></pre>
<h2 id="future-improvements">Future improvements</h2>
<ul>
<li>Customize report folder</li>
<li>Customize report theme</li>
<li>Management of <a href="GLOSSARY.html#scenario" class="glossary-term" title="A scenario is a flow of events through the feature being described and maps one to one with an executable test case for the system.">Scenario</a> Outlines</li>
<li>Management of similarities in Gherkins</li>
Expand Down Expand Up @@ -248,7 +269,7 @@ <h1 class="search-results-title">No results matching "<span class='search-query'



<a href="GLOSSARY.html" class="navigation navigation-next navigation-unique" aria-label="Next page: Glossary">
<a href="EXAMPLE.html" class="navigation navigation-next navigation-unique" aria-label="Next page: Examples">
<i class="fa fa-angle-right"></i>
</a>

Expand All @@ -259,7 +280,7 @@ <h1 class="search-results-title">No results matching "<span class='search-query'
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"Glossary","level":"1.2","depth":1,"path":"GLOSSARY.md","ref":"GLOSSARY.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"README.md","mtime":"2019-02-18T18:55:25.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-02-18T19:04:03.267Z"},"basePath":".","book":{"language":""}});
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"Examples","level":"1.2","depth":1,"path":"EXAMPLE.md","ref":"EXAMPLE.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"README.md","mtime":"2019-02-19T08:21:18.389Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-02-19T08:22:30.982Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gherkin-detailer",
"version": "1.0.7",
"version": "1.1.0",
"description": "gherkin-detailer is a tool that check the gherkins included in you project and list them",
"license": "MIT",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion docs/search_index.json

Large diffs are not rendered by default.

54 changes: 49 additions & 5 deletions docs/src/class/configurer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Configurer } from './configurer';
import { Configurer, ConfigurerData } from './configurer';
import { spy, assert, createSandbox } from 'sinon';
import * as program from 'commander';
import { expect } from 'chai';
Expand Down Expand Up @@ -37,14 +37,58 @@ describe('#Configurer', () => {

describe('#fetchData', () => {
it('should return configurer default data', () => {
const expectedConfigurerData = <ConfigurerData>{
analysisFolder: '',
outputFolder: ''
};
program['analysis'] = '';
program['output'] = '';

const data = configurer.fetchData();

expect(data).to.deep.equal(expectedConfigurerData);
});

it('should return customized analysis folder', () => {
const analysisFolder = 'directory';
const expectedConfigurerData = <ConfigurerData>{
analysisFolder: analysisFolder,
outputFolder: ''
};
program['analysis'] = analysisFolder;
program['output'] = '';

const data = configurer.fetchData();

expect(data).to.deep.equal(expectedConfigurerData);
});

it('should return customized output folder', () => {
const outputFolder = 'html/report/features';
const expectedConfigurerData = <ConfigurerData>{
analysisFolder: '',
outputFolder: outputFolder
};
program['analysis'] = '';
program['output'] = outputFolder;

const data = configurer.fetchData();
expect(data).to.deep.equal({ analysisFolder: '' });

expect(data).to.deep.equal(expectedConfigurerData);
});

it('should return particular data', () => {
program['analysis'] = '/directory';
it('should return customized output folder removing the absolute root', () => {
const outputFolder = '/';
const expectedConfigurerData = <ConfigurerData>{
analysisFolder: '',
outputFolder: ''
};
program['analysis'] = '';
program['output'] = outputFolder;

const data = configurer.fetchData();
expect(data).to.deep.equal({ analysisFolder: '/directory' });

expect(data).to.deep.equal(expectedConfigurerData);
});
});
});
17 changes: 13 additions & 4 deletions docs/src/class/configurer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as program from 'commander';

type ConfigurerData = {
analysisFolder: string;
export type ConfigurerData = {
analysisFolder?: string;
outputFolder?: string;
};

export class Configurer {
Expand All @@ -10,18 +11,26 @@ export class Configurer {
}

private setupOptions(): void {
const version = '1.0.7';
const version = '1.1.0';

program
.version(version, '-v, --version')
.allowUnknownOption()
.option('-a, --analysis [analysis]', 'Select folder to analyse')
.option('-o, --output [output]', 'Select folder to output')
.parse(process.argv);
}

fetchData(): ConfigurerData {
const analysis = program.analysis || '';
let output = program.output || '';
if (output === '/') {
output = '';
}

return {
analysisFolder: program.analysis || ''
analysisFolder: analysis,
outputFolder: output
};
}
}
55 changes: 48 additions & 7 deletions docs/src/class/reporter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as sinonChai from 'sinon-chai';
import { Reporter } from './reporter';
import { Analyzer } from './analyzer';
import { Reader } from './reader';
import { ConfigurerData } from './configurer';
import * as fs from 'fs';
import * as del from 'del';
import * as Mustache from 'mustache';
Expand Down Expand Up @@ -41,23 +42,63 @@ describe('#Reporter', () => {
});

describe('#createGherkinsReport', () => {
it('should initialize the report folder with default one', () => {
reporter.createGherkinsReport();
beforeEach(() => {
sandboxSet.stub(del, 'sync');
sandboxSet.stub(fs, 'mkdirSync');
sandboxSet.stub(fs, 'copyFileSync');
sandboxSet.stub(reporter, 'reportFeaturesFiles');
});

it('should initialize the analysis folder with default one', () => {
const config = <ConfigurerData>{ analysisFolder: '', outputFolder: '' };
reporter.createGherkinsReport(config);

expect(reporter['folderToReadReport']).to.equal(`${process.cwd()}/`);
});

it('should initialize the report folder with provided one', () => {
const reportFolder = './fixtures';
reporter.createGherkinsReport(reportFolder);
it('should initialize the analysis folder with provided one', () => {
const config = <ConfigurerData>{ analysisFolder: './fixtures', outputFolder: '' };
reporter.createGherkinsReport(config);

expect(reporter['folderToReadReport']).to.equal(config.analysisFolder);
});

it('should initialize the output folder with default one', () => {
sandboxSet.stub(reporter, 'setupReportFolder');
sandboxSet.stub(reporter['reader'], 'readFeatureFilesFromFolder');

const config = <ConfigurerData>{ };
reporter.createGherkinsReport(config);

expect(reporter['folderToWriteReport']).to.equal(`${process.cwd()}/report/gherkin-detailer/`);
});

it('should initialize the output folder with provided one', () => {
sandboxSet.stub(reporter, 'setupReportFolder');
sandboxSet.stub(reporter['reader'], 'readFeatureFilesFromFolder');

const config = <ConfigurerData>{ analysisFolder: '', outputFolder: 'doc/to/report/' };
reporter.createGherkinsReport(config);

expect(reporter['folderToWriteReport']).to.equal(config.outputFolder);
});

it('should initialize the output folder with provided one ending with a slash', () => {
sandboxSet.stub(reporter, 'setupReportFolder');
sandboxSet.stub(reporter['reader'], 'readFeatureFilesFromFolder');

const config = <ConfigurerData>{ analysisFolder: '', outputFolder: 'doc/to/report' };
reporter.createGherkinsReport(config);

expect(reporter['folderToReadReport']).to.equal(reportFolder);
expect(reporter['folderToWriteReport']).to.equal(`${config.outputFolder}/`);
});

it('should read features files from folder', () => {
const config = <ConfigurerData>{ analysisFolder: '', outputFolder: '' };
sandboxSet.stub(reporter, 'setupReportFolder');
const readFeatureFilesFromFolderStub = sandboxSet.stub(reporter['reader'], 'readFeatureFilesFromFolder');

reporter.createGherkinsReport();
reporter.createGherkinsReport(config);

expect(reporter['reader']).to.respondTo('readFeatureFilesFromFolder');
assert.calledOnce(readFeatureFilesFromFolderStub);
Expand Down
9 changes: 7 additions & 2 deletions docs/src/class/reporter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Reader } from './reader';
import { Analyzer } from './analyzer';
import { ConfigurerData } from './configurer';
import * as Mustache from 'mustache';
import * as fs from 'fs';
import * as del from 'del';
Expand Down Expand Up @@ -46,8 +47,12 @@ export class Reporter {
this.reportFeaturesFiles = this.reportFeaturesFiles.bind(this);
}

createGherkinsReport(folderToDetail?: string): void {
this.folderToReadReport = folderToDetail || this.folderToReadReport;
createGherkinsReport(config: ConfigurerData): void {
this.folderToReadReport = config.analysisFolder || this.folderToReadReport;
this.folderToWriteReport = config.outputFolder || this.folderToWriteReport;
if (this.folderToWriteReport.substr(-1) !== '/') {
this.folderToWriteReport += '/';
}

this.setupReportFolder();
this.reader.readFeatureFilesFromFolder(this.folderToReadReport, this.reportFeaturesFiles);
Expand Down
Loading

0 comments on commit 8be6bd6

Please sign in to comment.