Thursday, June 3, 2010

Joy for Cucumber on V8

‹prev | My Chain | next›

Last night I enjoyed little luck getting running on the v8 javascript engine. First up tonight, I am going to try a fresh install of all dependent gems. Thanks to rvm, this is trivial:
cstrom@whitefall:~/repos$ rvm gemset create 'javascript'
cstrom@whitefall:~/repos$ echo 'rvm 1.8.7@javascript' > cucumber/.rvmrc
cstrom@whitefall:~/repos$ cd cucumber
cstrom@whitefall:~/repos/cucumber$ gem install gherkin cucumber therubyracer
Now, I have only what I need:
cstrom@whitefall:~/repos/cucumber$ gem list

*** LOCAL GEMS ***

builder (2.1.2)
cucumber (0.7.3)
diff-lcs (1.1.2)
gherkin (1.0.30)
json_pure (1.4.3)
rake (0.8.7)
term-ansicolor (1.0.5)
therubyracer (0.7.1)
trollop (1.16.2)
While I'm at it, I pull new changes to cucumber. I still have the patch mostly lifted from Charles Lowell in place.

Now, when I run the javascript examples... everything passes:
cstrom@whitefall:~/repos/cucumber/examples/javascript$ rake cucumber
(in /home/cstrom/repos/cucumber/examples/javascript)
/home/cstrom/.rvm/rubies/ruby-1.8.7-p249/bin/ruby -I "/home/cstrom/repos/cuke.real/lib:lib" "/home/cstrom/repos/cucumber/bin/cucumber"
Feature: Fibonacci
In order to calculate super fast fibonacci series
As a Javascriptist
I want to use Javascript for that

Scenario Outline: Series # features/fibonacci.feature:6
When I ask Javascript to calculate fibonacci up to #
Then it should give me #

| n | series |
| 1 | [] |
| 2 | [1, 1] |
| 3 | [1, 1, 2] |
| 4 | [1, 1, 2, 3] |
Scenario: Single series with Before hook with a tag label # features/fibonacci.feature:41
Then it should give me [1, 1, 2] #

Scenario: Single series by calling a step from within a step # features/fibonacci.feature:45
Then it should give me [1, 1] via calling another step definition #

12 scenarios (12 passed)
21 steps (21 passed)
So what the hell? I spent a long time trying to get this working last night, so I cannot let that pass without trying to understand. Sadly, I cannot get this to fail again, even after trying:
  • reverting yesterday's cucumber patch
  • reverting to therubyracer version 0.7.0
  • even switching back to my "global" rvm gemset

Eventually, I do track this down. It turns out the patch that am using now is not quite the same as the one I used last night. Last night, I had used the following line directly from the patch in Charles Lowell's cucumber fork:, *js_args)
Earlier today I manually patched the Cucumber source by searching and replacing ToString with to_s. That left the above line in this state:
I am not sure what semantics (Ruby's or Javascript's) the call and eval statements are using in there. At this point, I am just happy to have it working. It would have been nicer if I realized it was working when I first made my "dumb" patch, but c'est la vie.

My complete patch, for what it's worth.

Day #123

No comments:

Post a Comment