Skip to content

Commit

Permalink
run specs with buster instead of the dead project 'jasmine-runner'
Browse files Browse the repository at this point in the history
  • Loading branch information
flosse committed Aug 28, 2012
1 parent 2b1ab53 commit c8223b7
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 51 deletions.
13 changes: 9 additions & 4 deletions rpc/README.md
Expand Up @@ -98,11 +98,16 @@ connection.rpc.addJidToWhiteList("*@*");


## Tests & specs ## Tests & specs


I use the node module `jasmine-runner` for the tests. Install it and use it as follow : I use the node module `buster` for the tests. Install it and use it as follow :


```bash ```bash
$ npm install jasmine-runner $ npm install buster
$ jasmine mon $ buster server
``` ```


The tests run in the browser at the address `localhost:8124`. Open a browser and navigate to `http://localhost:1111` and capture the browser.
Then you can run the tests:

```
$ buster test --browser
```
11 changes: 11 additions & 0 deletions rpc/buster.js
@@ -0,0 +1,11 @@
var config = module.exports;

config["rpc"] = {
environment: "browser",
specs: ["spec/*.spec.js"],
sources: ["strophe.rpc.js"],
libs: [
"lib/strophe.js",
"spec/strophe.rpc.spec.helper.js"
]
};
10 changes: 0 additions & 10 deletions rpc/jasmine.json

This file was deleted.

67 changes: 33 additions & 34 deletions rpc/spec/strophe.rpc.spec.helper.js
@@ -1,39 +1,38 @@
var helper = (function() { var helper = (function() {
function receive(c,req) { function receive(c,req) {
c._dataRecv(createRequest(req)); c._dataRecv(createRequest(req));
} }


function spyon (obj, method, cb) { function spyon (obj, method, cb) {
spyOn(obj,method).andCallFake(function(res) { sinon.stub(obj,method, function(res) {
res = res; cb.call(this,res);
cb.call(this,res); });
}); }
}


function mockConnection() { function mockConnection() {
var c = new Strophe.Connection(); var c = new Strophe.Connection();
c.authenticated = true; c.authenticated = true;
c.jid = 'n@d/r2'; c.jid = 'n@d/r2';
c._processRequest = function() {}; c._processRequest = function() {};
c._changeConnectStatus(Strophe.Status.CONNECTED); c._changeConnectStatus(Strophe.Status.CONNECTED);
return c; return c;
} }


function createRequest(iq) { function createRequest(iq) {
iq = typeof iq.tree == "function" ? iq.tree() : iq; iq = typeof iq.tree == "function" ? iq.tree() : iq;
var req = new Strophe.Request(iq, function() {}); var req = new Strophe.Request(iq, function() {});
req.getResponse = function() { req.getResponse = function() {
var env = new Strophe.Builder('env', {type: 'mock'}).tree(); var env = new Strophe.Builder('env', {type: 'mock'}).tree();
env.appendChild(iq); env.appendChild(iq);
return env; return env;
}; };
return req; return req;
} }


return { return {
createRequest: createRequest, createRequest: createRequest,
mockConnection: mockConnection, mockConnection: mockConnection,
receive: receive, receive: receive,
spyon: spyon spyon: spyon
}; };
})(); })();
8 changes: 5 additions & 3 deletions rpc/spec/strophe.rpc.spec.js
@@ -1,3 +1,5 @@
buster.spec.expose()

var mockConnection = helper.mockConnection, var mockConnection = helper.mockConnection,
spyon = helper.spyon, receive = helper.receive; spyon = helper.spyon, receive = helper.receive;


Expand Down Expand Up @@ -161,7 +163,7 @@ describe("Strophe Jabber-RPC plugin", function() {
var handler; var handler;


beforeEach(function() { beforeEach(function() {
handler = jasmine.createSpy(); handler = sinon.spy();
}); });


it("should be possible to add a request handler", function() { it("should be possible to add a request handler", function() {
Expand Down Expand Up @@ -246,7 +248,7 @@ describe("Strophe Jabber-RPC plugin", function() {
}); });


it("should NOT send forbidden access to the right nodes", function() { it("should NOT send forbidden access to the right nodes", function() {
spyOn(connection, "send"); spyon(connection, "send");
var iq = $iq({type: "set", id: "123", from: "foo@jabber.org", to: connection.jid}) var iq = $iq({type: "set", id: "123", from: "foo@jabber.org", to: connection.jid})
.c("query", {xmlns: Strophe.NS.RPC}); .c("query", {xmlns: Strophe.NS.RPC});
receive(connection, iq); receive(connection, iq);
Expand All @@ -257,4 +259,4 @@ describe("Strophe Jabber-RPC plugin", function() {


}); });


}); });

0 comments on commit c8223b7

Please sign in to comment.