2.1.4 • Published 9 years ago

slimjs v2.1.4

Weekly downloads
12
License
ISC
Repository
github
Last release
9 years ago

SlimJS

An Async Node.js SliM server for FitNesse

To use slimjs on an existing FitNesse server:

npm install -g slimjs

On windows there might be an error when java is trying to execute SlimJS even though installed globally. Try to replace COMMAND_PATTERN with an absolute path.

!define COMMAND_PATTERN {node C:\Users\<MY_USER>\AppData\Roaming\npm\node_modules\slimjs\src\SlimJS %p}

Create a test page in FitNesse and add this to the top of the page, remember on windows to replace COMMAND_PATTERN with an absolute path if needed:

!define TEST_SYSTEM {slim}
!define COMMAND_PATTERN {SlimJS %p}
!path /Path/To/My/Fixtures

|import      |
|my-test-file|

|Hi            |
|echo |sayHi?  |
|Bob  |Hi! Bob |

/Path/To/My/Fixtures/my-test-file.js

function Hi(){
    this.setEcho = function(str){
        this.echo = str;
    }

    this.sayHi = function(){
        return "Hi! " + this.echo;
    }
}

module.exports.Hi = Hi;

If you want to do something asynchronous, return a thenable (promise):

|script  |child_process            |
|check   |exec  |node -v  |v5.4.0  |
var exec = require('child_process').exec;

function child_process() {
    this.exec = function (cmd) {

        return {
            then:function(fulfill,reject){
                exec(cmd, function (err, stdout, stderr) {
                    if(err)
                        return reject(err);

                    fulfill(stdout.trim());
                });
            }
        }
    }
}

module.exports.child_process=child_process;

Using namespaces:

|eg.Division                       |
|numerator |denominator |quotient? |
|10        |2           |$result=  |
|$result   |10          |0.5       |
|12.6      |3           |4.2       |
|100       |4           |25        |
var eg={
    Division:function(){
        var num;
        var denom;

        this.setNumerator = function(n){
            num = n;
        }
        this.setDenominator = function(n){
            denom=n;
        }
        this.quotient = function(){
            return num/denom;
        }
    }
};

module.exports.eg=eg;

Name conversion:

|should I buy milk                                              |
|cash in wallet|credit card|pints of milk remaining|go to store?|
|0             |no         |0                      |no          |
|10            |no         |0                      |yes         |
|0             |yes        |0                      |yes         |
|10            |yes        |0                      |yes         |
|0             |no         |1                      |no          |
|10            |no         |1                      |no          |
|0             |yes        |1                      |no          |
|10            |yes        |1                      |no          |
function ShouldIBuyMilk() {
    var _dollars;
    var _pints;
    var _creditCard;

    this.setCashInWallet = function(dollars) {
        _dollars = dollars;
    }

    this.setPintsOfMilkRemaining=function(pints) {
        _pints = pints;
    }

    this.setCreditCard = function(valid) {
        _creditCard = "yes"===valid;
    }

    this.goToStore = function() {
        var ret=(_pints == 0 && (_dollars > 2 || _creditCard)) ? "yes" : "no";
        return ret;
    }
}

module.exports.ShouldIBuyMilk=ShouldIBuyMilk;

Using JSON

|Json                         |
|json               |X and Y ?|
|{x:1,y:2}          |3        |
|{x:'Bar', y:' Baz'}|Bar Baz  |
function Json(){
    this.setJson = function(jsonObject){
        this.obj = jsonObject;
    }

    this.XAndY = function(){
        return this.obj.x + this.obj.y;
    }
}

module.exports.Json=Json;

--

For contributors

I'm working to pass the FitNesse Test Suite for Slim.

You can run these test locally here (after you startup): http://localhost:8080/FitNesse.SuiteAcceptanceTests.SuiteSlimTests

To start the environment:

npm install
cd fitnesse
java -jar fitnesse-standalone.jar -p 8080

http://localhost:8080

To start the UDP logger (for debugging)

node src/utils/LogUdpServer.js

Thanks to:

Tomasz @mrt123. The first user of slimjs and for the async exec example. Gregor Gramlich @ggramlich. For help with the SliM protocol, the PHP implementation and the promise proposal. Christian Gagneraud @chgans. QtSlim

Libraries: json5

2.1.4

9 years ago

2.1.3

9 years ago

2.1.2

9 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.1.10

9 years ago

1.1.9

9 years ago

1.1.8

9 years ago

1.1.7

9 years ago

1.1.6

9 years ago

1.1.5

9 years ago

1.1.4

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.14

10 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago