isolation-mode tries to render templates (problem with pick_template)
Reported by Tim Haines | September 3rd, 2008 @ 12:40 AM | in 1.1.5
After upgrading to edge rails, rspec, and rspec-rails I have controller specs failing because views are being rendered when they shouldn't be (integrate_views is not set).
Here's a full back trace of one of the failures:
vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:376:in `raise_named_route_error'
vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:340:in `generate'
vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:208:in `rewrite_path'
vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:187:in `rewrite_url'
vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:165:in `rewrite'
vendor/rails/actionpack/lib/action_controller/base.rb:630:in `url_for'
vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:85:in `send'
vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:85:in `url_for'
(eval):15:in `user_path'
vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:111:in `__send__'
vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:111:in `polymorphic_url'
vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:118:in `polymorphic_path'
vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:91:in `url_for'
vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:228:in `link_to'
app/views/home/index.html.erb:5
app/views/home/index.html.erb:4:in `each'
app/views/home/index.html.erb:4
vendor/rails/actionpack/lib/action_view/renderable.rb:35:in `send'
vendor/rails/actionpack/lib/action_view/renderable.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:68:in `render_template'
vendor/rails/actionpack/lib/action_view/base.rb:266:in `orig_render'
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:26:in `render'
vendor/rails/actionpack/lib/action_view/base.rb:369:in `_render_with_layout'
vendor/rails/actionpack/lib/action_view/base.rb:260:in `orig_render'
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:26:in `render'
vendor/rails/actionpack/lib/action_controller/base.rb:1118:in `render_for_file'
vendor/rails/actionpack/lib/action_controller/base.rb:881:in `render_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb:213:in `render'
vendor/rails/actionpack/lib/action_controller/base.rb:853:in `render_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb:213:in `render'
vendor/rails/actionpack/lib/action_controller/base.rb:1170:in `default_render'
vendor/rails/actionpack/lib/action_controller/base.rb:1176:in `perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:202:in `perform_action_without_caching'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in `cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:535:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:535:in `process_without_filters'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
vendor/rails/actionpack/lib/action_controller/base.rb:535:in `process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process_without_test'
vendor/rails/actionpack/lib/action_controller/test_process.rb:18:in `process'
vendor/rails/actionpack/lib/action_controller/test_process.rb:400:in `process'
vendor/rails/actionpack/lib/action_controller/test_process.rb:371:in `get'
controllers/home_controller_spec.rb:12
vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in `instance_eval'
vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in `eval_block'
vendor/plugins/rspec/lib/spec/example/example_methods.rb:21:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:48:in `timeout'
vendor/plugins/rspec/lib/spec/example/example_methods.rb:18:in `execute'
vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:305:in `execute_examples'
vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in `each'
vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in `execute_examples'
vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:132:in `run'
vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in `run'
vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `each'
vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `run'
vendor/plugins/rspec/lib/spec/runner/options.rb:115:in `run_examples'
vendor/plugins/rspec/lib/spec.rb:21:in `run'
vendor/plugins/rspec/lib/spec/runner.rb:192:in `register_at_exit_hook'
controllers/home_controller_spec
Comments and changes to this ticket
-
Ian White September 3rd, 2008 @ 11:21 AM
- → Tag changed from to bug rspec_controller
I'm getting this as well, render is bailing out because it can't find the template.
I believe that this is probably caused by a change in ActionPack render internals, and rspec hasn't yet caught up. Investigating...
-

Tim Haines September 3rd, 2008 @ 11:34 AM
Hi Ian,
Thanks for taking a look at this. I saw a few other related bugs have been logged recently, and some fixed by David already. The trail starts at http://rspec.lighthouseapp.com/p...
Cheers,
Tim.
-
Ian White September 3rd, 2008 @ 11:42 AM
Ok, some info - the problem starts occurring from revision 6f932b4 of rails
Which bizarrely has this log message
"Database connections are now pooled, one pool per #establish_connection call. Pools start out empty and grow as necessary to a maximum size (default is 5, configure size with key 'pool' in your database configuration). If no connections are available, a thread will wait up to a 'wait_timeout' time (default is 5 seconds)."
Checking that change out on github...
-

Tim Haines September 3rd, 2008 @ 11:48 AM
How did you determine which revision it started occurring at?
-
Ian White September 3rd, 2008 @ 12:01 PM
How did you determine which revision it started occurring at?
I made a real simple controller test on a fresh rails app, and just started doing this (in vendor/rails)
git checkout HEAD^; touch ../../spec/controllers/foo_controller_spec.rb
(and let autospec tell me when the specs started to pass)
twenty or so keypresses later...
It turns out that the revision was a merge, and there's a whole bunch of changes in actionpack in that commit (git diff HEAD^) For one, it looks like file_exists? has disappeared, and there's a new mechanism for picking a template to render.
My guess is that rspec needs to know about this new mechanism to work in isolation mode.
Cheers, Ian
On 3 Sep 2008, at 11:48, Lighthouse wrote:
-
Ian White September 3rd, 2008 @ 12:11 PM
Ok, I think I've found the culprit.
pick_template has been renamed to _pick_template in this commit
When I change line 198 of spec/rails/controller_example_group.rb
define_method :_pick_template do |*args|
It all works.
For BC I guess both :pick_template or :_pick_template should be defined, or some branching code used.
Now to get down and dirty in rspec-dev
-

Tim Haines September 3rd, 2008 @ 12:34 PM
I can confirm that adding an _ to the start of pick_template as you suggested has resolved all of my failing specs too. Thanks for sorting this Ian.
-
Ian White September 3rd, 2008 @ 12:51 PM
- → Tag changed from bug rspec_controller to bug patch rspec_controller
OK, Here's a patch that fixed the problem.
Caveat - there's 46 failures on edge rails rspec-rails right now, this patch reduced that to 39, and introduced no new errors in the other rails versions.
Because of this, I didn't think it necessary to write new tests.
-
-
Ian White September 3rd, 2008 @ 01:27 PM
- → Title changed from Views rendered from controller specs when they shouldn't be to isolation-mode tries to render templates (problem with pick_template)
-
David Chelimsky September 7th, 2008 @ 03:27 PM
- → Assigned user changed from to David Chelimsky
- → Milestone changed from No-Milestone-Assigned to 1.1.5
- → State changed from new to resolved
Ian - thanks for the patch, but I fixed this by just changing pick_template to pick_template. pick_template was introduced between rails releases and changed to pick_template between releases and it's not feasible for rspec-rails to support multiple rails commits between releases.
Make sense?
-
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Behaviour Driven Development for Ruby.
