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

The Archive Base Latest Questions

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

I’ve ben struggling with this for a couple hours now. I am using Rack::Test

  • 0

I’ve ben struggling with this for a couple hours now. I am using Rack::Test to write API tests for my Rails 3.2 app.

Regardless of what I do, last_response has an empty body (well, specifically it has “{}”, so 2 characters).

Here are the tests:

describe "updating a product set with JSON" do
  def app
    ProductSetsController.action(:update)
  end

  let(:update_json) { ... }

  before do
    @product_set = FactoryGirl.build(:product_set)
  end
  it { @failures.should == 0 }

  it "should not increment the product set count" do
    expect { put :update, update_json }.to_not change(ProductSet, :count).by(1)
  end

  it "should increment the conditions count" do
    expect { put :update, update_json }.to change(@product_set.conditions, :count).by(2)
  end

  context "response should be valid" do
    before do
      put :update, update_json
    end
    subject { last_response }
    it { should be_ok }
  end
end

All these tests pass. But the body is empty.

The weird thing is that if I run the actual application the response body is definitely not empty. It has JSON about the updated product_set.

So I’m setting up the test incorrectly somehow. I bet I’m overlooking something really silly as this is my first time using Rack::Test. Any thoughts?

Just had a thought that I may not be setting the request headers correctly. I’m also using RABL for generation.

UPDATE:
The problem is indeed with RABL. Haven’t figured out a solution yet, but if I use:

respond_with(@product_set.update_attributes(get_properties(params)),
  file: 'app/views/product_sets/update.json.rabl', :handlers => [:rabl])

instead of:

respond_with(@product_set.update_attributes(get_properties(params)))

then it works in testing, whereas both work in development or production. Also I’ve confirmed that it’s not a Gemfile problem.

  • 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-11T15:42:25+00:00Added an answer on June 11, 2026 at 3:42 pm

    Found the answer. In short, make sure to use the keyword “render_views” at the top of the root describe block in the rspec document to ensure that views are rendered correctly.

    This was the helpful article:
    https://github.com/nesquena/rabl/wiki/Testing-with-rspec

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

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.