Skip to content

Instantly share code, notes, and snippets.

@queso
Created November 18, 2008 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save queso/26135 to your computer and use it in GitHub Desktop.
Save queso/26135 to your computer and use it in GitHub Desktop.
1)
NoMethodError in 'UserMailer should create a new email row when sending an email'
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.render_subject
/Users/josh/Code/HandCrafted/bootstrap/app/models/mailer.rb:16:in `setup_template'
/Users/josh/Code/HandCrafted/bootstrap/app/models/user_mailer.rb:23:in `setup_user_notification_email'
/Users/josh/Code/HandCrafted/bootstrap/app/models/user_mailer.rb:9:in `activation'
/Library/Ruby/Gems/1.8/gems/actionmailer-2.1.1/lib/action_mailer/base.rb:446:in `__send__'
/Library/Ruby/Gems/1.8/gems/actionmailer-2.1.1/lib/action_mailer/base.rb:446:in `create!'
/Library/Ruby/Gems/1.8/gems/actionmailer-2.1.1/lib/action_mailer/base.rb:439:in `initialize'
/Library/Ruby/Gems/1.8/gems/actionmailer-2.1.1/lib/action_mailer/base.rb:383:in `new'
/Library/Ruby/Gems/1.8/gems/actionmailer-2.1.1/lib/action_mailer/base.rb:383:in `method_missing'
/Users/josh/Code/HandCrafted/bootstrap/spec/models/user_mailer_spec.rb:9:
/Users/josh/Code/HandCrafted/bootstrap/script/spec:4:
class UserMailer < Mailer
def signup_notification(user)
setup_user_notification_email('signup', user)
end
def activation(user)
puts self.class
setup_user_notification_email('activation', user)
end
def forgot_password(user)
setup_user_notification_email('forgot_password', user)
end
def reset_password(user)
setup_user_notification_email('reset_password', user)
end
private
def setup_user_notification_email(name, user)
setup_template(name, user.email) do |options|
options['user'] = user
end
end
end
require File.dirname(__FILE__) + '/../spec_helper'
describe UserMailer do
it "should create a new email row when sending an email" do
user = Factory(:user)
user_mailer = mock(UserMailer)
user_mailer.should_receive(:setup_template)
UserMailer.deliver_activation(user)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment