Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7174893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:09:35+00:00 2026-05-28T16:09:35+00:00

I tried using this How do I test Pony emailing in a Sinatra app,

  • 0

I tried using this How do I test Pony emailing in a Sinatra app, using rspec? to test a Rails 3.1 app sending emails. The sending works fine, but I’m having a hard time getting the tests to work. Here’s what I have so far …

spec/spec_helper.rb

config.before(:each) do
    do_not_send_email
end
.
.
.
def do_not_send_email
    Pony.stub!(:deliver) # Hijack to not send email.
end

and in my users_controller_spec.rb

it "should send a greeting email" do
    post :create, :user => @attr
    Pony.should_receive(:mail) do |params|
        params[:to].should == "nuser@gmail.com"
        params[:body].should include("Congratulations")
    end
end

and I get this …

Failures:

1) UsersController POST ‘create’ success should send a greeting email
Failure/Error: Pony.should_receive(:mail) do |params|
(Pony).mail(any args)
expected: 1 time
received: 0 times
# ./spec/controllers/users_controller_spec.rb:121:in `block (4 levels) in ‘

It looks like Pony’s not getting an email, but I know the real email is getting sent out.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:09:35+00:00Added an answer on May 28, 2026 at 4:09 pm

    Here’s what I finally ended up with for the test …

    it "should send a greeting email" do
        Pony.should_receive(:deliver) do |mail|
            mail.to.should == [ 'nuser@gmail.com' ]
            mail.body.should =~ /congratulations/i
        end
        post :create, :user => @attr
    end
    

    The Pony.should_rececieve needs :deliver (not :mail), the do/end was changed a bit, and the post was done after the setup.

    Hope this helps someone else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried using the boost deadline_timer in this simple test application, but had some
i've tried using this code and this to make a random quote generator, but
I tried using height: 100% but this makes the div only as high as
I tried to send an email using this class below, but no success, no
I tried this using Test user and random friend , it seems Test user
I want to create multilevel accordion Navigation using jQuery , I tried using this
Can someone show me how to use the System.Numerics.BigInteger datatype? I tried using this
I just got Java5 project that has this error, i tried using Java5 and
I tried this aproach without any success the code I'm using: // File name
Using PyCrypto (although I've tried this in ObjC with OpenSSL bindings as well) :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.