[LRUG] Fwd: Testing JS in Rails 4

George Sheppard george at fuzzmonkey.co.uk
Wed Jul 31 07:25:18 PDT 2013


> I'm not sure how to do this, and Rails 4 seems to have a bunch of stuff hard-coded that's not configurable (e.g. it minifies code in production but not development and none of the config flags for this change anything). Where are the docs?

Rather than messing with the digests themselves you could use the manifest.json file to find the fingerprinted asset names from the the filenames. The only problem being that the manifest.json file is also fingerprinted... It's generated after rake assets:precompile in public/assets

George

On 31 Jul 2013, at 15:05, James Coglan <jcoglan at gmail.com> wrote:

> On 31 July 2013 11:34, Murray Steele <murray.steele at gmail.com> wrote:
>> Could you customise the digest mechanism in sprockets to produce empty (or knowable) digest suffixes.  Of course, you'd only want this for the JS test run, so you're not testing your exact production files, but you're testing something very close to it.
> 
> I'm not sure how to do this, and Rails 4 seems to have a bunch of stuff hard-coded that's not configurable (e.g. it minifies code in production but not development and none of the config flags for this change anything). Where are the docs?
>  
>> Alternatively, could you asset compile the JS test harness so that it has the digested asset names in it?
> 
> That's not a bad idea, and will work with a few test runners. Compile the code and tests into one static JS file, stick it on a web page, and have it run. Still probably requires the build target to have a stable un-digest-ed name in order to be easy to use. Or, you could run `cat public/assets/test-*.js > public/assets/test.js` after compiling.
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130731/885a0fe3/attachment.html>


More information about the Chat mailing list