简体   繁体   中英

Testing a Rails gem with test/dummy app, /tmp folder gets clobbered…somehow

I'm writing a gem that has to select which version of a XYZ.js file to make available to sprockets //= require "XYZ" statements based on configuration at app startup. My solution is to copy the XYZ.variant.js or XYZ.variant2.js to /tmp/cache/<gemname>/XYZ.js in the Rails app. This seems to work if I manually test; if I go to the test/dummy folder and test the functionality via rackup the XYZ.js is properly found. If I test the gem via another rails app, it works (via path: in Gemfile).

But, when I run the test suite for this gem, it fails, because at some point after the initial copy to /tmp/cache/<gemname>/XYZ.js , the whole tmp folder gets cleared, and the only thing in it by the time the test actually gets run is /tmp/cache/assets . I don't understand how this could be behaving different b/w the test suite and the other 2 working methods. It's as if the initialization order is different or something. Is there something special that running via rackup would do that would change the initialization order?

Note that the test suite worked fine before this particularly addition to the code that did the tmp copying. It's just the normal enginex code that would have been generated.

这与初始化程序无关,而与另一个测试案例(对于生成器)无关,后者破坏了tmp文件夹。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM