Errors: Spork, haml and emails templates

25 views
Skip to first unread message

Mohith Thimmaiah

unread,
Dec 29, 2011, 8:17:06 AM12/29/11
to sporkgem
#################
Context:

Im using spork,cucumber,email_spec in my testing of emails
My config.action_mailer.delivery_method = :test
My email templates are all haml based
All emails are working in non-test env i.e dev/prod I dont have any
problems

#################
Problem:

When I run my cucumber tests and the mails get triggered I get the
error shown below.
Note 2 things
1. :handlers=>[:erb, :rjs, :builder, :rhtml, :rxml] does not
show :haml as being avail even though Ive required 'haml' and 'haml-
rails' and have them both in my Gemfile
2. /haml/helpers are being invoked if you look carefully at the
stacktrace



Why are my email haml templates not being rendered when being invoked
within a spork environment ?



#################
Error stack trace

Missing template user_response_mailer/send_contact_info with
{:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:html], :locale=>[:en]}
in view paths \"/home/thimmaiah/work/InAJiffy/app/views\", \"/home/
thimmaiah/work/InAJiffy/vendor/plugins/metamagic/app/views\", \"/home/
thimmaiah/work/InAJiffy/vendor/plugins/dynamic_sitemaps/app/views\",
\"/home/thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/devise-1.3.3/app/views
\", \"/home/thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/
exception_logger-0.1.10/app/views\", \"/home/thimmaiah/.rvm/gems/
ruby-1.9.2-p180/gems/high_voltage-0.9.4/app/views\"\n/home/
thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/
action_view/paths.rb:15:in `find\'\\n/home/thimmaiah/.rvm/gems/
ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/action_view/
lookup_context.rb:81:in `find\'\\n/home/thimmaiah/.rvm/gems/ruby-1.9.2-
p180/gems/actionpack-3.0.3/lib/action_view/base.rb:186:in
`find_template\'\\n/home/thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/
actionpack-3.0.3/lib/action_view/render/rendering.rb:47:in
`_determine_template\'\\n/home/thimmaiah/.rvm/gems/ruby-1.9.2-p180/
gems/actionpack-3.0.3/lib/action_view/render/rendering.rb:24:in `render
\'\\n/home/thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/haml-3.1.2/lib/
haml/helpers/action_view_mods.rb:13:in `render_with_haml\'\\n/home/
thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/
abstract_controller/rendering.rb:115:in `_render_template\'\\n/home/
thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/
abstract_controller/rendering.rb:108:in `render_to_body\'\\n/home/
thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/
abstract_controller/rendering.rb:101:in `render_to_string\'\\n/home/
thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/
abstract_controller/rendering.rb:92:in `render\'\\n/home/
thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/actionmailer-3.0.3/lib/
action_mailer/deprecated_api.rb:111:in `render\'\\n/home/thimmaiah/
work/InAJiffy/app/mailers/user_response_mailer.rb:35:in `block (2
levels) in send_contact_info\'\\n/home/thimmaiah/.rvm/gems/ruby-1.9.2-
p180/gems/actionmailer-3.0.3/lib/action_mailer/collector.rb:26:in
`custom\'\\n/home/thimmaiah/.rvm/gems/ruby-1.9.2-p180/gems/
actionpack-3.0.3/lib/abstract_controller/collector.rb:10:in `html\'\\n/
home/thimmaiah/work/InAJiffy/app/mailers/user_response_mailer.rb:35:in
`block in send_contact_info\'\\n/home/thimmaiah/.rvm/gems/ruby-1.9.2-
p180/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:694:in
`collect_responses_and_parts_order\'\\n/home/thimmaiah/.rvm/gems/
ruby-1.9.2-p180/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:
648:in `mail\'\\n/home/thimmaiah/work/InAJiffy/app/mailers/
user_response_mailer.rb:34:

timcharper

unread,
Jan 22, 2012, 5:27:15 PM1/22/12
to spor...@googlegroups.com
Mohith,

First, happy new year!

I think that the reason HAML may not be being registered as a helper is due to the load order being changed when tests are run under Spork. This is unfortunate. It would be worth while to look at the Rails loader code and understand this. You might look into manually calling the integration hook yourself, but understandably, that is messy and shouldn't be necessary.

I've recently split out the attempt at rails integration to a separate gem. You might try using Spork 1.0.0rc0 without spork-rails. In your preload block, don't load your rails environment. Instead, I might extract a file that loads as many application dependencies as possible (that aren't files that live in the project and you actively develop on), then require that from your config/application.rb and your spork preload block. Load the environment in the each_run block.

The disadvantage of this is that you'll likely lose some of the speed gains from Spork.

Another option would be similar: don't use spork-rails, turn cache_classes = false, and then force an ActiveSupport dependency reload on each run. This might lead to other problems, but at least they would be consistent problems between runs.
Reply all
Reply to author
Forward
0 new messages