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

Controller specs: response.should == 'string' #613

Closed
pschuegr opened this issue Oct 3, 2012 · 3 comments
Closed

Controller specs: response.should == 'string' #613

pschuegr opened this issue Oct 3, 2012 · 3 comments

Comments

@pschuegr
Copy link

pschuegr commented Oct 3, 2012

Seems to explode. Memory usage goes up to > 8GB and the test does not return.

it "should fail to return a list of questions" do
  get :index, {}, :controller => "api/questions"
  response.should == 'hi'
  response.should be_success
  result = JSON.parse(response.body)
  result['success'].should == false
end

Of course, this is not really a legitimate test, I intended to use

response.body.should == 'hi'

But I have no idea what's happening.

@alindeman
Copy link
Contributor

This is a yucky issue, agreed.

tldr: You want to assert on response.body, not response (which is a Rack::Response, not a String).

The underlying issue is in Rack. See rack/rack#419 and previous rspec issues rspec/rspec-expectations#166 and #601

@raggi
Copy link

raggi commented Nov 2, 2012

This is now fixed on the rack side, in master.

@pschuegr
Copy link
Author

pschuegr commented Nov 2, 2012

Thanks for the update, raggi.

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