Closed wincent closed 14 years ago
For reference, this is my workaround that I've stuck in spec/support/mailer_spec_helpers.rb:
module MailerSpecHelpers
extend ActiveSupport::Concern
included do
Rails.configuration.action_mailer.default_url_options.each do |key, value|
default_url_options[key] = value
end
end
include Rails.application.routes.url_helpers
end
Then in the mailer spec itself:
describe CommentMailer do
include MailerSpecHelpers
...
end
Seems like a good addition. Patch would be welcome. Get some sleep first, though.
Ok, have pushed a patch to the "issue-94" branch of my fork:
http://github.com/wincent/rspec-rails/commits/issue-94
Specifically, this commit:
http://github.com/wincent/rspec-rails/commit/fa34d8df79fb2d4fc6bde22437fa677a5076aa7b
Cheers, Wincent
Here's the merged commit for the reference.
Updating an app from RSpec 1.3 to RSpec 2.0 I've noticed that the standard URL helpers aren't available in my mailer specs any more.
I can't remember doing anything special in RSpec 1.3 to make them available, and looking at the RSpec 1.3 code I can't see anything explicit in there to make the helpers available either, but I might be overlooking it.
In RSpec 2.0 I've had to add something like the following "include" to make the helpers available:
Do you think it would be a good idea to add the helpers in by default? As in, roll it into ./lib/rspec/rails/example/mailer_example_group.rb? Something like the following (not tested yet, just a demo of the basic idea):
If you think it's a good idea let me know and I'll prepare a patch. In the meantime though I'll just stick something in my spec_helper so that I don't have to repeat the above set-up in all my mailer specs.
If it's a bad idea please be gentle as I am feeling a little sleep-deprived and possibly stupid right now.
(No idea whether I am going to run into similar issues with url_helpers in other types of specs... I only just started converting this app and have started with the mailer specs...)
Cheers, Wincent