3

One of my rspec tests fails because I can't use a helper method on a decorator rendering a view, while the view works perfectly while running the server normally, here's the error

1) dashboard/index.html.haml render all translations
   Failure/Error: render
   ActionView::Template::Error:
   undefined method `dashboard?' for #<#<Class:0x0000000a9d1020>:0x0000000c2286f0>

the following method is a simple boolean check called inside a decorator method called from the rendered view:

items << h.link_to(...) if h.dashboard?

And the helper method:

def dashboard?
  controller_name == "dashboard"
end

I can import the helper module into the decorator but then the error changes to controller_name is undefined, so I guess my question is in two parts:

One, how can I get the helper method to work when the decorator is called from a rendered view through Rspec, and two, how can I set the controller_name to work within the Rspec test.

Marcelo Risoli
  • 792
  • 7
  • 24

1 Answers1

0

Your test is looking for a method called dashboard? which doesn't appear defined within your code.

You can either update your test to look for the method moderators_dashboard?

Or

Change def moderators_dashboard? to def dashboard?

thedanotto
  • 6,895
  • 5
  • 45
  • 43
  • I guess I erased something around when pasting the code, but there's no dashboard?, it is moderators_dashboard? Everywhere, I'll edit it for clarity – Marcelo Risoli Aug 28 '15 at 18:34