Skip to content

Commit

Permalink
spellbook
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Ronvel committed Sep 15, 2014
1 parent 74baced commit 975c7f2
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 32 deletions.
49 changes: 34 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ This Scroll is still a work in progress (specs, etc...)
Full BDD spec generated by Mocha:


bob blihblih one
0\.1\.2
BOB
fuuu
echo
delayed-echo
bob blihblih one
ls default line: one
ls line: one
ls line: three
Expand All @@ -38,15 +41,15 @@ onE
two
thrEE
# TOC
- [Formula](#formula)
- [Formula & variable substitution](#formula--variable-substitution)
- ['scroll' block](#scroll-block)
- ['summon' block and dependencies](#summon-block-and-dependencies)
- ['foreach' block](#foreach-block)
- ['transmute' block](#transmute-block)
<a name=""></a>

<a name="formula"></a>
# Formula
<a name="formula--variable-substitution"></a>
# Formula & variable substitution
should be parsed into list of string, with an additionnal property 'index' equals to 0.

```js
Expand All @@ -56,51 +59,67 @@ expect( book.formula.alert ).to.be.eql( [ 'bob' ] ) ;
expect( book.formula.list ).to.be.eql( [ 'one' , 'two' , 'three' ] ) ;
```

<a name="scroll-block"></a>
# 'scroll' block
should echoing echo.
should substitute variable (aka formula) accordingly in 'scroll' block.

```js
cleanup( function() {

var book = new spellcast.Book( fs.readFileSync( 'spellbook' ).toString() ) ;

book.cast( 'echo' , function( error )
book.cast( 'kawarimi' , function( error )
{
expect( error ).not.ok() ;
expect( getCastedLog( 'echo' ) ).to.be( 'echo\n' ) ;
expect( getCastedLog( 'kawarimi' ) ).to.be( 'bob blihblih one\n' ) ;
done() ;
} ) ;
} ) ;
```

should echoing delayed-echo after one second.
should substitute variable (aka formula) using filters.

```js
cleanup( function() {

var book = new spellcast.Book( fs.readFileSync( 'spellbook' ).toString() ) ;

book.cast( 'delayed-echo' , function( error )
book.cast( 'kawarimi-filter' , function( error )
{
expect( error ).not.ok() ;
expect( getCastedLog( 'delayed-echo' ) ).to.be( 'delayed-echo\n' ) ;
expect( getCastedLog( 'kawarimi-filter' ) ).to.be( '0\\.1\\.2\nBOB\nfuuu\n' ) ;
done() ;
} ) ;
} ) ;
```

should substitute variable (aka formula) accordingly in 'scroll' block.
<a name="scroll-block"></a>
# 'scroll' block
should echoing echo.

```js
cleanup( function() {

var book = new spellcast.Book( fs.readFileSync( 'spellbook' ).toString() ) ;

book.cast( 'kawarimi' , function( error )
book.cast( 'echo' , function( error )
{
expect( error ).not.ok() ;
expect( getCastedLog( 'kawarimi' ) ).to.be( 'bob blihblih one\n' ) ;
expect( getCastedLog( 'echo' ) ).to.be( 'echo\n' ) ;
done() ;
} ) ;
} ) ;
```

should echoing delayed-echo after one second.

```js
cleanup( function() {

var book = new spellcast.Book( fs.readFileSync( 'spellbook' ).toString() ) ;

book.cast( 'delayed-echo' , function( error )
{
expect( error ).not.ok() ;
expect( getCastedLog( 'delayed-echo' ) ).to.be( 'delayed-echo\n' ) ;
done() ;
} ) ;
} ) ;
Expand Down
49 changes: 34 additions & 15 deletions bdd-spec.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
bob blihblih one
0\.1\.2
BOB
fuuu
echo
delayed-echo
bob blihblih one
ls default line: one
ls line: one
ls line: three
Expand All @@ -20,15 +23,15 @@ onE
two
thrEE
# TOC
- [Formula](#formula)
- [Formula & variable substitution](#formula--variable-substitution)
- ['scroll' block](#scroll-block)
- ['summon' block and dependencies](#summon-block-and-dependencies)
- ['foreach' block](#foreach-block)
- ['transmute' block](#transmute-block)
<a name=""></a>

<a name="formula"></a>
# Formula
<a name="formula--variable-substitution"></a>
# Formula & variable substitution
should be parsed into list of string, with an additionnal property 'index' equals to 0.

```js
Expand All @@ -38,51 +41,67 @@ expect( book.formula.alert ).to.be.eql( [ 'bob' ] ) ;
expect( book.formula.list ).to.be.eql( [ 'one' , 'two' , 'three' ] ) ;
```

<a name="scroll-block"></a>
# 'scroll' block
should echoing echo.
should substitute variable (aka formula) accordingly in 'scroll' block.

```js
cleanup( function() {

var book = new spellcast.Book( fs.readFileSync( 'spellbook' ).toString() ) ;

book.cast( 'echo' , function( error )
book.cast( 'kawarimi' , function( error )
{
expect( error ).not.ok() ;
expect( getCastedLog( 'echo' ) ).to.be( 'echo\n' ) ;
expect( getCastedLog( 'kawarimi' ) ).to.be( 'bob blihblih one\n' ) ;
done() ;
} ) ;
} ) ;
```

should echoing delayed-echo after one second.
should substitute variable (aka formula) using filters.

```js
cleanup( function() {

var book = new spellcast.Book( fs.readFileSync( 'spellbook' ).toString() ) ;

book.cast( 'delayed-echo' , function( error )
book.cast( 'kawarimi-filter' , function( error )
{
expect( error ).not.ok() ;
expect( getCastedLog( 'delayed-echo' ) ).to.be( 'delayed-echo\n' ) ;
expect( getCastedLog( 'kawarimi-filter' ) ).to.be( '0\\.1\\.2\nBOB\nfuuu\n' ) ;
done() ;
} ) ;
} ) ;
```

should substitute variable (aka formula) accordingly in 'scroll' block.
<a name="scroll-block"></a>
# 'scroll' block
should echoing echo.

```js
cleanup( function() {

var book = new spellcast.Book( fs.readFileSync( 'spellbook' ).toString() ) ;

book.cast( 'kawarimi' , function( error )
book.cast( 'echo' , function( error )
{
expect( error ).not.ok() ;
expect( getCastedLog( 'kawarimi' ) ).to.be( 'bob blihblih one\n' ) ;
expect( getCastedLog( 'echo' ) ).to.be( 'echo\n' ) ;
done() ;
} ) ;
} ) ;
```

should echoing delayed-echo after one second.

```js
cleanup( function() {

var book = new spellcast.Book( fs.readFileSync( 'spellbook' ).toString() ) ;

book.cast( 'delayed-echo' , function( error )
{
expect( error ).not.ok() ;
expect( getCastedLog( 'delayed-echo' ) ).to.be( 'delayed-echo\n' ) ;
done() ;
} ) ;
} ) ;
Expand Down
4 changes: 2 additions & 2 deletions spellbook
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ formula
test/spellcast-test.js

cast
dev-summon
npm-dev-install

scroll
${mocha} test/spellcast-test.js -R spec
Expand All @@ -61,7 +61,7 @@ formula
test/spellcast-test.js

cast
dev-summon
npm-dev-install

scroll
${jshint} lib/spellcast.js test/spellcast-test.js
Expand Down

0 comments on commit 975c7f2

Please sign in to comment.