Stubbing helpers

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

Hard-coded stuff

end
end

Can this be done? Thanks,
–Trevor

sure just store in a instant variable and print the contents of that
variable in your view

On 11/16/06, Trevor L. [email protected] wrote:

require ‘application_helper’
class ApplicationController < ActionController::Base
def my_helper

Hard-coded stuff

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() ‘

junk
’ end
else
def my_helper() content_tag :div, special_junk end
end
end

jeremy

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs