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

Test of http response with wrong matcher never return #1129

Closed
vivit-jc opened this issue Jul 24, 2014 · 3 comments
Closed

Test of http response with wrong matcher never return #1129

vivit-jc opened this issue Jul 24, 2014 · 3 comments

Comments

@vivit-jc
Copy link

I found the case what never ends in controller specs. I should write test code like this:

expect(response.status).to eq(404)

But I wrote this in mistake:

expect(response).to eq(404)

and I ran rspec test, so it never ends. I'm using latest version of Rails and RSpec. What do you think about?

@JonRowe
Copy link
Member

JonRowe commented Jul 24, 2014

You haven't provided enough information to reproduce this, expect(response).to eq(404) should fail almost immediately, if it's not it's possibly because response is taking a very long time to return, but without further information I can't replicate this, can you produce a standalone reproduction of this?

@vivit-jc
Copy link
Author

I'm sorry my inspection was not enough. I created a new rails project, generate a scaffold model and add just only gem 'rspec-rails' in Gemfile for replication. My test returned a result rightly, expect(response).to eq(404) was failed. Probably, some gem in my project cause that issue. I'm investigating what gem do it. This is my Gemfile:

source 'https://rubygems.org'

gem 'rails'
gem 'sqlite3'

gem 'execjs'
gem 'therubyracer'
gem "less-rails"

group :assets do
  gem 'sass-rails'
  gem 'coffee-rails'
  gem 'uglifier', '>= 1.0.3'
end

gem "slim"
gem "ruby_parser"
gem "html2haml"
gem "slim-rails"

gem 'protected_attributes'
gem 'jquery-rails'
gem 'devise'
gem 'kaminari'
gem 'twitter-bootstrap-rails'
gem 'google-analytics-rails'

group :development,:test do
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'guard'
end

group :test do
  gem 'faker'
  gem 'capybara'
  gem 'database_cleaner'
  gem 'launchy'
  gem 'selenium-webdriver'
end

group :production do
  gem 'mysql2'
end

Any idea?

@myronmarston
Copy link
Member

This is due to 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:

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