Problem with helpers in view

23 views
Skip to first unread message

Martin

unread,
Nov 28, 2009, 12:05:37 PM11/28/09
to sporkgem
Hi,

I posted my problem first on rspec-users but I got the tip that this
would be the right place to ask. So here I am ;-)

I've got a problem when using spork. If I use a helper method which is
defined in a custom helper module (app/helpers/simple_helper.rb) then
I got the following error when running "rake spec".

ActionView::TemplateError in '/items/index.html.erb renders a list of
items'
undefined method `simpleFunction' for #<ActionView::Base:0x2409c44>
On line #2 of app/views/items/index.html.erb

This simpleFunction is defined in app/helpers/simple_helper.rb. The
error does not occur when running "rake spec" without spork.

I put this simple rails project as example on github: http://github.com/JerryWho/test

First I thought simple_helper.rb isn't loaded but that's not correct.
Using some puts $" I can see that the file is loaded.

Any ideas what I'm doing wrong?

Thanks,
Martin

Martin

unread,
Nov 28, 2009, 12:06:54 PM11/28/09
to sporkgem
As always I once again forgot to tell you the versions I'm using:
spork 0.7.3
rspec 1.2.9
rails 2.3.5

Tim Harper

unread,
Dec 3, 2009, 3:38:24 PM12/3/09
to spor...@googlegroups.com
> --
>
> As always I once again forgot to tell you the versions I'm using:
> spork 0.7.3
> rspec 1.2.9
> rails 2.3.5
>

This sounds nasty :( I've starred this email but I've procrastinated
getting to it because I'm afraid it may take an hour or so to delve in
and find the issue. Rails internals can be not very fun to spelunk
sometimes.

Tim

Tim Harper

unread,
Dec 4, 2009, 10:17:01 AM12/4/09
to spor...@googlegroups.com
> This sounds nasty :(  I've starred this email but I've procrastinated
> getting to it because I'm afraid it may take an hour or so to delve in
> and find the issue. Rails internals can be not very fun to spelunk
> sometimes.
>
> Tim
>

Reproduced the problem in your test application. In an even more
strange turn of events, running "spec spec/views" fails, but "cd spec
&& spec views" passes.

What an exciting mystery to be solved! ;)

Tim Harper

unread,
Dec 4, 2009, 10:20:48 AM12/4/09
to spor...@googlegroups.com
Doh, that was because it wasn't picking up the spec options, and
therefore wasn't using spork :S lol

Tim Harper

unread,
Dec 4, 2009, 11:35:23 PM12/4/09
to spor...@googlegroups.com
Hey Martin,

I deployed a fix to gemcutter (0.7.4). It works with your example, so
it should fix your real case as well.

It was kind of a big pain to track down :S Spork is really fighting
some of the rails magic to make things work. Most of the cases work,
but these little edge cases pop up and they are a bugger.

Anyways, I added another test to lock it down, and tested it against
rails 2.1.0, 2.2.x, and 2.3.5.

Tim

Martin

unread,
Dec 5, 2009, 6:06:49 AM12/5/09
to spor...@googlegroups.com
Hi Tim,

>
> I deployed a fix to gemcutter (0.7.4). It works with your example, so
> it should fix your real case as well.
>

yes it does. Thank you very much.

> It was kind of a big pain to track down :S Spork is really fighting
> some of the rails magic to make things work. Most of the cases work,
> but these little edge cases pop up and they are a bugger.

I took a look at what you have changed. I have to say that's really
beyond my horizon.

So thanks again for your great work.

Martin
Reply all
Reply to author
Forward
0 new messages