Anyone is doing email testing with RSpec?
Can you post some examples?
Thank you, Laco M.
Anyone is doing email testing with RSpec?
Can you post some examples?
Thank you, Laco M.
On 28/09/2007, at 9:01 PM, Ladislav Martincik wrote:
Anyone is doing email testing with RSpec?
Can you post some examples?
Like this?
before(:each) do
@user1 = mock_model(UserAccount, :email => ‘[email protected]’)
@user2 = mock_model(UserAccount, :email => ‘[email protected]’)
@user3 = mock_model(UserAccount, :email => ‘[email protected]’)
UserAccount.should_receive(:find).with(:all).and_return([@user1,
@user2, @user3])
@controller.stub!(:authorize).and_return(true)
@emails = ActionMailer::Base.deliveries
@emails.clear
end
it “should send three separate emails” do
post :email, :email =>{:body => ‘my message’, :from =>
‘[email protected]’, :subject => ‘testing email’}
@emails.size.should == 3
email_to_fred = @emails[0]
email_to_fred.to.should == ['[email protected]']
email_to_fred.subject.should == 'testing email'
email_to_fred.body.should match(/my message/)
email_to_bill = @emails[1]
email_to_bill.to.should == ['[email protected]']
email_to_bill.subject.should == 'testing email'
email_to_bill.body.should match(/my message/)
email_to_jane = @emails[2]
email_to_jane.to.should == ['[email protected]']
email_to_jane.subject.should == 'testing email'
email_to_jane.body.should match(/my message/)
end
HTH
Shane
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs