Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mklabs committed Apr 21, 2012
1 parent 4e6fbcd commit 3250fee
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions readme.md
Expand Up @@ -16,14 +16,15 @@ destination.
```js
var Parser = require('mocha-gherkin');
fs.createReadStream('local.feature').pipe(new Parser).pipe(process.stdout);
```
r``

## Api

# TOC
- [API](#api)
- [As a user of mocha-gherkin I want to be able to use a streaming api So that I can pipe anything to it and pipe the result to any destination](#api-as-a-user-of-mocha-gherkin-i-want-to-be-able-to-use-a-streaming-api-so-that-i-can-pipe-anything-to-it-and-pipe-the-result-to-any-destination)
- [Reading a file](#api-as-a-user-of-mocha-gherkin-i-want-to-be-able-to-use-a-streaming-api-so-that-i-can-pipe-anything-to-it-and-pipe-the-result-to-any-destination-reading-a-file)
- [Requesting a file](#api-as-a-user-of-mocha-gherkin-i-want-to-be-able-to-use-a-streaming-api-so-that-i-can-pipe-anything-to-it-and-pipe-the-result-to-any-destination-requesting-a-file)
<a name="" />

<a name="api" />
Expand Down Expand Up @@ -60,12 +61,38 @@ this.parser = this.file.pipe(new Parser)
this.file.resume();
```

Then I should see the content of 'test/fixtures/basics.js'.
<a name="api-as-a-user-of-mocha-gherkin-i-want-to-be-able-to-use-a-streaming-api-so-that-i-can-pipe-anything-to-it-and-pipe-the-result-to-any-destination-requesting-a-file" />
### Requesting a file
Given I fetch some remote feature using request.

```js
```

When I request 'https://raw.github.com/mojombo/jekyll/master/features/markdown.feature'.

```js
this.file = request('https://raw.github.com/mojombo/jekyll/master/features/markdown.feature');
done();
```

And I pipe it through a 'new Parser'.

```js
var self = this;
this.output = '';
this.parser = this.file.pipe(new Parser)
.on('data', function(c) { self.output += c })
.on('close', done);
this.file.resume();
```

Then I should see the content of 'test/fixtures/remote.js'.

```js
process.chdir(this.base);
var output = this.output;
fs.readFile('test/fixtures/basics.js', 'utf8', function(err, body) {
fs.readFile('test/fixtures/remote.js', 'utf8', function(err, body) {
if(err) return done(err);
assert.equal(body.trim(), output.trim());
done();
Expand Down

0 comments on commit 3250fee

Please sign in to comment.