railsinator-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-31 21:56 UTC
advice/suggestions for testing helpers
I''m having trouble testing helpers. I''ve found the topfunky helper testing plugin (http://nubyonrails.com/articles/2006/04/07/test-your- helpers), and I''ve seen the helper testing discussion in the rails recipe book, but both are falling short. Please let me know if I''m missing something. My helpers often need access to current url details, such as the action and params, and session values. These solutions don''t seem to address this. What would be really nice is to have a functional test that would establish the state for the url and session, and then have it yield or call back so that the helper functions could be tested. I might be able to do helper tests *after* the processing of the request (in a functional test), if I could figure out how to invoke the helpers. My best idea so far is to refactor my helper methods so that I have a version of the function that doesn''t rely on the session or controller state, and instead has the appropriate values provided as parameters. Any other ideas or suggestions? Thank you. -Kelly --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''m ripping my hair out this one. I have two select boxes. Both have an ''observe_field'' on it. The first select box, when changed, will clear the second select box and, if it needs to, adds new options to the second select box. The second select box, when changed, will grab a number from the database and put it in a text box. This all works great, except for the following circumstance. 1. The second select box is changed to the second option in the list, The text box is updated. 2. The first select box is changed to another option, clearing the second select box. 3. The first select box is changed to the first option it was on, filling the second select box with options, with the first option in the list showing. 4. The second select box is changed to the second option in the list. Nothing happens. The ''observe_field'' never fires. After that, if I pick different selections in the list, it works fine. So if I pick the first option and then the second option again, it works. Has anyone else run into this problem. It seems to happen on both Firefox 2 and IE 7. I''ve tried clearing the list in many different ways: Setting the length to 0, looping backwards through the list and setting each option to null. I''ve also tried many different ways to set the selection: setting selectedIndex to 0, adding true to the Option when it''s created when it''s the first, setting options[0].selected = true. Nothing seems to work. Stephen Gerstacker --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Stephen Gerstacker wrote:> I''m ripping my hair out this one. > > I have two select boxes. Both have an ''observe_field'' on it. The first > select box, when changed, will clear the second select box and, if it > needs > to, adds new options to the second select box. The second select box, > when > changed, will grab a number from the database and put it in a text box. > > This all works great, except for the following circumstance. > > 1. The second select box is changed to the second option in the list, > The > text box is updated. > 2. The first select box is changed to another option, clearing the > second > select box. > 3. The first select box is changed to the first option it was on, > filling > the second select box with options, with the first option in the list > showing. > 4. The second select box is changed to the second option in the list. > > Nothing happens. > The ''observe_field'' never fires. > > After that, if I pick different selections in the list, it works fine. > So > if I pick the first option and then the second option again, it works. > > Has anyone else run into this problem. It seems to happen on both > Firefox 2 > and IE 7. > > I''ve tried clearing the list in many different ways: Setting the length > to > 0, looping backwards through the list and setting each option to null. > > I''ve also tried many different ways to set the selection: setting > selectedIndex to 0, adding true to the Option when it''s created when > it''s > the first, setting options[0].selected = true. > > Nothing seems to work. > > Stephen GerstackerYou might get more responses if starting a new thread, instead of replying to another. It looks to me you should take a look at the prototype code for "observe_field". Maybe even with the Firebug debugger. I don''t think the code is that hard, and also not hard to change. We did that once, to solve a similar problem. Or maybe you will find a way to reset the value that is compared against for "observe_field". I don''t remember. Stephan -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---