[rspec-users] Testing Email thriugh Rspec

Amit Kulkarni lists at ruby-forum.com
Fri Jan 22 02:34:14 EST 2010

Hi i am testing email through rspec but some problem occured.
This is the whole scenario:
What i want to do is when my user is created it should send mail to for
This is the code under user_spec.rb
require File.expand_path(File.dirname(__FILE__) + ‘/../spec_helper’)

def valid_user_attributes
:email => “testing at joshsoftware.com”,
:login => “test”,
:password => “test123″,
:password_confirmation => “test123″,
:role_id => 1

describe User do
before(:each) do
@user = User.create
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []

fixtures :users

context “User” do
it “should be create if all the credentials are provided” do
@user.attributes = valid_user_attributes
mail = Notifier.signup_notification(”user_1″)
ActionMailer::Base.deliveries.size.should == 1
mail.body.should =~ /Please signup/
@user.should be_valid

Under notifier.rb it contains:
class Notifier < ActionMailer::Base
 helper :application
 #user notification
 def signup_notification( user )
    setup_email( user.email )
    @subject = "Please signup"
    @body[:user] = user
Now here Notifier is another model which contains signup_ notification
Is it the case that i would need to test that in notifier spec or is it
possible to get notifier model in user like by using include method

I tried using include like "include Notifier" but is is showing me error
user_spec.rb:2:in `include': wrong argument type Class (expected Module)
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list