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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:58:36+00:00 2026-06-02T03:58:36+00:00

I have a RESTful site that uses both the XML and web responses (API

  • 0

I have a RESTful site that uses both the XML and web responses (API and web site). Since there are a lot of pages, my current goal is setting up RSpec to simply request each of the pages in both data formats and check if the returned response is 200. What is the best way to check for both XML and HTTP 200 response? I know I should be doing TDD upfront, but right now I need this as a shell.

Example: I want to request both “/users” and “/users.xml” and test if there weren’t any server errors (200 OK)

  • 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-02T03:58:39+00:00Added an answer on June 2, 2026 at 3:58 am

    I wrote a blog post on testing JSON APIs with RSpec a couple of weeks ago.

    Basically, the way we are doing it is to get the actual response, and parse it to make sure it has the right content. As an example:

    context "#index (GET /artworks.json)" do
      # create 30 Artwork documents using FactoryGirl, and do a HTTP GET request on "/artworks.json"
      before(:each) do
        30.times { FactoryGirl.create(:artwork) }
        get "/artworks.json"
      end
      describe "should list all artworks" do
        # the request returns a variable called "response", which we can then make sure comes back as expected
        it { response.should be_ok }
        it { JSON.parse(response.body)["results"].should be_a_kind_of(Array) }
        it { JSON.parse(response.body)["results"].length.should eq 30 }
        # etc...
      end
    end
    

    Obviously a simple example, but hopefully you get the idea. I hope this helps.

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

Sidebar

Related Questions

I have a web service site that is restful enabled, so other websites/ajax script
I have a RESTful API containing a URI of /UserService/Register. /UserService/Register takes an XML
I have two applications that use same database. Let's call them Site and API.
I have a very simple WCF4 Restful web service which uses WcfRestContrib to allow
I have a rails site that allows authentication through OAuth (I use Restful Authentication
Consider following scenario: I have RESTful URL /articles that returns list of articles user
I have a restful web service which can deal with DTOs in json format
I have a ReSTful web service which needs to parse locale-sensitive data from the
I have a RESTful API serving JSON. I'm calling it like this: - (void)viewDidLoad
Let's say I have a RESTful, hypertext-driven service that models an ice cream store.

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.