[rspec-devel] [ rspec-Bugs-8897 ] Error when mixing controller spec with/without integrated views and using template system other than rhtml

noreply at rubyforge.org noreply at rubyforge.org
Sun Mar 4 11:01:39 EST 2007


Bugs item #8897, was opened at 2007-02-26 20:50
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=8897&group_id=797

Category: rails plugin
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 3
Submitted By: Jonathan Tron (jonathant)
>Assigned to: David Chelimsky (dchelimsky)
Summary: Error when mixing controller spec with/without integrated views and using template system other than rhtml

Initial Comment:
Whooo what a title !!

The problem is RoR does caching of template/template extension in test mode. So when RSpec stub ActionView methods, to run controller specs in isolation mode, it faint Rails about the presence of a template with an rhtml extension. Now, if you mix, for the same controller, specs in isolation mode and spec with integrated views or even for different controllers which shares some templates AND you use a template system using an extension other than rhtml you're in some trouble.

One solution is to disable caching in environment/test.rb :

config.action_view.cache_template_extensions         = false

An other solution would probably be to do it in Spec::Rails::Runner::ControllerContext only when running with integrated views, but it probably means clearing the cache in some way (stubbing ?).

----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-03-04 16:01

Message:
Fixed in trunk rev 1565

THANK YOU, THANK YOU, THANK YOU!!!!

As it turns out, this solves a bug that was happening in rspec's specs only when run against edge rails or 1.1.6.

I've gone ahead and called this:

  ActionView::Base.cache_template_extensions = false

in EvalContext, meaning it will be set for all specs regardless of mode.

Personally, I don't see a problem w/ that. Do you?

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=8897&group_id=797


More information about the rspec-devel mailing list