YUI 3 does have mocking as part of their test framework http://developer.yahoo.com/yui/3/test/
I'm looking forward to the work John Resig is doing on server side javascript testing (qunit just got externalized from what I hear). Mark On Sat, Oct 3, 2009 at 10:02 PM, Korny Sietsma <[email protected]> wrote: > > How is YUI these days for unit testing? I know when we looked at it a > year ago, there were testing and mocking libraries "in the next > release" - but it really wasn't clear to me whether they would let you > do something approaching TDD, or if they were more oriented towards > integration-style testing. > > This has always been a problem I've had with non-trivial javascript > development - it's hard to do isolate a single element of > functionality and test it in isolation; everything seems to end up > tightly coupled to the DOM and to browser-specific functionality. You > end up integration testing everything, whether it's via a real browser > (i.e. Selenium or Watir) or via a fake browser (Celerity and the like) > - either way you get fragile ugly tests, nowhere near as nice as the > tests you can do on the server-side code. > > - Korny > > On Sat, Oct 3, 2009 at 8:13 PM, Mark Mansour <[email protected]> wrote: >> >> There are two questions here what is YUI like to use and how does it >> integrate with Rails. >> >> As for integration, I don't use RJS. I write all my JavaScript by >> hand and aim to write modularized components. That way I can just >> write something like this in my view: >> >> <% content_for :page_javascript do %> >> <script type="text/javascript"> >> initTable(<%= @json_friendly_stories.to_json -%>, '<%= >> form_authenticity_token -%>'); >> </script> >> <% end %> >> >> So as far as the integration goes, I don't leverage anything in rails >> to write my JavaScript and I like it that way. So yes, Rails and YUI >> work great together :P. I've recently made the effort to start >> learning JavaScript rather than just hacking it, and it has made the >> world of difference. >> >> Now for the YUI stuff. My disclaimer is that I'm still on YUI 2 and >> haven't transitioned over to YUI 3 yet so double check on what I'm >> saying. >> >> The YUI 2 DOM API is a bit clunky and it is what I'm using at the >> moment. To get access to a Dom element by id you need to say >> div = YAHOO.util.Dom.getId("container"); >> >> This was a deliberate design decision as to not pollute the global >> namespace. What some people do is add a single line at the beginning >> of the YUI code that makes it more terse >> $ = YAHOO.util.Dom.get >> div = $("container"); >> $$ = YAHOO.util.Selector.query >> cssSelectorExample = $$("div p"); >> >> In YUI 3 they've cleaned up the API so instead of having a global >> singleton (YAHOO.util.Dom), you now get methods on "nodes". >> Y.get('.author').setStyle('cursor', 'move'); >> >> See http://developer.yahoo.com/yui/3/ and >> http://articles.sitepoint.com/article/yui-3-whats-new >> >> The other big argument against these types of frameworks is their >> size. YUI has a very small core and gets bigger as you need. It is >> componentized to the extreme (maybe even too much), but you can >> definitely only include what you want (the core is only a few k). The >> announcement blog post >> [http://www.yuiblog.com/blog/2009/09/29/yui-3-0-0/] talks about how >> something like the datasource component has been refactored and >> componentized. It is a The bad part is that there is additional >> configuration complexity in order to include all the right bits. The >> good part is they include a very sophisticated configurator that tells >> you how big your YUI footprint will be >> http://developer.yahoo.com/yui/3/configurator/ >> >> As far as the API and weight go I think that toolkits like YUI are a >> fine choice if you are building a web application. I'm using it for >> Agile Bench and I know Mint was using it too and both of these >> products are applications rather than just sites, but I reckon it is >> still worth checking out. >> >> Mark >> >> On Sat, Oct 3, 2009 at 6:47 PM, Joshua Partogi <[email protected]> >> wrote: >>> >>> On Sat, Oct 3, 2009 at 3:27 PM, David Lee <[email protected]> >>> wrote: >>>> Is YUI3 any more "streamlined" (in terms of feel / API) than YUI2 ? >>>> >>>> On Sat, Oct 3, 2009 at 9:42 AM, Mark Mansour <[email protected]> wrote: >>>>> >>>>> Lachie, I think you've nailed it here >>> >>> Mark, >>> >>> Would you share your experience with YUI and Rails? Does it work >>> really well together? >>> >>> >>> -- >>> Certified Scrum Master >>> http://twitter.com/scrum8 >>> Post agile jobs for free: http://jobs.scrum8.com >>> >>> > >>> >> >> >> >> -- >> Mark Mansour >> [email protected] >> http://agilebench.com/ >> >> > >> > > > > -- > Kornelis Sietsma korny at my surname dot com > kornys on twitter/fb/gtalk - korny on wave sandbox > "Every jumbled pile of person has a thinking part > that wonders what the part that isn't thinking > isn't thinking of" > > > > -- Mark Mansour [email protected] http://agilebench.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en -~----------~----~----~----~------~----~------~--~---
