I'm using a mail interceptor as follows:
setup_mail.rb
Mail.register_interceptor(MailInterceptor) if Rails.env != "production"
class MailInterceptor
class MailInterceptor
def self.delivering_email(message)
message.subject = "#{message.subject} [#{message.to}]"
message.to = "[email protected]"
end
end
I'm unable to create an rspec for this interceptor as it is not happen with rake spec.
I have the following spec:
describe "MailInterceptor" do
it "should be intercepted" do
@email = UserMailer.registration_automatically_generated(@user)
@email.should deliver_to("[email protected]")
end
end
In the test.log I see that the deliver_to is not the interceptor. Any ideas on how I can write an rspec for the interceptor?
Thanks