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 6224131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:37:05+00:00 2026-05-24T08:37:05+00:00

New to TDD here, d’oh! Here’s what I want to test ( ruby library

  • 0

New to TDD here, d’oh!

Here’s what I want to test (ruby library), in brief:

 account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)
    resp = account.request(
        "/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages",
        'POST',
        smsInfo
    )

And here’s test code attempt:

describe Text do
  it "should call the Twilio API with credentials" do
    #pending "mocking api although not passed in.."
    t = mock(Twilio::RestAccount)
    twapi = mock("new twapi").should_receive(:request).and_return(Net::HTTPSuccess)
    t.stub(:new).and_return(twapi)

    Twilio::RestAccount.should_receive(:new)

    sms = Factory.create(:boring_sms)
    sms.send_sms
  end
end

which generates the error: undefined method `request’ for nil:NilClass

Am I taking the right approach? thanks!

  • 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-24T08:37:06+00:00Added an answer on May 24, 2026 at 8:37 am

    With Twilio and other external services, I also consider using VCR. http://relishapp.com/myronmarston/vcr

    The upside is that you get it working once with manual testing, and it’s basically verifying you don’t mess anything up. Downside is that any time you touch code tested by VCR, you often have to re-test everything manually that’s tested by VCR. Something else to consider.

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

Sidebar

Related Questions

I'm new to TDD and xUnit so I want to test my method that
.NET Framework: 2.0 Preferred Language: C# I am new to TDD (Test Driven Development).
I want to follow TDD, but the command grails test-app CUT needs almost a
I'm very new to TDD world. I have a few questions regarding TDD. Do
First let me state that, despite being a fairly new practitioner of TDD, I'm
I am new (as of today) to NUnit and TDD. However, I am very
I'm new to C#/.NET but I've been doing TDD for quite some time now.
So, carrying on with my new years resolution to get more in to TDD,
I am trying to re-write a method using TDD. Here is the original method
For TDD you have to Create a test that fail Do the simplest thing

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.