<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Small Rspec revelations, ActionMailer</title>
	<atom:link href="http://www.rubytutorials.net/2008/02/26/small-rspec-revelations-actionmailer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rubytutorials.net/2008/02/26/small-rspec-revelations-actionmailer/</link>
	<description>Doctor's orders</description>
	<pubDate>Wed, 08 Sep 2010 09:35:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: admin</title>
		<link>http://www.rubytutorials.net/2008/02/26/small-rspec-revelations-actionmailer/#comment-1711</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Fri, 22 Jan 2010 07:37:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubytutorials.net/?p=11#comment-1711</guid>
		<description>You have to spec a notifier (instance of ActionMailer) seperately. And it took me a long time to figure out. A spec would look something like this:

describe Notifications, :type =&gt; :helper do #setting type is necessary
  before(:each) do
    ActionMailer::Base.delivery_method = :test
    ActionMailer::Base.perform_deliveries = true
    ActionMailer::Base.deliveries = []
  end

  it "should sent a nice email with the analyses to the user" do
    analysis_observer = AnalysisObserver.instance
    analysis_observer.stub!(:after_create)
    mail = Notifications.deliver_analyses_to_user "somegmail@gmail.com", Factory(:temporary_user, :analyses =&gt; [Factory(:analysis)])
    ActionMailer::Base.deliveries.size.should == 1
    mail.body.should have_tag("img", 3)
    mail.body.should have_tag("table")
  end

Hope that helps!</description>
		<content:encoded><![CDATA[<p>You have to spec a notifier (instance of ActionMailer) seperately. And it took me a long time to figure out. A spec would look something like this:</p>
<p>describe Notifications, :type => :helper do #setting type is necessary<br />
  before(:each) do<br />
    ActionMailer::Base.delivery_method = :test<br />
    ActionMailer::Base.perform_deliveries = true<br />
    ActionMailer::Base.deliveries = []<br />
  end</p>
<p>  it &#8220;should sent a nice email with the analyses to the user&#8221; do<br />
    analysis_observer = AnalysisObserver.instance<br />
    analysis_observer.stub!(:after_create)<br />
    mail = Notifications.deliver_analyses_to_user &#8220;somegmail@gmail.com&#8221;, Factory(:temporary_user, :analyses => [Factory(:analysis)])<br />
    ActionMailer::Base.deliveries.size.should == 1<br />
    mail.body.should have_tag(&#8221;img&#8221;, 3)<br />
    mail.body.should have_tag(&#8221;table&#8221;)<br />
  end</p>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amit</title>
		<link>http://www.rubytutorials.net/2008/02/26/small-rspec-revelations-actionmailer/#comment-1710</link>
		<dc:creator>Amit</dc:creator>
		<pubDate>Fri, 22 Jan 2010 06:57:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubytutorials.net/?p=11#comment-1710</guid>
		<description>Hi i am testing email through rspec.I followed your suggestions 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 activation.
This is the code under user_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
#require 'rasta/fixture/rasta_fixture'
#require 'fastercsv'

def valid_user_attributes
  {
    :email =&#62; "testing@joshsoftware.com",
    :login =&#62; "test",
    :password =&#62; "test123",
    :password_confirmation =&#62; "test123",
    :role_id =&#62; 1
  }
end

describe User do
  before(:each) do
    @user = User.create
    ActionMailer::Base.delivery_method = :test  
    ActionMailer::Base.perform_deliveries = true  
    ActionMailer::Base.deliveries = []  
  end

  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
       @user.save
    end

Now here Notifier ia another model which contains signup_ notification method.
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 require 'notifier.rb'
Please suggest</description>
		<content:encoded><![CDATA[<p>Hi i am testing email through rspec.I followed your suggestions but some problem occured.<br />
This is the whole scenario:<br />
What i want to do is when my user is created it should send mail to for activation.<br />
This is the code under user_spec.rb<br />
require File.expand_path(File.dirname(__FILE__) + &#8216;/../spec_helper&#8217;)<br />
#require &#8216;rasta/fixture/rasta_fixture&#8217;<br />
#require &#8216;fastercsv&#8217;</p>
<p>def valid_user_attributes<br />
  {<br />
    :email =&gt; &#8220;testing@joshsoftware.com&#8221;,<br />
    :login =&gt; &#8220;test&#8221;,<br />
    :password =&gt; &#8220;test123&#8243;,<br />
    :password_confirmation =&gt; &#8220;test123&#8243;,<br />
    :role_id =&gt; 1<br />
  }<br />
end</p>
<p>describe User do<br />
  before(:each) do<br />
    @user = User.create<br />
    ActionMailer::Base.delivery_method = :test<br />
    ActionMailer::Base.perform_deliveries = true<br />
    ActionMailer::Base.deliveries = []<br />
  end</p>
<p>  fixtures :users</p>
<p>  context &#8220;User&#8221; do<br />
    it &#8220;should be create if all the credentials are provided&#8221; do<br />
      @user.attributes = valid_user_attributes<br />
       mail = Notifier.signup_notification(&#8221;user_1&#8243;)<br />
       ActionMailer::Base.deliveries.size.should == 1<br />
       mail.body.should =~ /Please signup/<br />
       @user.should be_valid<br />
       @user.save<br />
    end</p>
<p>Now here Notifier ia another model which contains signup_ notification method.<br />
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 require &#8216;notifier.rb&#8217;<br />
Please suggest</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ahabman</title>
		<link>http://www.rubytutorials.net/2008/02/26/small-rspec-revelations-actionmailer/#comment-1361</link>
		<dc:creator>ahabman</dc:creator>
		<pubDate>Tue, 24 Nov 2009 17:48:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubytutorials.net/?p=11#comment-1361</guid>
		<description>Perfect.  That's exactly what I needed.</description>
		<content:encoded><![CDATA[<p>Perfect.  That&#8217;s exactly what I needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simple Email Form with ActionMailer</title>
		<link>http://www.rubytutorials.net/2008/02/26/small-rspec-revelations-actionmailer/#comment-1293</link>
		<dc:creator>Simple Email Form with ActionMailer</dc:creator>
		<pubDate>Wed, 18 Nov 2009 06:33:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubytutorials.net/?p=11#comment-1293</guid>
		<description>[...] In test-driven style (thanks to rubytutorials.net), here&#8217;s a spec for we&#8217;ll make work (at least the sending mail part of it). Note that [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] In test-driven style (thanks to rubytutorials.net), here&#8217;s a spec for we&#8217;ll make work (at least the sending mail part of it). Note that [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcelo Silveira</title>
		<link>http://www.rubytutorials.net/2008/02/26/small-rspec-revelations-actionmailer/#comment-1206</link>
		<dc:creator>Marcelo Silveira</dc:creator>
		<pubDate>Thu, 29 Oct 2009 19:51:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubytutorials.net/?p=11#comment-1206</guid>
		<description>Helped a lot. Thanks!</description>
		<content:encoded><![CDATA[<p>Helped a lot. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Garland</title>
		<link>http://www.rubytutorials.net/2008/02/26/small-rspec-revelations-actionmailer/#comment-790</link>
		<dc:creator>Dan Garland</dc:creator>
		<pubDate>Fri, 22 May 2009 10:06:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubytutorials.net/?p=11#comment-790</guid>
		<description>Thanks for this it worked well for me.

I opted to put 
ActionMailer::Base.delivery_method = :test  

in my environment though.

Cheers,</description>
		<content:encoded><![CDATA[<p>Thanks for this it worked well for me.</p>
<p>I opted to put<br />
ActionMailer::Base.delivery_method = :test  </p>
<p>in my environment though.</p>
<p>Cheers,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ariejan</title>
		<link>http://www.rubytutorials.net/2008/02/26/small-rspec-revelations-actionmailer/#comment-544</link>
		<dc:creator>Ariejan</dc:creator>
		<pubDate>Wed, 11 Mar 2009 12:17:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubytutorials.net/?p=11#comment-544</guid>
		<description>Awesome! Thanks!</description>
		<content:encoded><![CDATA[<p>Awesome! Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
