Skip to content

Sample out to showcase bug with creating tempfiles in Rspec with Jruby

Notifications You must be signed in to change notification settings

synth/jruby-rspec-tempfile-bug

Repository files navigation

This is a sample app to showcase a bug that occurs with creating Tempfiles in Jruby. I was only able to reproduce this with RSpec so I’m not exactly sure where the bug actually lies. Further, the bug is only apparent when uploading a fixture file in separate describe blocks. If they are in the same describe block, the issue does not occur.

The bug occurs when both of the following are true:

1. Rspec.config.order = "random"
2. ActionMailer::Base.deliveries is not cleared in a before block

The last item is super weird, but its what will actually get the test to pass.

Please see the Travis test matrix to see it pass and fail on different version of Ruby and Jruby: travis-ci.org/synth/jruby-rspec-tempfile-bug/builds/190508014

Some versions may be feeling due to red-herrings, but in particular, JRuby 9.1.5.0 experiences a NullPointException which is how I first came across this issue.

  1. Run spec test that will fail

    rspec spec/temp_file_spec.rb
    
  2. To see the test pass, do either of the following

    1. Comment out in spec_helper.rb "config.order = 'random'"
    2. Or uncomment the before block that clears out ActionMailer::Base.deliveries

About

Sample out to showcase bug with creating tempfiles in Rspec with Jruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published