Hi all, I just started using unittest.js with the javascript_test plugin. It seems like it hasn''t been updated much recently, but is still really useful. I''ve got a function that''s run onDOMReady (using lowpro''s Event.onReady), that should redirect the user if a certain browser extension isn''t installed: Event.onReady(function(){ if (!window.google || !google.gears) { location.href = "http://gears.google.com/" } }) In order to test this, I''d like to stub google.gears to return false, and location.href to be nop, but make sure that it''s called. With mocha/stubba, I''d do something like: google.stubs(:gears).returns(false) location.expects(:href).returns(nil).once Does anyone have any idea how to do something like that in Javascript? I''d think Javascript''s looseness would make it pretty straightforward. For bonus points: anyone have any idea how to do something like Event.simulateEvent(''DOM'', ''ready'') (which obviously won''t work...)? Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Take a look at js-spec. I think it''s pretty much what you need. http://code.google.com/p/js-spec/ - kangax On Feb 18, 4:08 pm, "I. E. Smith-Heisters" <i...-ZMJO0lPjCCA@public.gmane.org> wrote:> Hi all, > > I just started using unittest.js with the javascript_test plugin. It > seems like it hasn''t been updated much recently, but is still really > useful. > > I''ve got a function that''s run onDOMReady (using lowpro''s > Event.onReady), that should redirect the user if a certain browser > extension isn''t installed: > > Event.onReady(function(){ > if (!window.google || !google.gears) { > location.href = "http://gears.google.com/" > } > }) > > In order to test this, I''d like to stub google.gears to return false, > and location.href to be nop, but make sure that it''s called. With > mocha/stubba, I''d do something like: > > google.stubs(:gears).returns(false) > location.expects(:href).returns(nil).once > > Does anyone have any idea how to do something like that in Javascript? > I''d think Javascript''s looseness would make it pretty straightforward. > > For bonus points: anyone have any idea how to do something like > Event.simulateEvent(''DOM'', ''ready'') (which obviously won''t work...)? > > Thanks!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Looks neat, but the documentation and liveliness of the project seems even less than javascript_test. Nonetheless, I may borrow some stuff from that project''s expectations.js file to do what I''m trying to accomplish. I''ll post back here if/when I get something running. Thanks! On 2/18/08, kangax <kangax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Take a look at js-spec. I think it''s pretty much what you need. > http://code.google.com/p/js-spec/ > > - kangax > > On Feb 18, 4:08 pm, "I. E. Smith-Heisters" <i...-ZMJO0lPjCCA@public.gmane.org> wrote: > > Hi all, > > > > I just started using unittest.js with the javascript_test plugin. It > > seems like it hasn''t been updated much recently, but is still really > > useful. > > > > I''ve got a function that''s run onDOMReady (using lowpro''s > > Event.onReady), that should redirect the user if a certain browser > > extension isn''t installed: > > > > Event.onReady(function(){ > > if (!window.google || !google.gears) { > > location.href = "http://gears.google.com/" > > } > > }) > > > > In order to test this, I''d like to stub google.gears to return false, > > and location.href to be nop, but make sure that it''s called. With > > mocha/stubba, I''d do something like: > > > > google.stubs(:gears).returns(false) > > location.expects(:href).returns(nil).once > > > > Does anyone have any idea how to do something like that in Javascript? > > I''d think Javascript''s looseness would make it pretty straightforward. > > > > For bonus points: anyone have any idea how to do something like > > Event.simulateEvent(''DOM'', ''ready'') (which obviously won''t work...)? > > > > Thanks! > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Heh, I''m right now buried under a lot of work and js-spec has been pretty much dead for a while. I *am* going to get back on track with it, and if you''re interested in helping out, I''d appreciate that. I''m probably going to move the repository over to git so I don''t have to be around to commit the patches I''ve received :) About mocking and stubbing, I was thinking on a nice implementation for that, that was as nice as it is with rspec but doesn''t touch Object.prototype. Best, -Nicolas On Feb 19, 3:41 pm, "Ian Smith-Heisters" <i...-ZMJO0lPjCCA@public.gmane.org> wrote:> Looks neat, but the documentation and liveliness of the project seems > even less than javascript_test. Nonetheless, I may borrow some stuff > from that project''s expectations.js file to do what I''m trying to > accomplish. I''ll post back here if/when I get something running. > > Thanks! > > On 2/18/08, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Take a look at js-spec. I think it''s pretty much what you need. > >http://code.google.com/p/js-spec/ > > > - kangax > > > On Feb 18, 4:08 pm, "I. E. Smith-Heisters" <i...-ZMJO0lPjCCA@public.gmane.org> wrote: > > > Hi all, > > > > I just started using unittest.js with the javascript_test plugin. It > > > seems like it hasn''t been updated much recently, but is still really > > > useful. > > > > I''ve got a function that''s run onDOMReady (using lowpro''s > > > Event.onReady), that should redirect the user if a certain browser > > > extension isn''t installed: > > > > Event.onReady(function(){ > > > if (!window.google || !google.gears) { > > > location.href = "http://gears.google.com/" > > > } > > > }) > > > > In order to test this, I''d like to stub google.gears to return false, > > > and location.href to be nop, but make sure that it''s called. With > > > mocha/stubba, I''d do something like: > > > > google.stubs(:gears).returns(false) > > > location.expects(:href).returns(nil).once > > > > Does anyone have any idea how to do something like that in Javascript? > > > I''d think Javascript''s looseness would make it pretty straightforward. > > > > For bonus points: anyone have any idea how to do something like > > > Event.simulateEvent(''DOM'', ''ready'') (which obviously won''t work...)? > > > > Thanks!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
w00t! I got my invite to github about 2 hours after writing this :) I''ve set up a git repo for js-spec in http://github.com/foca/js-spec Best, -Nicolas On Feb 19, 2008 4:25 PM, Nicolas Sanguinetti <godfoca-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Heh, I''m right now buried under a lot of work and js-spec has been > pretty much dead for a while. I *am* going to get back on track with > it, and if you''re interested in helping out, I''d appreciate that. I''m > probably going to move the repository over to git so I don''t have to > be around to commit the patches I''ve received :) > > About mocking and stubbing, I was thinking on a nice implementation > for that, that was as nice as it is with rspec but doesn''t touch > Object.prototype. > > Best, > -Nicolas > > On Feb 19, 3:41 pm, "Ian Smith-Heisters" <i...-ZMJO0lPjCCA@public.gmane.org> wrote: > > Looks neat, but the documentation and liveliness of the project seems > > even less than javascript_test. Nonetheless, I may borrow some stuff > > from that project''s expectations.js file to do what I''m trying to > > accomplish. I''ll post back here if/when I get something running. > > > > Thanks! > > > > > On 2/18/08, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Take a look at js-spec. I think it''s pretty much what you need. > > >http://code.google.com/p/js-spec/ > > > > > - kangax > > > > > On Feb 18, 4:08 pm, "I. E. Smith-Heisters" <i...-ZMJO0lPjCCA@public.gmane.org> wrote: > > > > Hi all, > > > > > > I just started using unittest.js with the javascript_test plugin. It > > > > seems like it hasn''t been updated much recently, but is still really > > > > useful. > > > > > > I''ve got a function that''s run onDOMReady (using lowpro''s > > > > Event.onReady), that should redirect the user if a certain browser > > > > extension isn''t installed: > > > > > > Event.onReady(function(){ > > > > if (!window.google || !google.gears) { > > > > location.href = "http://gears.google.com/" > > > > } > > > > }) > > > > > > In order to test this, I''d like to stub google.gears to return false, > > > > and location.href to be nop, but make sure that it''s called. With > > > > mocha/stubba, I''d do something like: > > > > > > google.stubs(:gears).returns(false) > > > > location.expects(:href).returns(nil).once > > > > > > Does anyone have any idea how to do something like that in Javascript? > > > > I''d think Javascript''s looseness would make it pretty straightforward. > > > > > > For bonus points: anyone have any idea how to do something like > > > > Event.simulateEvent(''DOM'', ''ready'') (which obviously won''t work...)? > > > > > > Thanks! > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---