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

  • Home
  • SEARCH
  • 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 8932815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:23:42+00:00 2026-06-15T09:23:42+00:00

Consider a Rails app that hits a (Sinatra app) API being developed separately from

  • 0

Consider a Rails app that hits a (Sinatra app) API being developed separately from the Rails app. I want to test an API call from within the Rails tests.

The API code:

post '/foo/create' do
  ...

I created a mock, but that doesn’t make sense because it is just a copy of the API file. That stinks.

It is possible to require the API file in the test. But how to call it from RSpec? There is no route in the Rails app for it.

One option is to start the API and make the HTTP call from the Rails test, but this is smelly because:

  1. You have to start the API server to run the Rails tests
  2. Why should a Rails test make a HTTP request? Rack::Test simulates this.
  3. I don’t think this will work because the apps have different test databases, but share the same production database.

EDIT: The point of the test is that the API call creates records that the Rails app is expecting. So the Rails app needs to test the state of the database after the API call is made.

  • 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-06-15T09:23:43+00:00Added an answer on June 15, 2026 at 9:23 am

    Well. The perfect answer for you is a gem to mock the answer like webmock. It will fake a response when acessing that url, so on the test your app will make the requisition as it was for real, only that before it hits the web, it will hit your mock and respond with the desired answer.

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

Sidebar

Related Questions

Consider this scenario. We have an internal Rails 2 app that connects to a
Consider a basic Rails development pipeline, going from development -> staging -> production. When
I have got a Rails app running which displays data that is generated by
I'm developing an app with Rails 3.1.2 but I can't find some documentation that
I am using REST and OAuth to talk to a Rails app (from an
am struggling with Ruby validates :confirmation => true in my Rails app. Consider the
I'm trying setup a Rails app that will be something like a game. The
Okay, consider the following: A app/views/pages/index.html.erb , consisting of: <div id='content'> <%= link_to 'Test',
I have recently upgraded an app from Rails 3.0 to 3.1. I have followed
Please consider this scenario: a web app that has 4 levels of access: admin

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.