Hi, Is it possible to stub out a helper for development? I''ve got a (view) helper that renders a partial and runs all kind of javascript. But for dev purposes I''d like it to return some hardcoded html. I''m not having any success stubbing the helper out. Something like... test/mocks/development/helper_stub.rb require ''application_helper'' class ApplicationController < ActionController::Base def my_helper "<div>Hard-coded stuff</div>" end end Can this be done? Thanks, --Trevor --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
sure just store in a instant variable and print the contents of that variable in your view -- 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 -~----------~----~----~----~------~----~------~--~---
On 11/16/06, Trevor Leffler <tleffler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Is it possible to stub out a helper for development? > > I''ve got a (view) helper that renders a partial and runs all kind of > javascript. But for dev purposes I''d like it to return some hardcoded > html. I''m not having any success stubbing the helper out. Something > like... > > test/mocks/development/helper_stub.rb > > require ''application_helper'' > class ApplicationController < ActionController::Base > def my_helper > "<div>Hard-coded stuff</div>" > end > end > > Can this be done? Thanks,You can test RAILS_ENV in your class or module definition: module MyHelper if RAILS_ENV == ''development'' def my_helper() ''<div>junk</div>'' end else def my_helper() content_tag :div, special_junk end end end jeremy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---