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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:51:59+00:00 2026-05-29T03:51:59+00:00

I am trying to setup specs for my Checkout::Sale class that employs ActiveMerchant using

  • 0

I am trying to setup specs for my Checkout::Sale class that employs ActiveMerchant using credentials for a test Authorize.NET account that I set up the other day.

My plan was to use VCR to record the response for the gateway and run my specs against that, so I’m not hitting the gateway all the time when I run my specs.

Here’s is my spec and my class that I’m testing.

My issue is, this code works perfectly if I’m am in the Rails console (development environment), but fails every time I run my specs (test environment). Specifically, the Authorize.NET API complains that my credentials are invalid…

(TESTMODE) The merchant login ID or password is invalid or the account
is inactive.

… even though I use the exact same credentials in development and they work fine.

I have no ActiveMerchant-related logic in either config/environments/development.rb and config/environments/test.rb.

I don’t understand how the exact same code is working for me in development and not in test mode. Anyone know what’s up with this?

I’m using activemerchant 1.20.2, rspec 2.8.0 and rails 3.1.1.

NOTE: This fails regardless if I’m using VCR or not; removing VCR seems to have no effect.

  • 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-29T03:52:00+00:00Added an answer on May 29, 2026 at 3:52 am

    Aph, just figured it out.

    Just passing test: true only makes the transaction a test transaction, even though the gateway is still hitting the :production gateway.

    As this test runs without Rails loaded, I wasn’t loading in my environment files, where I had specified for both dev and test:

    ActiveMerchant::Billing::Base.mode = :test
    

    Since loading the rails console does load Rails, that’s why it was working in development but not in my tests. Throwing the above into a before block solved my problem.

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

Sidebar

Related Questions

I'm trying setup a subset of boost and get it properly compiled using bjam,
After trying to setup my site for Google Webmaster Tools I found that my
I'm trying to setup CruiseControl.net at the moment. So far it works nice, but
I'm trying to setup an Apache/PHP/Postgresql server locally on my machine. I'm using Windows
I'm trying to setup an automated build server for my rails projects using Hudson
I'm trying to use setup the rails application on apache2 using the virtual server
I m trying setup a cassandra cluster as a test bed but gave the
Trying to setup a Cron task that gets a file via FTP however seems
I am trying to install openID into my web site project that is using
When trying to launch the rails console after updating my ruby setup using 'sudo

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.