Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expect(response).to be 200 initiates lag and memory leak #964

Closed
atomAltera opened this issue Mar 22, 2014 · 2 comments
Closed

expect(response).to be 200 initiates lag and memory leak #964

atomAltera opened this issue Mar 22, 2014 · 2 comments

Comments

@atomAltera
Copy link

Hello, I'm just begun learning controller testing with RSpec and accidently wrote

expect(response).to be 200

in place of

expect(response).to be_success

Full unit:

require 'spec_helper'

describe UserController do

  describe "GET 'show'" do
    it "assigns the requested user to @user" do
      user = create(:user)

      get :show, id: user.id

      expect(response).to be 200
      expect(response).to render_template :show

      expect(assigns :user).to eq user
    end
  end

end

Result is shown in image:
screenshot - 03222014 - 01 19 27 pm

@myronmarston
Copy link
Member

This is due a bug in either rack (see rack/rack#419) or rails (see rails/rails#13921 and rails/rails#13982) that causes [response].flatten to recurse infinitely. Both have been fixed (although I'm not sure if the rails fix has been released) but if you upgrade to versions that have fixes the problem will go away. In the meantime, make expectations about attributes of the response rather than on the response itself.

For more history/discussion see:

@JonRowe
Copy link
Member

JonRowe commented Mar 23, 2014

Good catch @myronmarston

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants