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

jb renders an empty string in rspec controller test in both Rails4 and Rails5 #11

Open
gfx opened this issue Mar 14, 2017 · 1 comment

Comments

@gfx
Copy link

gfx commented Mar 14, 2017

It sometimes renders an empty string with status 200, or sometimes just raises 404. The app below reproduces the former, though.

The demo is based on Rails5 but I have found this problem on my Rails4 app.

How to reproduce it

https://github.com/gfx/test_jb (Rails5)

  1. git clone the repo
  2. bundle install
  3. bundle exec rspec

will shows:

$ bundle exec rspec
F

Failures:

  1) FoosController#index should eq "[]"
     Failure/Error: expect(response.body).to eq("[]")

       expected: "[]"
            got: ""

       (compared using ==)
     # ./spec/controllers/foos_controller_spec.rb:8:in `block (3 levels) in <top (required)>'

Finished in 0.06748 seconds (files took 4.92 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/controllers/foos_controller_spec.rb:5 # FoosController#index should eq "[]"

curl http://localhost:3000/foos.json with rails server does return [] as expected.

@dks17
Copy link

dks17 commented Mar 23, 2018

@gfx hello
Please check my comment in #18.
Try to set rspec render_views setting to true:

RSpec.configure do |config|
  config.render_views = true
end

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

2 participants