Live data from Hacker News

Javascript + DOM in your ruby, the simple way

github.com

1–10 of 18 posts

Re: Javascript + DOM in your ruby, the simple way

#7
So, which browser's quirks does this emulate? And what version of HTML does it support? (seriously. and what user agent does it report? developing cross-browser code is often important)

I can see how this could be extremely useful, but it does strike me as yet another source for unique bugs in your JS-manipulating-DOM code, and it's potentially even harder to find out why they're happening.

Re: Javascript + DOM in your ruby, the simple way

#8
post #7

So, which browser's quirks does this emulate? And what version of HTML does it support? (seriously. and what user agent does it report? developing cross-browser code is often important) I can see how this could be extremely useful, but it does strike me as yet another source for unique bugs in your JS-manipulating-DOM code, and it's potentially even harder to find out why they're happening.

I think it simulates a perfect browser. But that's fine. I see unit testing as the main use case for this library. If you want to test browser compatibility, then just simulate their quirks by mocking and stubbing the relevant APIs.

Re: Javascript + DOM in your ruby, the simple way

#9
post #2

This means I can test all the Javascript that my rails applications use without opening a browser!

You can run cucumber + selenium. I'm pretty sure selenium can run in headless mode (haven't turned it on yet, too fun to watch!)

This is useful for tightening the feedback loop. Using something like Autotest gives me near-instant feedback on changes I'm making to client-side libraries.

I'll continue to periodically run my tests inside a "real" browser, but I think this sort of headless testing is a real win.

[Disclaimer: I wrote Johnson, so I'm not exactly a disinterested bystander. Edited for repetition.]

Re: Javascript + DOM in your ruby, the simple way

#10
post #7

So, which browser's quirks does this emulate? And what version of HTML does it support? (seriously. and what user agent does it report? developing cross-browser code is often important) I can see how this could be extremely useful, but it does strike me as yet another source for unique bugs in your JS-manipulating-DOM code, and it's potentially even harder to find out why they're happening.

If you use a client-side js framework like JQuery or Prototype, the cross browser compatibility isn't an issue since it's taken care of for you.

The user agent it reports as is irrelevant - it's not a full http client. You can use other ruby tools to fetch a page if you want, and then feed harmony the document.

As others pointed out, testing is probably the main use case, but it offers other obvious possibilities; for instance, talkerapp.com needed a way to easily validate js syntax for their plugins.

Post reply on HN