[LRUG] Fwd: Testing JS in Rails 4

James Coglan jcoglan at gmail.com
Wed Jul 31 07:05:45 PDT 2013


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130731/c4df1f20/attachment-0003.html>


More information about the Chat mailing list