Permalink
Browse files

I found a nicer way to express the DSL

  • Loading branch information...
1 parent 269c19c commit b66b8f85102fcd644c19fee45b9334a4a0085c6d Alex Young committed Oct 21, 2009
Showing with 11 additions and 6 deletions.
  1. +11 −6 riot.js
View
17 riot.js
@@ -49,12 +49,17 @@ var Riot = {
withDSL: function(fn, context) {
var body = this.functionBody(fn);
body = "(function(context, given, asserts, should, setup, teardown) { " + body + " })";
- return function() { eval(body)(Riot.context,
- Riot.given,
- function() { return context.asserts.apply(context, arguments); },
- function() { return context.should.apply(context, arguments); },
- function() { return context.setup.apply(context, arguments); },
- function() { return context.teardown.apply(context, arguments); }) };
+ return function() {
+ var args = [
+ Riot.context,
+ Riot.given,
+ function() { return context.asserts.apply(context, arguments); },
+ function() { return context.should.apply(context, arguments); },
+ function() { return context.setup.apply(context, arguments); },
+ function() { return context.teardown.apply(context, arguments); }
+ ];
+ eval(body).apply(Riot, args);
+ };
},
context: function(title, callback) {

0 comments on commit b66b8f8

Please sign in to comment.