Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7639423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:24:53+00:00 2026-05-31T08:24:53+00:00

I taught that, with an option like delivery_method = :test in my config/environments/test.rb I

  • 0

I taught that, with an option like delivery_method = :test in my config/environments/test.rb I should not receive any mails while running my Rspec tests:

config/environments/test.rb:

config.action_mailer.delivery_method = :test

But in my tests, when I create a user with FactoryGirl and the user has an after_save callback that sends a signup-notification, this email will be sent:

myspec.rb:

user = FactoryGirl.create(:user, :login => 'johndoe')

user_observer.rb:

class UserObserver < ActiveRecord::Observer
  def after_create(user)
    UserMailer.signup_notification(user).deliver
  end
end

action_mailer.rb:

ActionMailer::Base.delivery_method = :smtp

ActionMailer::Base.smtp_settings = {
  :address => "...",
  :port => "25",
  :domain => "...",
  :user_name => "...",
  :password => "...",
  :authentication => :plain
}

What can be wrong?

I’m using:

  • Rails 3.2.2
  • buildin ActionMailer
  • RSpec-Rails
  • FactoryGirl
  • Guard
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:24:55+00:00Added an answer on May 31, 2026 at 8:24 am

    Yes, you are right. ActionMailer::Base.delivery_method = :smtp masks your configuration in environment/test.rb

    I propose you next solution: create fixture with specific data for each scope.
    like in enter link description here
    in my case it looks like:

    my config.yml

     development:
          support_mail: test@test.test
          smtp_user_name: test@test.test
          smtp_password: test
          smtp_domain: test.test
          smtp_address: test.test.test
          smtp_port: => 999
    
        test:
          support_mail: test@test.test
          smtp_user_name: test@test.test
          smtp_password: test
          smtp_domain: test.test
          smtp_address: test.test.test
          smtp_port: => 999
    
        production:
          support_mail: somth@somth.com
          smtp_user_name: somth@somth.com
          smtp_password: somth
          smtp_domain: somth.com
          smtp_address: smtp.somth.com
          smtp_port: => 587
    

    my environment.rb

    # Load the rails application
    require File.expand_path('../application', __FILE__)
    #initialize custom config variables
    APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]
        ActionMailer::Base.smtp_settings = {
          :user_name => APP_CONFIG["smtp_user_name"], #ENV['SENDGRID_USERNAME'],
          :password => APP_CONFIG["smtp_password"], #  ENV['SENDGRID_PASSWORD'],
          :domain => APP_CONFIG["smtp_domain"],
          :address => APP_CONFIG["smtp_address"],
          :port => APP_CONFIG["smtp_port"],
          :authentication => :plain,
          :enable_starttls_auto => false
        }
    ActionMailer::Base.delivery_method = :smtp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I attended a session in which it was taught that we should not use
In Java, it's taught that variables should be kept private to enable better encapsulation,
I'm trying to learn this basic thing about processors that should be taught in
I have always been taught that non-primitive types should be passed by const reference
I was taught that private methods should begin with lowercase for example: thisIsBestPractice I've
I was taught that a regression test was a small (only enough to prove
Some years ago, I was taught that JavaScript code blocks embedded inside HTML should
I was taught that in maths we evaluate things, with the acronym BODMAS Brackets,
Inspired by the discussion in this question . We have all been taught that
It is taught in every computer science class and written in many books that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.