I want to make a spec for the mailing that is already implemented and I have this:
- rspec-rails 3.5.2
- rails 5
- ruby 2.3.1
app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base
default from: '[email protected]'
layout 'mailer'
end
app/mailers/user_mailer.rb
class UserMailer < ApplicationMailer
def welcome(user)
@user = user
mail(to: @user.email, subject: 'Welcome!')
end
end
config/environments/test.rb
Rails.application.configure do
#[...]
config.action_mailer.delivery_method = :test
#[...]
end
spec/mailers/usermailer_spec.rb
require 'spec_helper'
RSpec.describe UserMailer, :type => :mailer do
#[...]
end
When I run
rspec spec/mailers/usermailer_spec.rb
I receive this error message on the terminal:
[...]spec/mailers/usermailer_spec.rb:4:in `': uninitialized constant UserMailer (NameError) [...]
usermailer_spec.rb&user_mailer.rb(don't match) Try maybe renaming spec touser_mailer_spec.rband see if this helps - Tomasz Giba