[sporkgem] spork + cucumber + active_scaffold = "You have a nil object when you didn't expect it!"

42 views
Skip to first unread message

hoenth

unread,
May 13, 2010, 9:52:47 AM5/13/10
to sporkgem
I have been using activescaffold in my application for more than a
year, and have been using cucumber to do integration testing. All has
worked well, until I recently started trying to use spork to provide a
drb to cucumber to speed up the tests.

When cucumber hits pages that contain activescaffold embeds, like the
following:

25: <%= render :active_scaffold => 'messages', :constraints =>
{ :group_id => @classroom.id, :group_type => 'Classroom' } %>

I get the following error:

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
(ActionView::TemplateError)
On line #25 of app/views/classrooms/show.html.erb

If I run cucumber without spork, I don't get the error.

If the cucumber test does not encounter an embedded active_scaffold
partial, I don't get the error.

I am having a hard time pointing a finger at the problem, as there is
a lot going on here, between spork, cucumber, active_scaffold,
render_component, etc. When using spork, I can't seem to break into a
debugger session to try to trace the error to its source.

Any advice you can provide would be greatly appreciated.

Thanks
Tom

Rails: 2.3.2
spork: 0.8.3
Ruby: 1.8.6

Running on Windows

PS: I am also going to post this message to the active_scaffold group.

--
You received this message because you are subscribed to the Google Groups "sporkgem" group.
To post to this group, send email to spor...@googlegroups.com.
To unsubscribe from this group, send email to sporkgem+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sporkgem?hl=en.

hoenth

unread,
Jun 9, 2010, 8:48:19 AM6/9/10
to sporkgem
After some investigation and conversation with the activescaffold
folks, here is what the activescaffold developer concluded:

Spork modifies eager loading views (it delays it), so @paths is not
initialized
when AS looks for a view in its paths. I think it's a spork issue but
I don't
know spork to fix it, I was looking at spork code to guess this.

This came from finding that the error occurs here:

Here now is the trace I get:

actionpack (2.3.2) lib/action_view/template.rb:76:in `[]'
actionpack (2.3.2) lib/action_view/paths.rb:48:in
`find_template_without_active_scaffold'
actionpack (2.3.2) lib/action_view/paths.rb:47:in `each'
actionpack (2.3.2) lib/action_view/paths.rb:47:in
`find_template_without_active_scaffold'
vendor/plugins/active_scaffold/lib/extensions/
generic_view_paths.rb:11:in `find_template'
actionpack (2.3.2) lib/action_controller/base.rb:1380:in
`default_template'
actionpack (2.3.2) lib/action_controller/base.rb:943:in
`render_without_benchmark'
actionpack (2.3.2) lib/action_controller/benchmarking.rb:
51:in `render_without_active_scaffold'
activesupport (2.3.2) lib/active_support/core_ext/
benchmark.rb:17:in `ms'
activesupport (2.3.2) lib/active_support/core_ext/
benchmark.rb:10:in `realtime'
activesupport (2.3.2) lib/active_support/core_ext/
benchmark.rb:17:in `ms'
actionpack (2.3.2) lib/action_controller/benchmarking.rb:
51:in `render_without_active_scaffold'
vendor/plugins/active_scaffold/lib/extensions/
action_controller_rendering.rb:13:in `render'

Which implies that the @path variable is not getting set.

If you have any advice as to how to allow spork and AS to coexist, I
would greatly appreciate it.

Tom

Tim Harper

unread,
Jun 9, 2010, 12:19:50 PM6/9/10
to spor...@googlegroups.com
Hi Tom,

Have you looked at the spork ruby-debug monkey-patch? At the top of
your cucumber file, if you require "spork/ext/ruby-debug", it ought to
install the hooks necessary to make ruby-debug play with spork. This
is tested in the spork integration tests, so I am confident that it
should work.

As far as your issue goes, yes, this stinks. Sorry about that. Rails
is a convoluted mess and getting it to submit is a very tricky, nasty
job. The rails app-framework support for Spork is far from a perfect
solution, but it's the best I could do.

Now... what's interesting here is... yes, eager loading _IS_ delayed.
That means it will be run right after the fork, and before the tests
are run. What is triggering the render call with active scaffold? Can
you extend the stack trace further?

Tim

Tom Hoen

unread,
Jun 10, 2010, 11:25:04 AM6/10/10
to spor...@googlegroups.com
Hey Tim - Thanks for your response. I will give the debugger a try. In the
mean time, there are probably a couple of pieces of information that I need
to share. I am running this on a windows machine, and so am using the
magazine instead of fork.

Here is the full stack:

actionpack (2.3.5) lib/action_view/template.rb:81:in `[]'
actionpack (2.3.5) lib/action_view/paths.rb:48:in
`find_template_without_active_scaffold'
actionpack (2.3.5) lib/action_view/paths.rb:47:in `each'
actionpack (2.3.5) lib/action_view/paths.rb:47:in
`find_template_without_active_scaffold'
vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb:11:in
`find_template'
actionpack (2.3.5) lib/action_controller/base.rb:1389:in `default_template'
actionpack (2.3.5) lib/action_controller/base.rb:951:in
`render_without_benchmark'
actionpack (2.3.5) lib/action_controller/benchmarking.rb:51:in
`render_without_active_scaffold'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:17:in `ms'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:10:in
`realtime'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:17:in `ms'
actionpack (2.3.5) lib/action_controller/benchmarking.rb:51:in
`render_without_active_scaffold'

vendor/plugins/active_scaffold/lib/extensions/action_controller_rendering.rb
:13:in `render'
vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb:14:in
`table'
actionpack (2.3.5) lib/action_controller/base.rb:1331:in `send'
actionpack (2.3.5) lib/action_controller/base.rb:1331:in
`perform_action_without_filters'
actionpack (2.3.5) lib/action_controller/filters.rb:617:in `call_filters'
actionpack (2.3.5) lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
actionpack (2.3.5) lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:17:in `ms'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:10:in
`realtime'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:17:in `ms'
actionpack (2.3.5) lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
actionpack (2.3.5) lib/action_controller/rescue.rb:160:in
`perform_action_without_flash'
actionpack (2.3.5) lib/action_controller/flash.rb:146:in
`perform_action_without_render_component'
vendor/plugins/render_component/lib/components.rb:39:in `perform_action'
actionpack (2.3.5) lib/action_controller/base.rb:532:in `send'
actionpack (2.3.5) lib/action_controller/base.rb:532:in
`process_without_filters'
actionpack (2.3.5) lib/action_controller/filters.rb:606:in `process'
vendor/plugins/render_component/lib/components.rb:27:in
`process_with_components'
vendor/plugins/render_component/lib/components.rb:93:in
`component_response'
vendor/plugins/render_component/lib/components.rb:65:in
`render_component_as_string'
vendor/plugins/render_component/lib/components.rb:125:in
`component_logging'
vendor/plugins/render_component/lib/components.rb:64:in
`render_component_as_string'
vendor/plugins/render_component/lib/components.rb:33:in `__send__'
vendor/plugins/render_component/lib/components.rb:33:in `render_component'

vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb:59:in
`render_without_mock_proxy'

c:/Ruby/lib/ruby/gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/a
ction_view/base.rb:27:in `render'
app/views/classrooms/show.html.erb:25
actionpack (2.3.5) lib/action_view/renderable.rb:34:in `send'
actionpack (2.3.5) lib/action_view/renderable.rb:34:in
`render_without_active_scaffold'
actionpack (2.3.5) lib/action_view/base.rb:306:in `with_template'
actionpack (2.3.5) lib/action_view/renderable.rb:30:in
`render_without_active_scaffold'

vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb:94:in
`render_without_template_tracking'
actionpack (2.3.5) lib/action_view/test_case.rb:20:in `render'
actionpack (2.3.5) lib/action_view/template.rb:205:in `render_template'
actionpack (2.3.5) lib/action_view/base.rb:265:in
`render_without_active_scaffold'

vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb:61:in
`render_without_mock_proxy'

c:/Ruby/lib/ruby/gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/a
ction_view/base.rb:27:in `render'
actionpack (2.3.5) lib/action_view/base.rb:348:in `_render_with_layout'
actionpack (2.3.5) lib/action_view/base.rb:262:in
`render_without_active_scaffold'

vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb:61:in
`render_without_mock_proxy'

c:/Ruby/lib/ruby/gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/a
ction_view/base.rb:27:in `render'
actionpack (2.3.5) lib/action_controller/base.rb:1250:in `render_for_file'
actionpack (2.3.5) lib/action_controller/base.rb:951:in
`render_without_benchmark'
actionpack (2.3.5) lib/action_controller/benchmarking.rb:51:in
`render_without_active_scaffold'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:17:in `ms'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:10:in
`realtime'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:17:in `ms'
actionpack (2.3.5) lib/action_controller/benchmarking.rb:51:in
`render_without_active_scaffold'

vendor/plugins/active_scaffold/lib/extensions/action_controller_rendering.rb
:13:in `render'
actionpack (2.3.5) lib/action_controller/mime_responds.rb:135:in `send'
actionpack (2.3.5) lib/action_controller/mime_responds.rb:135:in `custom'
actionpack (2.3.5) lib/action_controller/mime_responds.rb:179:in `call'
actionpack (2.3.5) lib/action_controller/mime_responds.rb:179:in `respond'
actionpack (2.3.5) lib/action_controller/mime_responds.rb:173:in `each'
actionpack (2.3.5) lib/action_controller/mime_responds.rb:173:in `respond'
actionpack (2.3.5) lib/action_controller/mime_responds.rb:107:in
`respond_to'
app/controllers/classrooms_controller.rb:27:in `show'
actionpack (2.3.5) lib/action_controller/base.rb:1331:in `send'
actionpack (2.3.5) lib/action_controller/base.rb:1331:in
`perform_action_without_filters'
actionpack (2.3.5) lib/action_controller/filters.rb:617:in `call_filters'
actionpack (2.3.5) lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
actionpack (2.3.5) lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:17:in `ms'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:10:in
`realtime'
activesupport (2.3.5) lib/active_support/core_ext/benchmark.rb:17:in `ms'
actionpack (2.3.5) lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
actionpack (2.3.5) lib/action_controller/rescue.rb:160:in
`perform_action_without_flash'
actionpack (2.3.5) lib/action_controller/flash.rb:146:in
`perform_action_without_render_component'
vendor/plugins/render_component/lib/components.rb:39:in `perform_action'
actionpack (2.3.5) lib/action_controller/base.rb:532:in `send'
actionpack (2.3.5) lib/action_controller/base.rb:532:in
`process_without_filters'
actionpack (2.3.5) lib/action_controller/filters.rb:606:in `process'
actionpack (2.3.5) lib/action_controller/base.rb:391:in `process'
actionpack (2.3.5) lib/action_controller/base.rb:386:in `call'
actionpack (2.3.5) lib/action_controller/routing/route_set.rb:437:in `call'
actionpack (2.3.5) lib/action_controller/dispatcher.rb:87:in `dispatch'
actionpack (2.3.5) lib/action_controller/dispatcher.rb:121:in `_call'
actionpack (2.3.5) lib/action_controller/dispatcher.rb:130:in
`build_middleware_stack'
actionpack (2.3.5) lib/action_controller/string_coercion.rb:25:in `call'
actionpack (2.3.5) lib/action_controller/string_coercion.rb:25:in `call'
rack (1.0.1) lib/rack/head.rb:9:in `call'
rack (1.0.1) lib/rack/methodoverride.rb:24:in `call'
actionpack (2.3.5) lib/action_controller/params_parser.rb:15:in `call'
actionpack (2.3.5) lib/action_controller/session/abstract_store.rb:122:in
`call'
activerecord (2.3.5) lib/active_record/query_cache.rb:29:in `call'
activerecord (2.3.5)
lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
activerecord (2.3.5) lib/active_record/query_cache.rb:9:in `cache'
activerecord (2.3.5) lib/active_record/query_cache.rb:28:in `call'
activerecord (2.3.5)
lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in
`call'
actionpack (2.3.5) lib/action_controller/failsafe.rb:26:in `call'
rack (1.0.1) lib/rack/lock.rb:11:in `call'
rack (1.0.1) lib/rack/lock.rb:11:in `synchronize'
rack (1.0.1) lib/rack/lock.rb:11:in `call'
actionpack (2.3.5) lib/action_controller/dispatcher.rb:106:in `call'
rack (1.0.1) lib/rack/lint.rb:47:in `_call'
rack (1.0.1) lib/rack/lint.rb:35:in `call'
actionpack (2.3.5) lib/action_controller/integration.rb:316:in `process'
actionpack (2.3.5) lib/action_controller/integration.rb:197:in `get'
actionpack (2.3.5) lib/action_controller/integration.rb:499:in `__send__'
actionpack (2.3.5) lib/action_controller/integration.rb:499:in `get'
webrat (0.7.1) lib/webrat/adapters/rails.rb:50:in `send'
webrat (0.7.1) lib/webrat/adapters/rails.rb:50:in `do_request'
webrat (0.7.1) lib/webrat/adapters/rails.rb:15:in `get'
(__FORWARDABLE__):3:in `__send__'
(__FORWARDABLE__):3:in `get'
webrat (0.7.1) lib/webrat/core/session.rb:280:in `send'
webrat (0.7.1) lib/webrat/core/session.rb:280:in `process_request'
webrat (0.7.1) lib/webrat/core/session.rb:119:in `request_page'
webrat (0.7.1) lib/webrat/core/session.rb:132:in `request_page'
webrat (0.7.1) lib/webrat/core/elements/form.rb:20:in `submit'
webrat (0.7.1) lib/webrat/core/elements/field.rb:193:in `click'
webrat (0.7.1) lib/webrat/core/scope.rb:291:in `click_button'
(__FORWARDABLE__):3:in `__send__'
(__FORWARDABLE__):3:in `click_button'
webrat (0.7.1) lib/webrat/core/methods.rb:7:in `click_button'
features/step_definitions/logins_steps.rb:44:in `__instance_exec1'
cucumber (0.7.3) lib/cucumber/core_ext/instance_exec.rb:26:in `send'
cucumber (0.7.3) lib/cucumber/core_ext/instance_exec.rb:26:in
`instance_exec'
cucumber (0.7.3) lib/cucumber/core_ext/instance_exec.rb:48:in
`cucumber_instance_exec'
cucumber (0.7.3) lib/cucumber/core_ext/instance_exec.rb:69:in
`cucumber_run_with_backtrace_filtering'
cucumber (0.7.3) lib/cucumber/core_ext/instance_exec.rb:36:in
`cucumber_instance_exec'
cucumber (0.7.3) lib/cucumber/rb_support/rb_step_definition.rb:54:in
`invoke'
cucumber (0.7.3) lib/cucumber/step_match.rb:26:in `invoke'
cucumber (0.7.3) lib/cucumber/step_mother.rb:179:in `invoke'
cucumber (0.7.3) lib/cucumber/rb_support/rb_world.rb:22:in `When'
features/step_definitions/logins_steps.rb:49:in `__instance_exec0'
cucumber (0.7.3) lib/cucumber/core_ext/instance_exec.rb:26:in `send'
cucumber (0.7.3) lib/cucumber/core_ext/instance_exec.rb:26:in
`instance_exec'
cucumber (0.7.3) lib/cucumber/core_ext/instance_exec.rb:48:in
`cucumber_instance_exec'
cucumber (0.7.3) lib/cucumber/core_ext/instance_exec.rb:69:in
`cucumber_run_with_backtrace_filtering'
cucumber (0.7.3) lib/cucumber/core_ext/instance_exec.rb:36:in
`cucumber_instance_exec'
cucumber (0.7.3) lib/cucumber/rb_support/rb_step_definition.rb:54:in
`invoke'
cucumber (0.7.3) lib/cucumber/step_match.rb:26:in `invoke'
cucumber (0.7.3) lib/cucumber/ast/step_invocation.rb:62:in `invoke'
cucumber (0.7.3) lib/cucumber/ast/step_invocation.rb:41:in `accept'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:99:in `visit_step'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:98:in `visit_step'
cucumber (0.7.3) lib/cucumber/ast/step_collection.rb:15:in `accept'
cucumber (0.7.3) lib/cucumber/ast/step_collection.rb:14:in `each'
cucumber (0.7.3) lib/cucumber/ast/step_collection.rb:14:in `accept'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:93:in `visit_steps'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:92:in `visit_steps'
cucumber (0.7.3) lib/cucumber/ast/scenario.rb:54:in `accept'
cucumber (0.7.3) lib/cucumber/step_mother.rb:330:in `before_and_after'
cucumber (0.7.3) lib/cucumber/ast/scenario.rb:52:in `accept'
cucumber (0.7.3) lib/cucumber/step_mother.rb:319:in `call'
cucumber (0.7.3) lib/cucumber/step_mother.rb:319:in `around'
cucumber (0.7.3) lib/cucumber/language_support/language_methods.rb:13:in
`around'
cucumber (0.7.3) lib/cucumber/language_support/language_methods.rb:95:in
`call'
cucumber (0.7.3) lib/cucumber/language_support/language_methods.rb:95:in
`execute_around'
cucumber (0.7.3) lib/cucumber/language_support/language_methods.rb:12:in
`around'
cucumber (0.7.3) lib/cucumber/step_mother.rb:318:in `around'
cucumber (0.7.3) lib/cucumber/step_mother.rb:316:in `call'
cucumber (0.7.3) lib/cucumber/step_mother.rb:316:in `around'
cucumber (0.7.3) lib/cucumber/ast/scenario.rb:51:in `accept'
cucumber (0.7.3) lib/cucumber/ast/scenario.rb:108:in `with_visitor'
cucumber (0.7.3) lib/cucumber/ast/scenario.rb:45:in `accept'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:51:in
`visit_feature_element'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:50:in
`visit_feature_element'
cucumber (0.7.3) lib/cucumber/ast/feature.rb:35:in `accept'
cucumber (0.7.3) lib/cucumber/ast/feature.rb:34:in `each'
cucumber (0.7.3) lib/cucumber/ast/feature.rb:34:in `accept'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:20:in `visit_feature'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:19:in `visit_feature'
cucumber (0.7.3) lib/cucumber/ast/features.rb:29:in `accept'
cucumber (0.7.3) lib/cucumber/ast/features.rb:17:in `each'
cucumber (0.7.3) lib/cucumber/ast/features.rb:17:in `each'
cucumber (0.7.3) lib/cucumber/ast/features.rb:28:in `accept'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:14:in `visit_features'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
cucumber (0.7.3) lib/cucumber/ast/tree_walker.rb:13:in `visit_features'
cucumber (0.7.3) lib/cucumber/cli/main.rb:66:in `execute!'
spork (0.8.3) lib/spork/test_framework/cucumber.rb:23:in `run_tests'
/magazine_slave.rb:22:in `run'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1555:in `__send__'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1555:in `perform_without_block'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1515:in `perform'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1589:in `main_loop'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1585:in `loop'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1585:in `main_loop'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1581:in `start'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1581:in `main_loop'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1430:in `run'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1427:in `start'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1427:in `run'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1347:in `initialize'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1627:in `new'
c:/Ruby/lib/ruby/1.8/drb/drb.rb:1627:in `start_service'
magazine_slave_provider.rb:17

Hi Tom,

Tim

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.829 / Virus Database: 271.1.1/2926 - Release Date: 06/09/10
02:35:00

Tim Harper

unread,
Jun 10, 2010, 11:54:38 AM6/10/10
to spor...@googlegroups.com
Hmm.... very interesting. From the looks of it, it appears there is a
problem with Spork#trap_method, and that it's not executing the
delayed eager-view loading.

Could you build a tiny, sample AS application and reproduce the issue with it?

Thanks!

Tim

Tom Hoen

unread,
Jun 10, 2010, 1:04:15 PM6/10/10
to spor...@googlegroups.com
Hey Tim, I have created a sample app. I have not frozen the gems in the app.
Do you need me to?

What is the best way to get it to you?

Thanks
Tom

Thanks!

Tim

Version: 9.0.829 / Virus Database: 271.1.1/2929 - Release Date: 06/10/10
02:35:00

Tim Harper

unread,
Jun 10, 2010, 1:12:46 PM6/10/10
to spor...@googlegroups.com
github would work. Or you zip the app up and send it straight to me.

Thanks!

Tim

Reply all
Reply to author
Forward
0 new messages