So the stock answer to this is “don’t do it”. But I’m in a situation
where it’s really what I want to do to test what I want to test.
a helper method:
def some_helper
render(:partial => “some/partial”, :locals => {:some => some}
end
or even:
def some_helper
content = “”
some_loop.each do |something|
content << render(:partial => “some/partial”, :locals =>
{:something => something}
end
end
Is there any way to write a spec where I can test this kind of helper,
and it really will render it’s partial(s), and I can really write specs
against the return strings?
Any way at all? I’ve been trying for a while with no success. Thanks for
any advice.
Jonathan
On Jul 13, 2010, at 5:43 PM, Jonathan R. wrote:
against the return strings?
Any way at all? I’ve been trying for a while with no success. Thanks for
any advice.
RSpec version?
David C. wrote:
On Jul 13, 2010, at 5:43 PM, Jonathan R. wrote:
against the return strings?
Any way at all? I’ve been trying for a while with no success. Thanks for
any advice.
RSpec version?
Good point. Rails2, rspec 1.3.0. Thanks.
On Jul 13, 2010, at 6:05 PM, Jonathan R. wrote:
Good point. Rails2, rspec 1.3.0. Thanks.
Do you know about integrate_views?
http://rspec.info/rails/writing/controllers.html
On Jul 13, 2010, at 6:59 PM, Jonathan R. wrote:
spec. If I actually set it up as a helper spec… I don’t seem to get
“integrate_views”, if I try to call it I get a method missing exception.
Can I set it up as a controller spec, but then somehow still spec a
helper method, rather than a controller? I thought of that, and tried
to do it, but couldn’t quite figure out how to do that. Any advice?
I don’t think there’s a good way to do that in RSpec-1. In RSpec-2,
however, you should be able to do this in a regular helper spec.
HTH,
David
David C. wrote:
I don’t think there’s a good way to do that in RSpec-1. In RSpec-2,
however, you should be able to do this in a regular helper spec.
Okay, thanks. Can’t wait until I get my app migrated to Rails3, glad
that Rspec has improved in flexibility in a great many ways, it appears,
in Rspec2/Rails3.
David C. wrote:
On Jul 13, 2010, at 6:05 PM, Jonathan R. wrote:
Do you know about integrate_views?
http://rspec.info/rails/writing/controllers.html
I read about it in my quest through the documentation for a solution.
This isn’t actually a controller spec I’m trying to write, it’s a helper
spec. If I actually set it up as a helper spec… I don’t seem to get
“integrate_views”, if I try to call it I get a method missing exception.
Can I set it up as a controller spec, but then somehow still spec a
helper method, rather than a controller? I thought of that, and tried
to do it, but couldn’t quite figure out how to do that. Any advice?
Jonathan