-1

New User, trying to follow the examples

http://developer.yahoo.com/cocktails/mojito/docs/code_exs/route_config.html

When I try to follow the example above, the mojit won't run. It gives this error:

FAILURE DETAILS:

RoutingMojit-tests :: RoutingMojit user tests :: test mojit TypeError: Cannot call method 'getRequest' of undefined at route_info (/nodejs/configure_routing/mojits/RoutingMojit/controller.server.js:7:24) at Object.Y.namespace.index (/nodejs/configure_routing/mojits/RoutingMojit/controller.server.js:35:15) at suite.add.YUITest.TestCase.test mojit (/nodejs/configure_routing/mojits/RoutingMojit/tests/controller.server-tests.js:48:24) at YUITest.TestRunner.YUITest.Util.mix._resumeTest (/usr/local/lib/node_modules/mojito-cli/node_modules/mojito-cli-test/node_modules/yuitest/lib/yuitest-node.js:3140:29) at YUITest.TestRunner.YUITest.Util.mix._runTest (/usr/local/lib/node_modules/mojito-cli/node_modules/mojito-cli-test/node_modules/yuitest/lib/yuitest-node.js:3348:26) at YUITest.TestRunner.YUITest.Util.mix._run (/usr/local/lib/node_modules/mojito-cli/node_modules/mojito-cli-test/node_modules/yuitest/lib/yuitest-node.js:3096:30) at null._onTimeout (/usr/local/lib/node_modules/mojito-cli/node_modules/mojito-cli-test/node_modules/yuitest/lib/yuitest-node.js:3090:52) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Total tests: 2 â Passed: 1 â Deferred: 0 â Failed: 1 50% pass rate

<root@NAS-01>://nodejs/configure_routing# mojito info mojito-cli v0.1.0 node v0.10.12/linux configure_routing v0.0.1, My Mojito application configure_routing dependencies: mojito mojito v0.7.0 (installed locally).

I see these notes about changes to the way ac.* works: https://github.com/yahoo/mojito/wiki/ReleaseNotes0_5_0

But, I am a bit lost as how to convert the example code.

YUI.add('RoutingMojit', function(Y, NAME) { // Builds object containing route information function route_info(ac) { var methods = "", name = "", action = ac.action, path = ac.http.getRequest().url .....

How should I use ac.http.getRequest().url ?

Appreciate any pointers. Thanks, Mark

by
3 Replies
  • @Mark, that's when you run mojito test app . right? If that's the case, it is probably an error in the tests. We will look at it.

    0
  • Yes, that is running mojito test app . And indeed just running mojito start in the app's root directory, the app seems to work fine. I just wanted to make sure I wasn't doing things wrong, but I guess it is just the unit testing bit that isn't working.

    Thanks for the quick response. Mark B

    0
  • Hi Mark,

    No, you're not doing anything wrong. The tests for the examples have to be modified to pass successfully. The tests that are generated when you create a mojit are just boilerplate code. You need to modify the tests for any changes to your mojit code. The examples do not cover writing tests.

    As for ac.http.getRequest().url, it just returns the path that is requested, which in the example is either/showor/index. You can useac.http.getRequest` to get a good deal information about the request, such as the context (ac.http.getRequest().context), HTTP headers (ac.http.getRequest().headers), the instance being executed (ac.http.getRequest().command.instance), etc.

    0

Recent Posts

in Yahoo! Mojito